Page 1 of 1

3 variable surface chart

Posted: Fri Apr 11, 2014 3:09 pm
by 16468913
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.

Re: 3 variable surface chart

Posted: Mon Apr 14, 2014 2:53 pm
by yeray
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.