Modifying the formatting of ChartAxisLabels
I have an issue when modifying my series, namely switching from a standard numerical axis to a logarithmic axis. Because my values are very low (between 0 and ~0.0000003), when switching to a standard numerical axis, they are all rounded to 0, which is not good. I have tried linking the following method to the LabelCreated event but to no avail - it's still a bunch of 0's which appear in the axis.
private void XValueFormatter(object sender, LabelCreatedEventArgs e) {What can I do to achieve my task?
double val = Convert.ToDouble(e.AxisLabel.LabelContent);
if (Math.Abs(val) < 0.1)
e.AxisLabel.LabelContent = val.ToString("G1", CultureInfo.InvariantCulture);
else
e.AxisLabel.LabelContent = val;
}
Hi Jeremie,
Thank you for contacting Syncfusion Support.
We have achieved your requirement by applying the required format for the axis label in LabelCreated event as like in the below code sample.
Code Snippet [C#]
|
private void XValueFormatter(object sender, LabelCreatedEventArgs e) { var axisLabel = e.AxisLabel; axisLabel.LabelContent = string.Format("{0:0.#######}", axisLabel.Position); } |
Regards,
Samuel
Please confirm us, whether your requirement is to display the exact value or the exponential format of actual value.
For example:
(1) 0.0000003 need to display as 3E-6,
Code sample[C#]:
|
|
(2) Need to display 0.0000003 as itself.
Code sample[C#]:
|
|
Regards,
Sumathi J
Thanks for the update.
We have prepared a sample to meet your requirements and it can be downloaded from the following location.
Sample: XAxisLabel_Sample
Regards,
Sumathi J
- 5 Replies
- 3 Participants
-
JC Jeremie Clos
- Apr 1, 2016 04:38 PM UTC
- Apr 6, 2016 12:00 PM UTC