Hi,
I have a plot, I'm using automatic axes. When I don't do anything special, the X axis is neatly divided and I get major ticks at -8, -6, -4, -2 and 0. What I want to do now is to slightly modify these labels - say, replace "0" with "zero". So I'm subscribing to the GetAxisLabel event and making my label change there.
The problem is that as a result my automatic axis is putting the major ticks at different X locations. My guess is that it looks at the lengths of my new labels and rearranges everything. But that's precisely what I don't want!
Any hints on how to modify my labels in GetAxisLabel but without changing the default automatic locations of the major labels?
Question about GetAxisLabel
-
- Newbie
- Posts: 64
- Joined: Fri Jun 16, 2006 12:00 am
Question about GetAxisLabel
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec
Michal Blazejczyk
Lead Programmer
Genome Quebec
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Michal,
You can try setting labels separation to zero to make the labels being as close as possible.
If this is not enough then you may need to use custom labels as you can see in the All Features\Welcome !\Axes\Labels\Custom labels example in the features demo.
You can try setting labels separation to zero to make the labels being as close as possible.
Code: Select all
tChart1.Axes.Bottom.Labels.Separation = 0;
Best Regards,
Narcís Calvet / 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 |
-
- Newbie
- Posts: 64
- Joined: Fri Jun 16, 2006 12:00 am
Yes, but if I do this, my major ticks will still end up at different locations than where they are created automatically. What I would like is to keep the automatic tick locations but change some of the labels. The problem is that Axis.Labels is empty when I'm setting up my chart. Any solution?
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec
Michal Blazejczyk
Lead Programmer
Genome Quebec
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Michal,
When using custom labels the ticks are also automatically placed. The features demo example ticks are not spaced equally because labels don't have regular increment. Try using something like this:
Axis.Labels.Items is not empty when using custom labels.
When using custom labels the ticks are also automatically placed. The features demo example ticks are not spaced equally because labels don't have regular increment. Try using something like this:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
tChart1.Aspect.View3D = false;
Random val = new Random();
for (int i = -8; i <= 0; i+=2)
{
line1.Add(i, val.Next());
}
AddCustomLabels();
}
private void AddCustomLabels()
{
tChart1.Axes.Bottom.Labels.Items.Clear();
for (int i = 0; i < line1.Count; i++)
{
if (line1.XValues[i] == -8) tChart1.Axes.Bottom.Labels.Items.Add(line1.XValues[i], "minus eight");
if (line1.XValues[i] == -6) tChart1.Axes.Bottom.Labels.Items.Add(line1.XValues[i], "minus six");
if (line1.XValues[i] == -4) tChart1.Axes.Bottom.Labels.Items.Add(line1.XValues[i], "minus four");
if (line1.XValues[i] == -2) tChart1.Axes.Bottom.Labels.Items.Add(line1.XValues[i], "minus two");
if (line1.XValues[i] == 0) tChart1.Axes.Bottom.Labels.Items.Add(line1.XValues[i], "zero");
}
}
Best Regards,
Narcís Calvet / 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 |