Pre loader

Tag: FastErrorBarsRenderableSeries

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 vote
0 answers
5k views

(Edited to add code blocks)
I am trying to draw 4 series simultaneously on a chart. I have 2 Scatter plot series, a FastLineRenderableSeries (Which I’ll call the trendline) and I have a FastErrorBarsRenderableSeries which I’ll call the uncertainty. The scatter plots always draw.

When I draw the scatter plots and the trendline, everything looks right. As soon as I add any points to the HlcDataSeries in the uncertainty, though, the trendline disappears, and the error bars won’t draw. It’s very strange.
Below is my xaml and code (edited for clarity).


   void SetData(int channels, MyDataSet incomingData){
        var n = incomingData.Count;
        var unc = new List<Point>(n); //Point has x y coords and uncertainty
        double[] xValues = new double[n], yValues = new double[n];
        for (int i = 0; i < n; i++)
        {
            var x = incomingData[i].X.Value; //Incoming data has x y coords 
                                                                  //with uncertainties in each direction
            var y = incomingData[i].Y.Value;
            xValues[i] = x;
            yValues[i] = y;
            var yVal = incomingData[i].Y;
            if (yVal is not { Uncertainty: not null and not 0 }) continue;
            unc.Add(incomingData[i]);
        }
        if (xValues.Any())
            PointData = new XyDataSeries<double>(xValues, yValues);
        var xList = new double[channels];
        var yList = new double[channels];
    if (incomingData.CalibrationCoefficients == null)
    {
            incomingData.Fit(); //Generate coefficients
    }
    for (var i = 0; i < channels; i++)
    {
          xList[i] = i;
          yList[i] = incomingData.GetY(i); //Apply Coefficients
     }
    LineData = new XyDataSeries<double>(xList, yList);
    unc.Add(new Point(1, 0, 100, 50)); //x, x uncertainty, y, y uncertainty
    unc.Add(new Point(10, 0, 100, 50));//Adding bogus data to ensure uncertainty
    unc.Add(new Point(100, 0, 1000, 50));
    unc.Add(new Point(1000, 0, 500, 50));
    unc.Add(new Point(5000, 0, 250, 50));
    if (unc.Any())
    {
        UncertaintyData = new HlcDataSeries<double, double>();
        var hlc = (HlcDataSeries<double, double>)UncertaintyData;
        foreach (var t in unc)
        {
            var uncertainty = Math.Abs(t.Y.Uncertainty);
            var y = t.Y.Value;
            hlc.Append(t.X.Value, y,
                y- uncertainty,
                y+ uncertainty);
        }
    }

}

And my Xaml:


 <s:SciChartSurface MinWidth="200" MinHeight="200" 
                                   Name="ChartSurface" Padding="0"  
                                   Style="{Binding CurrentChartStyle}" >
            <s:SciChartSurface.RenderableSeries>
 <!-- Scatter plots omitted for brevity -->
                <s:FastErrorBarsRenderableSeries DataSeries="{Binding UncertaintyData}" 
                                                 ErrorDirection="YAxis"
                                                 Stroke="Blue"
                                                 StrokeThickness="2"
                                                 LastErrorBarWidth="7"
                                                 DataPointWidthMode="Absolute"
                                                 /> 

                <s:FastLineRenderableSeries x:Name="LineSeries" AntiAliasing="True" Stroke="Gray"
 DataSeries="{Binding LineData}" StrokeThickness="2"/>
            </s:SciChartSurface.RenderableSeries>
 <!-- Axes omitted for brevity --> 
        </s:SciChartSurface>
0 votes
4k views

Hi!

I would like to plot a series as a solid line AND include error bars. The way I do this now is to define a single series:

var fSeries    = new HlcDataSeries<double, double>();
fSeries.SeriesName = $"My Series!";

And then two different ViewModels:

var fLineVm = new LineRenderableSeriesViewModel();
var fErrorVm = new ErrorBarsRenderableSeriesViewModel();

And set the data series to belong to both:

fLineVm.DataSeries = fSeries;
fErrorVm.DataSeries = fSeries;

This looks ok. But when I show the legend, I see “My Series” in the legend twice, and I can control the error bars separately from the line series.

What I want to happen is that I see the series a single time in the legend and if I turn it off (uncheck it) everything disappears.

Right now, i’m adding those two ViewModels to an ObservableCollection of IRenderableSeriesViewModels and then SeriesBinding to display them.

0 votes
10k views

Hi,

I’m using the error bars series, and I get some strange behavior when zooming in/out using the RubberBandXyZoomModifier.
Sometimes the vertical line is not drawn, and sometimes the top & bottom horizontal lines are not drawn / drawn too wide.

This issue doesn’t occur when zoom with the MouseWheelZoomModifier.
However, with the MouseWheelZoomModifier in the current implementation the top & bottom horizontal line width depend on the zoom level (the zoom level affects the horizontal lines), where in my opinion it should not. For example, when zooming in, the horizontal lines may cover the whole view width, and when zooming out to a certain level you cannot see them since they are too short.

I attached a few screenshots of the same data in different zoom/pan, when using the RubberBandXyZoomModifier (the MouseWheelZoomModifier issue can be easily reproduced with simple data).
Screenshot ‘error_bars_display1’: horizontal lines are too wide.
Screenshot ‘error_bars_display2’: vertical & horizontal lines are not drawn at all (left line. Only the scatter series cross marker can be seen).
Screenshot ‘error_bars_display3’: vertical line is drawn, but horizontal lines are not (left line. This is one mouse wheel rotation-click away from screenshot #2).
It seems like an issue with the line size calculations (?).

Note: the ‘closing’ value of the HlcSeries is drawn using a Scatter series with a cross marker, so you can ignore it in the attached screenshots.

Thanks.

  • Yonatan D asked 8 years ago
  • last active 8 years ago
Showing 3 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies