1

I am trying to draw a horizontal boxplot in Excel using Script Lab. For this, I first created a stacked bar chart and made the first and the last bars as transparent. Now I am trying to add error bars to the data bar in the middle using the following snippet:

async function addErrorBars() {
  await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    var chart = sheet.charts.getItemAt(0);
    chart.series.getItemAt(3).xErrorBars.visible = true;
    chart.series.getItemAt(3).xErrorBars.type = Excel.ChartErrorBarsType.percent;
    chart.series.getItemAt(3).xErrorBars.include = Excel.ChartErrorBarsInclude.both;
    chart.series.getItemAt(3).xErrorBars.endStyleCap = true;

    await context.sync();
  });
}

However, I do not see any xerror bars in my stacked bar chart. Can someone please guide me as I do not know what am I doing wrong? And if I choose chart.series.getItemAt(3).xErrorBars.type = Excel.ChartErrorBarsType.custom;, then how can I specify the custom value?

PS: If there is a better way to draw a horizontal box plot in Excel using Script lab, then please let me know.

Thanks

Vinni

Vinni
  • 23
  • 1
  • 6

1 Answers1

0

Does boxplot chart means Box and Whisker chart? You could use

let chart = sheet.charts.add(Excel.ChartType.boxwhisker, range);

to create a Box and Whisker chart.

Dongqi Lv
  • 71
  • 2
  • Thanks. But I would like to create a horizontal boxplot and it is not possible to rotate the chart 90 degrees. Or is it? – Vinni Jan 03 '20 at 14:07