Page 1 of 1

Adding labels to series (Horizontal Bar)

Posted: Tue Jun 09, 2015 2:59 pm
by 15671530
Hi,

I have a small sample application in which I create a Horizontal Bar Series.
snap1.png
snap1.png (8.17 KiB) Viewed 6143 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 6146 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.

Re: Adding labels to series (Horizontal Bar)

Posted: Thu Jun 11, 2015 8:49 am
by Christopher
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 6130 times
Does this code give you different results? Which version of TeeChart.dll are you using?

Re: Adding labels to series (Horizontal Bar)

Posted: Thu Jun 11, 2015 10:14 am
by 15671530
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.