Pre loader

No line drawn when all values for the series are the same, very near 0, float value

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

We have been testing different limits of data types we are aiming to draw to the chart, and have found that if all of the values in a series are the same, very near 0, float value, then the line isn’t drawn. We do, however, get the value showing up on the vertical line annotation.

Though we are not using the latest version of SciChart in our production app (Net 4.6.1 requirement, but upgrading that soon), I have managed to reproduce the same in a very simplified .Net7 app using the latest version (7.0.2.27161). I have attached both the test app (with my runtime key removed) and a screenshot of the app.

Here is the code we are using to generate the sample series in the code behind of MainWindow.xaml:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += OnLoaded;
    }

    private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
    {
        var floatData = new XyDataSeries<double, float>();

        for (var i = 0; i < 1000; i++)
        {
            floatData.Append(i, float.Parse(Math.Pow(2, -126).ToString("E")));
        }

        this.FloatSeries.DataSeries = floatData;
    }
}

MainWindow.xaml contains just a SciChart Surface, as follows:

<s:SciChartSurface x:Name="Surface">
            <s:SciChartSurface.RenderableSeries>
                <s:FastLineRenderableSeries x:Name="FloatSeries" 
                                            Stroke="#FF4083B7"/>
            </s:SciChartSurface.RenderableSeries>

            <s:SciChartSurface.XAxis>
                <s:NumericAxis AutoRange="Always"/>
            </s:SciChartSurface.XAxis>

            <s:SciChartSurface.YAxis>
                <s:NumericAxis AutoRange="Always"/>
            </s:SciChartSurface.YAxis>

            <s:SciChartSurface.ChartModifier>
                <s:ModifierGroup>
                    <s:RubberBandXyZoomModifier />
                    <s:ZoomExtentsModifier />

                    <s:VerticalSliceModifier>
                        <s:VerticalSliceModifier.VerticalLines>
                            <s:VerticalLineAnnotation X1="500" 
                                                      IsEditable="True"
                                                      LabelTextFormatting="E"
                                                      Stroke="White" />
                        </s:VerticalSliceModifier.VerticalLines>
                    </s:VerticalSliceModifier>
                </s:ModifierGroup>
            </s:SciChartSurface.ChartModifier>

            <s:SciChartSurface.Annotations>
                <s:TextAnnotation Text="Test app highlighting problem when all x values are floats with the same scientific value"
                                  CoordinateMode="Relative"
                                  X1="0" 
                                  Y1="0"
                                  Margin="2"/>
            </s:SciChartSurface.Annotations>
        </s:SciChartSurface>

Adding another value to the series with result in the line being drawn, as long as it is sufficiently different to the others.

What would be the best way to get this data showing to the users? Whilst highly unlikely the user is going to use such values, we cannot discount this. Would extending the ViewportManager to provide our own range be the best approach? If it impacts on the suggestions, due to our implementation requirements our production app will only show up to two series per surface (with the same data type), but we could be showing upwards of 256 charts (with one of 12 data types as their y-axis type). All of our charts are linked to a common TimeSpanAxis for the x axis.

Version
7.0.2.27161
Attachments
Images
  • You must to post comments
0
0

Hi Carl,

When a series has all the same values e.g. 0, 0, 0, 0, 0, 0, … then our AutoRange algorithm doesn’t really know what to do. What should the range be? -1 to +1? -10 to +10? In this case SciChart calculates a range equal to Y+1 and Y-1 and that should ‘just work’ out of the box.

In this case though you’re not sending repeated zero values to the chart, you’re appending something close to the minimum float precision (1.175494E-38) to every value. This is your MainWindow.OnLoaded code:

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
    var floatData = new XyDataSeries<double, float>();
    for (var i = 0; i < 1000; i++)
    {
        floatData.Append(i, float.Parse(Math.Pow(2, -126).ToString("E"))); // Resolves to Y=1.175494E-38
    }
    this.FloatSeries.DataSeries = floatData;
}

Substituting for floatData.Append(i, 0.0f) and the chart renders correctly.

Also, substituting the DataSeries for new XyDataSeries<double, double>() and the line renders but Y-Axis is not displaying.

So I think this is actually a precision issue. Once you we try to calculate an Axis.VisibleRange so small, it no longer appears (the limit is around Axis.VisibleRange.Max – Min = ~1E-15).

I’ll talk with the team about a possible solution. May involve constraining or coercing VisibleRange to something sensible.

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.