Hello,
Perhaps I'm not understanding the question well so I'll answer different aspects in the way I see them.
An index on the data would give you the exact chart you want without the year labels:
ie.
Code: Select all
int[] idx = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int[] year = { 2021, 2021, 2021, 2021, 2022, 2022, 2022, 2023, 2023, 2023, 2023 };
string[] label = { "A", "B", "C", "D", "E", "F", "A", "S", "T", "H", "N" };
double[] total = { 10, 20, 20, 20, 10, 10, 20, 10, 20, 20, 10 };
private void Form1_Load(object sender, EventArgs e)
{
//note an index (idx here) is not required for this add overload as it is automatically added, but it
//helps to include it for clarity/understanding.
for (int i = 0; i < 11; i++)
{
points1.Add(total[i], label[i]);
//or
//points1.Add(idx[i], total[i], label[i]);
}
tChart1.Axes.Left.SetMinMax(0, 50);
}
You can add the year to the label in this way, via the OnGetAxisLabel event:
Code: Select all
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender == tChart1.Axes.Bottom)
{
if (e.ValueIndex != -1)
e.LabelText = e.LabelText + "\n" + year[e.ValueIndex].ToString();
}
}
If you only want the year once, at the first value of the year for example, then you could setup the OnGetAxisLabel event in this way:
Code: Select all
int lastYear = -1;
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender == tChart1.Axes.Bottom)
{
if (e.ValueIndex != -1)
if (lastYear != year[e.ValueIndex])
{
e.LabelText = e.LabelText + "\n " + year[e.ValueIndex].ToString();
lastYear = year[e.ValueIndex];
}
}
}
- points_year.png (1.78 KiB) Viewed 26096 times
There are other options, including putting the year to the centre of each range, but that requires a little more work…
You could even plot the grouping symbol. Custom drawing is described here:
Custom drawing Tutorial
Regards,
Marc