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

Free Support Forum - aspose.com

ErrorBar Range

Does aseries.yerrorbar support a range of values so each data point in a series can have a different plus and/or minus value?

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

There are different options for aseries.YErrorBar.Type which you can use. But the type you specify will be used for all the series datapoints. Forexample, if you choose, ErrorBarType.FixedValue then the fixed value (specified in aseries.YErrorBar.Amount property) will be equal and fix for all data points. If you choose ErrorBarType.Percent then the value for errorbar will be be according to the parcentage of datapoint value (percentage specified in aseries.YErrorBar.Amount property). Please see the following sample code with may clear the concept abit more for you,

Sample Code:

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";

//With Fixed Value

ASeries aseries1 = chart.NSeries[0];

aseries1.YErrorBar.DisplayType = ErrorBarDisplayType.Plus;

aseries1.YErrorBar.Type = ErrorBarType.FixedValue;

aseries1.YErrorBar.Amount = 5;

//With Percent

ASeries aseries2 = chart.NSeries[1];

aseries2.YErrorBar.DisplayType = ErrorBarDisplayType.Both;

aseries2.YErrorBar.Type = ErrorBarType.Percent;

aseries2.YErrorBar.Amount = 75;

workbook.Save("c:\\new_Chart.xls");

Thank You & Best Regards,

Hi,

And, you may also try custom errorbar type specifying "+", "-" bar values for your requirements. Check the following piece of code.

e.g.,

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;
If you still have different opinion and it does not fit your need, kindly create a sample chart with your desired error bars in MS Excel (97-2003) manually and post the excel file here, we will check and try to mimic it using Aspose.Cells APIs for your need.
Thank you.

That was it thanks. I didn’t know PlusValues and MinusValues properties took ranges.