SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

Hello,

I’m trying to get a scatter series chart to work but it doesn’t render. For Bar, Impulse, and Line I can use the same code only switching the series type, but when I attempt to do the same with Scatter series (both XyScatter and ExtremeScatter) the points don’t render.

Here is my scatter series code:

// ... 
        for (int i = 0; i < dimensions; i++)
        {
            var scatterSeries = new ExtremeScatterRenderableSeries()
            {
                PointMarker = new EllipsePointMarker() { Width = 7, Height = 7}
            };

            scatterSeries.PaletteProvider = new ExtremeScatterPaletteProvider(colors);

            Binding DataSeriesBinding = new Binding("Data");
            DataSeriesBinding.Source = (_cvm as ChartViewModelXY).ndData.ElementAt(i);
            scatterSeries.SetBinding(BaseRenderableSeries.DataSeriesProperty, DataSeriesBinding);

            Chart.RenderableSeries.Add(scatterSeries);

            permanentLineSeries++;
        }
// ...
public class ExtremeScatterPaletteProvider : IExtremePointMarkerPaletteProvider
{
    private readonly List<Color> _dataPointColors;
    private readonly Values<Color> _colors = new Values<Color>();
    public ExtremeScatterPaletteProvider(List<Color> dataPointColors)
    {
        _dataPointColors = dataPointColors;
    }
    // Fill Colors for each data-point index
    public Values<Color> Colors { get { return _colors; } }
    public void OnBeginSeriesDraw(IRenderableSeries rSeries)
    {
        var indexes = rSeries.CurrentRenderPassData.PointSeries.Indexes;
        var count = indexes.Count;
        _colors.Count = count;
        // copy required colors from list using data point indices
        for (int i = 0; i < count; i++)
        {
            var dataPointIndex = indexes[i];
            _colors[i] = _dataPointColors[dataPointIndex];
        }
    }
}

The same code works with 3 other XY charts, so I’m fairly certain the issue is with how I am creating the ExtremeScatter. Any help or insight would be greatly appreciated!

Edit: For anyone curious / googling a fully instantiated XyScatterRenderableSeries in code looks like this:

   // Render a scatter series
    var scatterSeries = new XyScatterRenderableSeries()
     {
            PointMarker = new EllipsePointMarker() { Width = 7, Height = 7, Stroke = colors[i], Fill = colors[i]}
     };  

That will render the series with the same color for both the border and interior.

Version
5
  • You must to post comments
1
0

ExtremeScatterRenderableSeries is a feature available in the SDK Professional, SDK Enterprise and SciChart WPF 2D Enterprise editions only.

We have another scatter series though called the XyScatterRenderableSeries which will work with your edition (SciChart WPF 2D Professional)

Best regards,
Andrew

  • Joe
    Hi Andrew, I tried the XyScatter series but it didn’t work either. It was the same code except for the palette provider class.
  • Andrew
    Work backwards. Try our tutorial: https://www.scichart.com/documentation/v5.x/Tutorial%2003%20-%20Adding%20Series%20to%20a%20Chart.html. This works. Also our palette provider example works. What have you done differently ?
  • Joe
    That’s what I’m trying to figure out. As far as I can tell, it’s the same code as the tutorial. I use one design pattern to create all of my 2D charts. If I replace XyScatter with any other 2D series (Impulse, Line, Bar, etc.) they all work using this same structure. I’m not sure why scatter is the only one that doesn’t work, so my main question was whether there is some other difference between them that would prevent it from rendering.
  • Andrew
    Isolate things one by one, for example, the binding you added in code. If you just set the dataseries property does it work? Next isolate by removing the palette provider. If all else fails you can turn on the debug logger to get more info: https://www.scichart.com/documentation/v5.x/SciChart_2D_Troubleshooting.html
  • Joe
    Hey Andrew, I was able to get it working. There were a couple problems. The first is I didn’t account for the fact that this series type is slightly slower than the others (which I’m sure is fixed in ExtremeScatter) so my oscilloscope view of the data left what was rendered just off-screen. The second was the way I’d instantiated Point Markers. Thank you, Andrew, I appreciate the guidance and for bringing the debug option to my attention!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.