3 variable surface chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Matias Nabarro
Newbie
Newbie
Posts: 9
Joined: Mon Apr 07, 2014 12:00 am

3 variable surface chart

Post by Matias Nabarro » Fri Apr 11, 2014 3:09 pm

Hello. I need some help. I'll explain what I'm trying to achieve, hoping somebody could give me a guideline of where to start.

I need a 3 variable graphic, let's call the variables X, Y and Z. X horizontal axis, Y in vertical axis and Z showing color from a pre definied scale.
Let's say blue for 0.0 and red for 10.0 of Z value. I need to be able to define color for extremes of color scale. Is this possible ?.

Thanks in advance, best regards.

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

Re: 3 variable surface chart

Post by Yeray » Mon Apr 14, 2014 2:53 pm

Hi Matias,

I'm afraid this series type doesn't exist. However, you can always inherit from TPointSeries (or whatever series you like), add a TValueList to it (your Z for the colors), a StartColor and an EndColor (or just an EndColor and use the already present Series' Color as StartColor) and recalculate the color for each point overriding GetValueColor function. Here it is how you could start:

Code: Select all

uses Series;

type RangePoint=class(TPointSeries)
  private
    ZValues: TChartValueList;
    EndColor: TColor;
  protected
    function GetValueColor(ValueIndex:Integer):TColor; override;
end;

function RangePoint.GetValueColor(ValueIndex:Integer):TColor;
begin
  result:=inherited GetValueColor(ValueIndex);
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  with Chart1.AddSeries(RangePoint) as RangePoint do
  begin
    EndColor:=clRed;
    ZValues:=TChartValueList.Create(Chart1[0], 'Z Values');

    for i:=0 to 9 do
    begin
      ZValues.TempValue:=i;
      Add(i);
    end;
  end;
end;
Also note there is the TColorGrid series that also fits with the description you've made. I'd suggest you to take a look at the examples in the features demo and tell us if you don't find what you are looking for.
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