Gradient in TBarSeries with strange behaviour

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Gradient in TBarSeries with strange behaviour

Post by Whookie » Mon Mar 20, 2017 2:56 pm

Hi,
I'm trying to use TChar + TBarSeries to display a colormap-indicator much like octaves 'colorbar' command does. The following example uses the 'jet' colormap (but I need to use others too):
bar_octave.PNG
Octaves 'colorbar' command using jet colormap
bar_octave.PNG (2.64 KiB) Viewed 7309 times
1.
First thing is, that using GDI no Gradient with more then 3 interpolation points seems to be drawn (seems to be a bug).
I can't use GDI+ (for compatibility issues) so I would need that feature working for GDI.

2.
Regardless of the rendering mode the Gradient seems not to respect the Gradients 'EndColor':
bar.PNG
bar.PNG (30.96 KiB) Viewed 7309 times
As you can see the Top color (see red arrow) and the color on the 'End...' button seems to be some sort of blue but I had set it to dark red in the gradient construction window (see image).
If I set that color again the button shows it for a moment:
buttonok.PNG
buttonok.PNG (4.83 KiB) Viewed 7307 times
but as soon as you move the mouse over that button the color gets blueish again (the BarSeries never changes).
Same behaviour if you use one of the 'Default' colormaps and with any EndColor in GDI-Mode too.

You can paste the following to an empty Form to get the bar (its a simplified colormap). Also after pasting it, you need to go to the series Data Source - page and change the number of samples to 1 (number of samples seems not to get stored in the dfm):

Code: Select all

  object CMapChart: TChart
    Left = 456
    Top = 8
    Width = 105
    Height = 396
    AllowPanning = pmNone
    BackWall.Brush.Gradient.Direction = gdBottomTop
    BackWall.Brush.Gradient.EndColor = clWhite
    BackWall.Brush.Gradient.StartColor = 15395562
    BackWall.Brush.Gradient.Visible = True
    BackWall.Transparent = False
    Foot.Font.Color = clBlue
    Foot.Font.Name = 'Verdana'
    Gradient.Direction = gdBottomTop
    Gradient.EndColor = clWhite
    Gradient.MidColor = 15395562
    Gradient.StartColor = 15395562
    Gradient.Visible = True
    LeftWall.Color = 14745599
    Legend.Font.Name = 'Verdana'
    Legend.Shadow.Transparency = 0
    Legend.Symbol.Gradient.EndColor = 10708548
    Legend.Visible = False
    RightWall.Color = 14745599
    Title.Font.Name = 'Verdana'
    Title.Text.Strings = (
      'TChart')
    Title.Visible = False
    BottomAxis.Axis.Color = 4210752
    BottomAxis.Axis.Visible = False
    BottomAxis.Grid.Color = 11119017
    BottomAxis.LabelsFormat.Font.Name = 'Verdana'
    BottomAxis.TicksInner.Color = 11119017
    BottomAxis.Title.Font.Name = 'Verdana'
    BottomAxis.Visible = False
    DepthAxis.Axis.Color = 4210752
    DepthAxis.Grid.Color = 11119017
    DepthAxis.LabelsFormat.Font.Name = 'Verdana'
    DepthAxis.TicksInner.Color = 11119017
    DepthAxis.Title.Font.Name = 'Verdana'
    DepthTopAxis.Axis.Color = 4210752
    DepthTopAxis.Grid.Color = 11119017
    DepthTopAxis.LabelsFormat.Font.Name = 'Verdana'
    DepthTopAxis.TicksInner.Color = 11119017
    DepthTopAxis.Title.Font.Name = 'Verdana'
    LeftAxis.Axis.Color = 4210752
    LeftAxis.Grid.Color = 11119017
    LeftAxis.LabelsFormat.Font.Name = 'Verdana'
    LeftAxis.TicksInner.Color = 11119017
    LeftAxis.Title.Font.Name = 'Verdana'
    Panning.MouseWheel = pmwNone
    RightAxis.Axis.Color = 4210752
    RightAxis.Grid.Color = 11119017
    RightAxis.LabelsFormat.Font.Name = 'Verdana'
    RightAxis.TicksInner.Color = 11119017
    RightAxis.Title.Font.Name = 'Verdana'
    TopAxis.Axis.Color = 4210752
    TopAxis.Grid.Color = 11119017
    TopAxis.LabelsFormat.Font.Name = 'Verdana'
    TopAxis.TicksInner.Color = 11119017
    TopAxis.Title.Font.Name = 'Verdana'
    View3D = False
    View3DWalls = False
    Zoom.Allow = False
    TabOrder = 5
    DefaultCanvas = 'TGDIPlusCanvas'
    ColorPaletteIndex = 13
    object CMapSeries: TBarSeries
      BarBrush.Gradient.Colors = <
        item
          Color = 7798784
        end
        item
          Color = clAqua
          Offset = 0.266467065868263500
        end
        item
          Color = clYellow
          Offset = 0.511976047904191600
        end
        item
          Color = clRed
          Offset = 0.745508982035928200
        end
        item
          Color = 10708548
          Offset = 1.000000000000000000
        end>
      BarBrush.Gradient.EndColor = 10708548
      BarBrush.Gradient.MidColor = clAqua
      BarBrush.Gradient.StartColor = 7798784
      BarBrush.Gradient.Visible = True
      Marks.Visible = False
      BarWidthPercent = 100
      Gradient.Colors = <
        item
          Color = 7798784
        end
        item
          Color = clAqua
          Offset = 0.266467065868263500
        end
        item
          Color = clYellow
          Offset = 0.511976047904191600
        end
        item
          Color = clRed
          Offset = 0.745508982035928200
        end
        item
          Color = 10708548
          Offset = 1.000000000000000000
        end>
      Gradient.EndColor = 10708548
      Gradient.MidColor = clAqua
      Gradient.StartColor = 7798784
      Gradient.Visible = True
      GradientRelative = True
      SideMargins = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Bar'
      YValues.Order = loNone
    end
  end

