I've encountered a problem where with datapoints when the y values are around -1E-15
the labels for y axis change to 0 instead.
This seems to happen from around -1E-11, which is that last value seen when I set the range manually (e. g. attached screenshot)
Within the code there is no adjustment done to these labels (it is set to automatic).
Is there a way to have these numbers shown in a simple workaround or would I need to implement special zooming and panning helpers to display these values?
Hi Lukáš Krejcí,
We have validated your query and would like to inform you that axis labels are currently rounded to 11 decimal places. We are actively investigating potential workarounds to allow customization of the decimal rounding value. We will update you with further details within one business day (Nov 4, 2024).
Thank you for your patience and understanding.
Best regards,
Arul Jenith B.
Hi Lukas,
Thank you for your patience as we investigated your query. We have reviewed the behavior with decimal numbers on the axis labels and attempted to replicate the output you described, including testing with chart zooming. However, we have not been able to reproduce the issue so far. We are continuing our efforts to achieve consistent results.
In
the meantime, we recommend using the LabelCreated
event of the Numerical Axis to address the decimal precision requirement.
Within this event, you can access the label's position, which contains the full
value. By leveraging this, you can manually control the decimal
precision, byrounding it to 15 digits and assign it to LabelContent as shown in the code snippet below:
|
<chart:SfChart.SecondaryAxis> <chart:NumericalAxis LabelCreated="NumericalAxis_LabelCreated"/> </chart:SfChart.SecondaryAxis>
private void NumericalAxis_LabelCreated(object sender, Syncfusion.UI.Xaml.Charts.LabelCreatedEventArgs e) { var position = e.AxisLabel.Position; e.AxisLabel.LabelContent = Math.Round(position, 15).ToString(); } |
We will provide further updates, including a sample with the relevant code snippet on or before November 05th, 2024.
Thank you again for your patience and understanding.
Regards,
Dhanaraj Rajendran.
Hi Lukas,
In
our WPF SfChart, the axis labels are currently rounded to 11 decimal places by
default. You can adjust the number of decimal places to meet your specific
requirements by using the LabelCreated
event.
For your convenience, we’ve prepared a sample based on your requirements, which is attached to this message. Here’s a code snippet for reference:
|
<chart:SfChart.SecondaryAxis> <chart:NumericalAxis LabelCreated="NumericalAxis_LabelCreated"/> </chart:SfChart.SecondaryAxis> private void NumericalAxis_LabelCreated(object sender, Syncfusion.UI.Xaml.Charts.LabelCreatedEventArgs e) { var position = e.AxisLabel.Position; e.AxisLabel.LabelContent = Math.Round(position, 15).ToString(); } |
Output:
Thank you for your patience and understanding. Please let us know if you have any further questions.
Regards,
Dhanaraj Rajendran.
Hi,
Thank you for the response,
I have found the issue to be in sfChart's source code.
Specifically in
(Syncfusion.SfChart.WPF, Version=26.2.9.0)
namespace Syncfusion.UI.Xaml.Charts;
class ChartAxis
method GetActualLabelContent
where this value is hardcoded to be rounded
```cs
internal virtual object GetActualLabelContent(double position)
{
return Math.Round(position, 11).ToString(LabelFormat, CultureInfo.CurrentCulture);
}
```
Is there any possibility that this could be fixed?
Since it seems unnecessary to limit the string representation of double?
UPDATE:
After some nuances with my side of code this fix has helped.
Thank you very much
Hi Lukas,
We would like to inform you that in order to maintain consistency with our axis label standards, we round the decimal points to 11 places and removing this configuration will face some issues with older behaviors. Therefore, we suggest using the previously provided solution to achieve your requirement.
Thank you for your patience and understanding.
Best regards,
Arul Jenith B.
Hi again,
I've been trying more stuff and I've found out that
on X Axis the precision is ranged up to E-7 not E-11,
and the shown range is defaulted instead and the values are changed to be only within the E-7 intervals?
Is this also something regarding old behaviors?
In the picture attached the time values for X axis are within the E-11 precision.
Thank you again for answering all my questions.
Lukas
Here's additional example to my previous question
Attachment: examples_f7400bfc.zip
Where even when trying to zoom in beyond precision where a line should be seen,
no data is displayed and instead rounded to nearest values that would be zero
Hi Lukáš Krejcí,
We have reviewed your query, and we'd like to inform you that you can customize axis labels according to your preferred roundoff settings using LabelCreated event as mentioned earlier and additionally, we suggest to using the GenerateVisibleLabels override method to customize the axis label based on label positions. This approach enables you to control the label content with custom precision.
Here’s a code example:
public class NumericalAxisExt : NumericalAxis { protected override void GenerateVisibleLabels() { base.GenerateVisibleLabels();
foreach ( var label in VisibleLabels) { label.LabelContent = Math.Round(label.Position, 12).ToString(); } } } |
<chart:SfChart.SecondaryAxis> <local:NumericalAxisExt /> </chart:SfChart.SecondaryAxis> |
We hope this helps. Thank you for your patience and understanding.
Best regards,
Arul Jenith B.