Hi,
I have a logarithmic Y axis with values smaller than 1. I have AutoFormatLabels set to true. It looks like this:
I don't want the 0.0 values. I thought AutoFormatLabels would take care of this, but it doesn't. Instead I have to change the LabelsNumberFormat. When I set "" (empty string) it uses the default double.ToString(), which is what I would like, but the labels and title are drawn over each other (it gets worse when panning):
By the way, I don't have this problem when using a linear axis.
Thanks for fixing!
Joost
Logarithmic Y axis labels and title
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Logarithmic Y axis labels and title
AutoFormatLabels doesn't handle this, and it seems we can improve it in v.7, but not v.6.
Please use this workaround:
- Set yAxis.AutoFormatLabels = False.
- define event handler for yAxis.FormatValueLabel:
Expect the left margin not to adjust correctly becuase it is based on checking maximum value with constant decimal count, so you may want to set ViewXY.AxisLayout.AutoAdjustMargins = false and define margins manually with ViewXY.Margins property.
Please use this workaround:
- Set yAxis.AutoFormatLabels = False.
- define event handler for yAxis.FormatValueLabel:
Code: Select all
string ExampleLogAxesXY_FormatValueLabel(AxisBase axis, double value)
{
if (value < 1)
{
string strFormat = "0.0";
double dValue = 1;
while (dValue > axis.LogZeroClamp)
{
dValue /= axis.LogBase;
if(value >= dValue)
break;
strFormat += "0";
}
return value.ToString(strFormat);
}
return value.ToString("0");
}
LightningChart Support Team, PT
Re: Logarithmic Y axis labels and title
I think you might have misunderstood me. When I set LabelsNumberFormat to string.Empty the formatting is exactly what I want it to be, so there's no need to use the event handler.
My problem is that the left margin is calculated incorrectly. Of course I can adjust the margin manually, but I expect AutoAdjustMargins to work properly, like it does when using a linear axis.
Thanks,
Joost
My problem is that the left margin is calculated incorrectly. Of course I can adjust the margin manually, but I expect AutoAdjustMargins to work properly, like it does when using a linear axis.
Thanks,
Joost
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Logarithmic Y axis labels and title
How about just setting yAxis.LogLabelsType = LogLabelsType.Log10Exponential ? Then margins adjust correctly automatically.
Manual margins can be calculated with aid of chart.MeasureText method. Pass axis label font, and the formatted label string. Measure both Minimum and Maximum value of axis and use the one having larger width, and add a little bit space for axis title and tick marks.
Manual margins can be calculated with aid of chart.MeasureText method. Pass axis label font, and the formatted label string. Measure both Minimum and Maximum value of axis and use the one having larger width, and add a little bit space for axis title and tick marks.
LightningChart Support Team, PT
Re: Logarithmic Y axis labels and title
These are nice workarounds, but the fact remains that AutoMargins should work properly for ALL ScaleTypes, ALL LogLabelsTypes and ALL LabelNumberFormats.
So please fix it in a (hopefully no too distant) future version.
Thanks,
Joost
So please fix it in a (hopefully no too distant) future version.
Thanks,
Joost