Pre loader

Drawing a filled polygon using a custom renderable series

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

Hello!

I have been looking into creating a custom renderable series for drawing filled polygons.

I have a class that derives from the BaseRenderableSeries type, and uses an XyDataSeries for its dataSeries. So far I’ve been able to draw the shape of the polygon using the drawLines function for the render context API. However, I’m wondering what the best way would be to go about adding support for filling the area of the polygon.

Having read the docs

The IFillPaletteProvider interface allows you to perform per-point
paletting or coloring of series or data-points in Mountain, Column,
Candlestick Charts and JavaScript chart types which have a fill or
body

…I got the impression that I probably want to be implementing a custom palette provider that implements IFillPaletteProvider, which

may be used to override the color of filled polygon in various chart types.

Rather than jumping straight into this, I had a go at overriding the paletteProvider getter with a function that returns an IFillPaletteProvider. In this I create an empty DefaultPaletteProvider, set the fill palette mode to solid, and then set the overrideFillArgb function to essentially always return the ARGB colour code for an arbitrary colour as a test. I also played around with calling (and not calling) shouldUpdatePalette before returning the palette provider:

get paletteProvider(): IFillPaletteProvider {
    const paletteProvider = DefaultPaletteProvider.createEmpty();
    paletteProvider.fillPaletteMode = EFillPaletteMode.SOLID;
    paletteProvider.overrideFillArgb = (xValue:number, yValue: number, _index: number): number => {
        return yValue > 0 ? parseColorToUIntArgb("blue") : parseColorToUIntArgb("black");
    }
    paletteProvider.shouldUpdatePalette();
    return paletteProvider;
}

Now when I call the hasFillPaletteProvider function on my custom renderable series, it indeed returns true.

However, for now my polygon still remains unfilled when drawn onto a surface, I can only see the outline of it. Any advice or tips on where I might be going wrong? I get the feeling I’m missing something obvious/simple, but as yet I can’t figure out what!

Thank you for any help!

Version
scichart 3.3.567, scichart-react 0.1.7
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.