Error Bars on Bar Chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Error Bars on Bar Chart

Post by porterbe » Tue Oct 19, 2010 10:28 am

Hi

I am wondering if it is possible to do some form of error bar on a bar chart.

The kind of thing I am thinking of is a normal bar chart, with an error band at the top - but I am open to suggestions. I don't seem to be able to locate any tutorials on adding error bars to a plot series either, but that may well be me being thick...

TIA for the help

Bernie

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Error Bars on Bar Chart

Post by Sandra » Tue Oct 19, 2010 2:06 pm

Hello Bernie,

TeeChart.Net gives you a series specially for do you want. I recommend you take a look to a Demo of TeeChart.Net concretely in t he example:All Features\Welcome!\Chart styles\Statistical\Error Bar

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Error Bars on Bar Chart

Post by porterbe » Tue Oct 19, 2010 3:59 pm

Ok, I missed that one. It's ok, and it'll do for a start, but what I really wanted to do was something akin to the image attached (edited in PSP from your example)...

You'll note I've modified the 2nd bar to have upper and lower error bands. Is this as simple as using a Bar series then adding adding a second error series? How would I get different upper and lower error bands?

TIA....

Bernie
Attachments
Desired ErrorBar Format.png
Desired ErrorBar Format.png (13.59 KiB) Viewed 7573 times

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Error Bars on Bar Chart

Post by porterbe » Tue Oct 19, 2010 4:04 pm

I've also just noticed that the legend is now using the error bar shape and colour - is there any way of changing it back to display a square block of Bar colour?

Bernie

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Error Bars on Bar Chart

Post by porterbe » Wed Oct 20, 2010 7:55 am

Ok, I've found the .ErrorStyle property that seems to do what I need.

Still haven't found a way of turning the legend back the way I want it though...

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Error Bars on Bar Chart

Post by Yeray » Wed Oct 20, 2010 8:05 am

Hi porterbe,
porterbe wrote:the legend is now using the error bar shape and colour - is there any way of changing it back to display a square block of Bar colour?
Do you mean that the Error Bar series showed a square in the legend in a previous version? I can see the same in TeeChart for NET v3 and v2.
If you want, you can customize the legend symbols as in the example at All Features\Welcome !\Miscellaneous\Legend\OnDrawSymbol Event
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Error Bars on Bar Chart

Post by porterbe » Wed Oct 20, 2010 9:01 am

When I used a standard bar series, my legend looked like the image BarLegend.png
BarLegend.png
BarLegend.png (8.44 KiB) Viewed 7595 times
With a ErrorBar series, my legend looks like the image ErrorBarLegend.png.
ErrorBarLegend.png
ErrorBarLegend.png (8.81 KiB) Viewed 7597 times
I want the error bars in ErrorBarLegend.png, but with the Legend from BarLegend.png. Can I get this?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Error Bars on Bar Chart

Post by Sandra » Wed Oct 20, 2010 10:41 am

Hello Bernie,

I think you can do something as next example:

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            Steema.TeeChart.Styles.ErrorBar series1 = new Steema.TeeChart.Styles.ErrorBar(tChart1.Chart);
            Steema.TeeChart.Styles.ErrorBar series2 = new Steema.TeeChart.Styles.ErrorBar(tChart1.Chart);
            Steema.TeeChart.Styles.ErrorBar series3 = new Steema.TeeChart.Styles.ErrorBar(tChart1.Chart);
            series1.Add(0, 123, 23);
            series2.Add(1, -432, 65);
            series3.Add(2, 88, 13);
            series1.Add(4, 222, 44);
            series1.ErrorPen.Color = Color.Blue;
            series1.Color = Color.Red;
            series2.ErrorPen.Color = Color.Blue;
            series2.Color = Color.Red;
            series3.ErrorPen.Color = Color.Blue;
            series3.Color = Color.Red;
            series1.ErrorStyle = Steema.TeeChart.Styles.ErrorStyles.TopBottom;
            series2.ErrorStyle = Steema.TeeChart.Styles.ErrorStyles.Bottom;
            series3.ErrorStyle = Steema.TeeChart.Styles.ErrorStyles.Top;
            tChart1.Legend.Symbol.OnSymbolDraw += new Steema.TeeChart.SymbolDrawEventHandler(Symbol_OnSymbolDraw);
        }

        void Symbol_OnSymbolDraw(object sender, Steema.TeeChart.SymbolDrawEventArgs e)
        {
            Rectangle tmpR = e.Rect;
            tChart1.Chart.Graphics3D.Rectangle(tmpR);   
        }
Could you please, tell us if this code works as you want?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Error Bars on Bar Chart

Post by porterbe » Wed Oct 20, 2010 12:24 pm

That'll do the job, thank you :D .

I had come to a similar conclusion, but I was struggling with how to fill the rectangle. Now I know!

Post Reply