Skip to content

Instantly share code, notes, and snippets.

@MiaofeiWang
Created July 13, 2017 02:56
Show Gist options
  • Save MiaofeiWang/b70c6d5d29dac99107f979654e6e86f4 to your computer and use it in GitHub Desktop.
Save MiaofeiWang/b70c6d5d29dac99107f979654e6e86f4 to your computer and use it in GitHub Desktop.
In scatter chart, add a new series and set data for it. - Shared with Script Lab
name: Add Series For Bubble
description: 'In scatter chart, add a new series and set data for it.'
author: MiaofeiWang
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(run);
async function run() {
try {
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getActiveWorksheet();
var seriesCollection = sheet.charts.getItemAt(0).series;
var series = seriesCollection.add("Product B");
var rangeSelection = "F3:F6";
var xValue = sheet.getRange(rangeSelection);
series.setXAxisValues(xValue);
rangeSelection = "G3:G6";
var values = sheet.getRange(rangeSelection);
series.setValues(values);
rangeSelection = "H3:H6";
var sizes = sheet.getRange(rangeSelection);
series.setBubbleSizes(sizes);
seriesCollection.load("count");
await context.sync();
console.log("Succeed to add a new series and set data!");
console.log("Series count = " + seriesCollection.count);
});
}
catch (error) {
OfficeHelpers.UI.notify(error);
OfficeHelpers.Utilities.log(error);
}
}
language: typescript
template:
content: |
<button id="run" class="ms-Button">
<span class="ms-Button-label">Run</span>
</button>
language: html
style:
content: "/* Your style goes here */\r\n"
language: css
libraries: |
# Office.js
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
# CSS Libraries
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css
# NPM libraries
core-js@2.4.1/client/core.min.js
@microsoft/office-js-helpers@0.7.1/dist/office.helpers.min.js
jquery@3.1.1
# IntelliSense: @types/library or node_modules paths or URL to d.ts files
@types/office-js
@types/core-js
@microsoft/office-js-helpers@0.7.1/dist/office.helpers.d.ts
@types/jquery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment