We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error bars

Hello,

I have a set of data plotted as a chart. I also have a column that contains the error that I would like to use as error bars. I see there is a fixed value amount for error bars, but how can I add the corresponding error to each individual point?


This message was posted using Aspose.Live 2 Forum

Hi,

Please see the following sample code for your reference:

Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
cells[“a1”].PutValue(2);
cells[“a2”].PutValue(5);
cells[“a3”].PutValue(3);
cells[“a4”].PutValue(6);
cells[“b1”].PutValue(4);
cells[“b2”].PutValue(3);
cells[“b3”].PutValue(6);
cells[“b4”].PutValue(7);

cells[“C1”].PutValue(“Q1”);
cells[“C2”].PutValue(“Q2”);
cells[“C3”].PutValue(“Y1”);
cells[“C4”].PutValue(“Y2”);

int chartIndex = workbook.Worksheets[0].Charts.Add(ChartType.Column, 11, 0, 27, 10);

Chart chart = workbook.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add(“A1:B4”, true);

chart.NSeries.CategoryData = “C1:C4”;


ASeries aseries = chart.NSeries[1];
aseries.YErrorBar.DisplayType = ErrorBarDisplayType.Both;
aseries.YErrorBar.Type = ErrorBarType.Custom;
aseries.YErrorBar.PlusValue = “B1:B2”;
aseries.YErrorBar.MinusValue = “B3:B4”;
aseries.YErrorBar.Style = LineType.Solid;
aseries.YErrorBar.Color = Color.Red;
aseries.YErrorBar.Weight = WeightType.SingleLine;



workbook.Save(“e:\test\errorbars.xls”);


If you still could not evaluate, kindly create a simple chart with your desired error bars in MS Excel (manually) and post the Excel file here, we will check it soon.

Thank you.