Office Scripts : Chart Data Labels "Values From Cells
Tim Smith
0
Reputation points
I am trying to create an Automate Script in Excel that will generate and format chart. I am getting close, but I can't figure out how to set Data Label values. I want the same functionality as the Format Data Label/Label Options/Vale From Cells as shown in the attached image.
This code will show the Y Value as the data label and rotate it 90deg. How can I set this to a cell value instead of the Y Value?
const thirdSeries = chart_2.addChartSeries();
YRange = CMBSheet.getRange('G2').getResizedRange(rowCount - 1, 0);
thirdSeries.setXAxisValues(XRange);
thirdSeries.setValues(YRange);
secSName = CMBSheet.getRange('G1').getText();
thirdSeries.setName(secSName);
thirdSeries.setHasDataLabels(true);
let thSDataLab = chart_2.getSeries()[3].getDataLabels();
//thirdSeries.setShowValue(true);
//thSDataLab.setShowLegendKey(true);
thSDataLab.setPosition(ExcelScript.ChartDataLabelPosition.top);
thSDataLab.setTextOrientation(90);
If there is no API for this, is there at least a method I could use to set the text of the data label?
Sign in to answer