Problem colouring axis bar

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
jorge
Posts: 20
Joined: Tue Jun 28, 2016 7:54 am

Problem colouring axis bar

Post by jorge » Tue Jun 28, 2016 2:21 pm

Following the "Line, palette coloring" example, I am trying to set different color to the Y axis bar. I need solid colors instead of gradients, and I want to apply it only to the axis bar, not to the series line.

What I am trying to achieve is to colour the Y axis in red color from -inf to 0, and green color from 0 to +inf.
I have done this so far, using a dummy series to set the color ranges, and assign it to the axis. Maybe there is a way of assigning a palette to the bar directly?

Code: Select all

            PointLineSeries colorSeries = new PointLineSeries();
            ValueRangePalette palette = new ValueRangePalette(colorSeries);
            palette.Type = PaletteType.Uniform;
            palette.MinValue = 1;
            palette.Steps.Add(new PaletteStep(palette, Color.Red, 0));
            palette.Steps.Add(new PaletteStep(palette, Color.Green, 10000));
            colorSeries.UsePalette = true;
            AxisY.PaletteSeries = colorSeries;
One problem I found is that, from -inf to 0 it is set to Red, but for 0 and higher values it is not set to green, but white. Also there is some strange gradient effect around 0, showing some blue gradient color if I zoom that area.

Could someone please advise on this?

Thanks.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Problem colouring axis bar

Post by ArctionPasi » Tue Jun 28, 2016 2:50 pm

A series has to be used, as you figured out already.

You can create the palette like this:

Code: Select all

private ValueRangePalette CreatePalette(PointLineSeriesBase ownerSeries)
        {
          
            ValueRangePalette palette = new ValueRangePalette(ownerSeries);

            palette.Steps.Clear();

            palette.Steps.Add(new PaletteStep(palette, Color.Red, 0));
            palette.Steps.Add(new PaletteStep(palette, Color.Lime, 1000));
            
            
            palette.Type = PaletteType.Uniform;

            return palette;
        }
It seems palette.Steps.Clear() was missing in your code, and it already has 4 steps created in the palette by constructor.
LightningChart Support Team, PT

jorge
Posts: 20
Joined: Tue Jun 28, 2016 7:54 am

Re: Problem colouring axis bar

Post by jorge » Tue Jun 28, 2016 3:41 pm

It worked, thanks.

Post Reply