0

im relativley new to Excel Scripts and i need your help.

I have build an Excel Script which i want to add to my power automate flow, to generate graphs automatically with a predefined template.

In general i want to add vertical gridlines to the graph so that it becomes easier for the reader to look at the data. On the right side i haven't figured out how to set the x-Axis with the labels to the bottom of the graph, now it does not look uniform with regards to the left graph.

any help is appreciated :)

// Formating Graph1 //-----------------------------------------------

AAchart.getTitle().setVisible(false);
AAchart.getLegend().setVisible(false);


AAseriesC.getFormat().getLine().setColor("#00B050");
AAseriesG.getFormat().getLine().setColor("#FF0000");
AAseriesH.getFormat().getLine().setColor("#00B050"); //green

let AALineFormatC = AAseriesC.getFormat().getLine();
AALineFormatC.setWeight(2);
let AALineFormatG = AAseriesG.getFormat().getLine();
AALineFormatG.setWeight(2);
let AALineFormatH = AAseriesH.getFormat().getLine();
AALineFormatH.setWeight(2);

AAseriesC.setMarkerStyle(ExcelScript.ChartMarkerStyle.none);
AAseriesG.setMarkerStyle(ExcelScript.ChartMarkerStyle.none);
AAseriesH.setMarkerStyle(ExcelScript.ChartMarkerStyle.none);

let AAseriesAB = AAchart.getSeries()[0];
AAseriesAB.setMarkerStyle(ExcelScript.ChartMarkerStyle.circle);
AAseriesAB.setMarkerBackgroundColor("#FFFFFF");
AAseriesAB.setMarkerSize(6);

enter image description here


4
  • 1
    So why not build a template with the charts formatted etc ready to go then just dump the fresh data in and then save as Newfile? That was the route we used for over 100,000 files... Commented Sep 5, 2024 at 9:12
  • @SolarMike thank you for your response. I already build a template the way i want my data to be presented. But I'm not sure how to access this template in the excel script itsself. In my script i generate a graph like this: let chart = Sheet.addChart(ExcelScript.ChartType.line,rangeAB); I used the standard Chart Type line but is it possible to input my template here ? Commented Sep 5, 2024 at 11:08
  • Please edit your question instead of adding information in comments. Commented Sep 5, 2024 at 14:19
  • How do I ask a good question? Why should I not upload images of code/data/errors?. Commented Sep 6, 2024 at 13:42

1 Answer 1

0

Relocate Axis-X location to bottom of the chart.

Microsoft documentation:

ExcelScript.ChartAxis interface setPosition(position)

ExcelScript.ChartAxis interface getMinimum()

function main(workbook: ExcelScript.Workbook) {
    let sht = workbook.getActiveWorksheet();
    let cht = sht.getCharts()[0];
    let axisX = cht.getAxes().getValueAxis();
    // axisX.setPosition(ExcelScript.ChartAxisPosition.automatic);
    axisX.setPosition(ExcelScript.ChartAxisPosition.custom) ;
    axisX.setPositionAt(axisX.getMinimum());
}

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

taller thank you so much, this works perfectly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.