Hi
I can change Y axis to a logarthmic scale by doing;
tChart1.Axes.Left.Logarithmic = true;
However the axis only shows 1 label. See the 2 attached screenshots for a linear scale chart and the corresponding logarithmic scale chart.
I searched the forum and I found you can do;
tChart.Axes.Left.Increment = 100;
tChart1.Axes.Left.Logarithmic = true;
This improves things a bit with more labels displayed. However depending on the Y-axis scale, often there are too many labels and they overlap.
Is there a way to calculate the Increment (perhaps based on the max and min Y values in the chart?) such that a reasonable number of labels (that do not overlap!) are displayed.
Thanks!
Setting Labels for a Logarithmic Scale
Setting Labels for a Logarithmic Scale
- Attachments
-
- chart with logarithmic scale
- log.PNG (65.68 KiB) Viewed 7657 times
-
- chart with normal linear scale
- linear.PNG (78.28 KiB) Viewed 7652 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Setting Labels for a Logarithmic Scale
Dave,
This can be modified to account for scrolling vertically upwards and for other similar circumstances.
An example here uses scrolling ... run the following code and then scroll the chart vertically (right-button mouse click and drag down):Dave wrote:s there a way to calculate the Increment (perhaps based on the max and min Y values in the chart?) such that a reasonable number of labels (that do not overlap!) are displayed.
Code: Select all
private void InitializeChart()
{
Random rnd = new Random();
tChart1.Aspect.View3D = false;
for (int i = 0; i < 5; i++)
{
tChart1.Series.Add(typeof(Line));
for (int j = 0; j < 50; j++)
{
tChart1[i].Add(rnd.Next(10000, 1000000));
}
}
tChart1.Scroll += TChart1_Scroll;
}
private void TChart1_Scroll(object sender, EventArgs e)
{
double range = tChart1.Axes.Left.Maximum - tChart1.Axes.Left.Minimum;
range /= 10000;
int div = (Utils.Round(range) / 100) * 100;
tChart1.Axes.Left.Increment = div;
}
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 |
Re: Setting Labels for a Logarithmic Scale
Thanks Chris. That helped a lot.