Adding labels to series (Horizontal Bar)

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
DaVinci
Newbie
Newbie
Posts: 9
Joined: Wed Feb 18, 2015 12:00 am

Adding labels to series (Horizontal Bar)

Post by DaVinci » Tue Jun 09, 2015 2:59 pm

Hi,

I have a small sample application in which I create a Horizontal Bar Series.
snap1.png
snap1.png (8.17 KiB) Viewed 6124 times
I use the following code to create it:
horizBar1.Clear();
horizBar1.Add(50);
horizBar1.Add(80);
horizBar1.Add(70);
horizBar1.Add(60);

I want to add labels to the bars like this:
horizBar1.Labels.Clear();
horizBar1.Labels.Add("fifty");
horizBar1.Labels.Add("eighty");
horizBar1.Labels.Add("seventy");
horizBar1.Labels.Add("sixty");
but the labels do not correspond with the bar values: bar with value '50' should correspond with label "fifty".

The result of the above code is:
snap2.png
snap2.png (12.71 KiB) Viewed 6127 times
What is the relation of the labels and the bars?
I know you can add the label when you add the data point (horizBar1.Add() method), but at the point where I create the bars, the labels are not known yet and need to be added afterwards.

Thanks for your help.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Adding labels to series (Horizontal Bar)

Post by Christopher » Thu Jun 11, 2015 8:49 am

Hello,

Using the latest public release, the following code:

Code: Select all

    HorizBar horizBar1;

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      horizBar1 = new HorizBar(tChart1.Chart);

      horizBar1.Clear();
      horizBar1.Add(50);
      horizBar1.Add(80);
      horizBar1.Add(70);
      horizBar1.Add(60);

      horizBar1.Labels.Clear();
      horizBar1.Labels.Add("fifty");
      horizBar1.Labels.Add("eighty");
      horizBar1.Labels.Add("seventy");
      horizBar1.Labels.Add("sixty");
    }
Gives me the following:
export635696092114004400.png
export635696092114004400.png (15.52 KiB) Viewed 6111 times
Does this code give you different results? Which version of TeeChart.dll are you using?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

DaVinci
Newbie
Newbie
Posts: 9
Joined: Wed Feb 18, 2015 12:00 am

Re: Adding labels to series (Horizontal Bar)

Post by DaVinci » Thu Jun 11, 2015 10:14 am

Hi Christopher,

I am using the latest version 4.1.2015.5142.

I found my mistake: for some reason, I accidentaly modified the XValues.Order in the TeeChart Editor. It should be set to 'None' before adding values and labels.
Thanks for your help to figure this out.

Post Reply