Yeray
Site Admin
Site Admin
Posts: 9534
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Gradient in TBarSeries with strange behaviour

Post by Yeray » Tue Mar 21, 2017 9:47 am

Hello,
Whookie wrote:1.
First thing is, that using GDI no Gradient with more then 3 interpolation points seems to be drawn (seems to be a bug).
I can't use GDI+ (for compatibility issues) so I would need that feature working for GDI.
ç
I'm afraid we don't have plans to continue improving GDI, and we recommend moving to GDIPlus.
Can't these "compatibility issues" be circumvented?
Whookie wrote:2.
Regardless of the rendering mode the Gradient seems not to respect the Gradients 'EndColor':
With a couple of modifications, this seems to work fine:

Code: Select all

    object Series1: TBarSeries
      BarBrush.Gradient.Colors = <
        item
          Color = 125239296
        end
        item
          Color = clAqua
          Offset = 0.266467065868263500
        end
        item
          Color = clYellow
          Offset = 0.511976047904191600
        end
        item
          Color = clRed
          Offset = 0.745508982035928200
        end
        item
          Color = 4849712
          Offset = 1.000000000000000000
        end>
      BarBrush.Gradient.EndColor = 4849712
      BarBrush.Gradient.MidColor = clAqua
      BarBrush.Gradient.StartColor = 125239296
      BarBrush.Gradient.Visible = True
      Marks.Visible = False
      SeriesColor = 268435584
      BarWidthPercent = 100
      Gradient.Colors = <
        item
          Color = 125239296
        end
        item
          Color = clAqua
          Offset = 0.266467065868263500
        end
        item
          Color = clYellow
          Offset = 0.511976047904191600
        end
        item
          Color = clRed
          Offset = 0.745508982035928200
        end
        item
          Color = 4849712
          Offset = 1.000000000000000000
        end>
      Gradient.EndColor = 4849712
      Gradient.MidColor = clAqua
      Gradient.StartColor = 125239296
      Gradient.Visible = True
      GradientRelative = True
      SideMargins = False
      XValues.Name = 'X'
      XValues.Order = loAscending
      YValues.Name = 'Bar'
      YValues.Order = loNone
    end
Project2_2017-03-21_10-47-04.png
Project2_2017-03-21_10-47-04.png (47.67 KiB) Viewed 7301 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Gradient in TBarSeries with strange behaviour

Post by Whookie » Wed Mar 22, 2017 1:08 pm

Hi Yeray,
Thats an application running on some really old Windows XP embedded Panel-PCs which are untouchable by me. As you might know embbeded Windows does not have all the sub-systems because its tailored to fit on tiny harddisks. There also seems to be missing more than the gdiplus.dll (I tried to supply it with a test-application and it constantly crashed).

For now I have a ColorStrip component of my own and I just place it above the bar area (to get the scale - I need - from the TChart).

Regarding youe fix:
What you are suggesting is a workaround for that single colormap. Try opening your solution and change the last color from dark red to lets say yellow and the bug is there again.

As far as I can see this is because you always overwrite the last color of a gradient with the series color. What you could do is check the gradient visible flag and leave the gradient untouched if set (or - maybe not that good - change the series color to the last color of the current gradient).

Best Regards
Whookie

Yeray
Site Admin
Site Admin
Posts: 9534
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Gradient in TBarSeries with strange behaviour

Post by Yeray » Fri Mar 24, 2017 10:24 am

Hello Whookie,

I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1823
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply