High-Low Series, Trasparency, add three arrays of data

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
skng
Newbie
Newbie
Posts: 7
Joined: Thu Aug 07, 2014 12:00 am

High-Low Series, Trasparency, add three arrays of data

Post by skng » Tue Sep 23, 2014 2:48 pm

Hi,

I have three arrays of data to show on the chart.

on x-axis : XArray[10000] with the date-time information
on y-axis : YHighArray[10000] and YLowArray[10000] data information with respect to the date-time in XArray[10000].

Could you please tell me how to add the above three arrays data to THighLowSeries, which is added during the run time ?

How to make Lines (between the High Pen and Low Pen) invisible programmatically ?

I tried to use the transparency option, but it is only working for the Series style lines between the high and low pen, not for the high-low pen colour(i.e it is only working for the brush not for the pen colour). I have to make whole series transparency (including pen colour). Could you please tell me, how to make this programmatically ?

thanks in advance,

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

Re: High-Low Series, Trasparency, add three arrays of data

Post by Yeray » Wed Sep 24, 2014 9:15 am

Hello,
skng wrote:Could you please tell me how to add the above three arrays data to THighLowSeries, which is added during the run time ?
You should loop the arrays and use the AddHighLow method. Ie:

Code: Select all

for i:=Low(XArray) to High(XArray) do (Chart1[0] as THighLowSeries).AddHighLow(XArray[i], YHighArray[i], YLowArray[i]);
skng wrote:How to make Lines (between the High Pen and Low Pen) invisible programmatically ?
Use the Pen.Visible property of the series:

Code: Select all

(Chart1[0] as THighLowSeries).Pen.Visible:=false;
skng wrote:I tried to use the transparency option, but it is only working for the Series style lines between the high and low pen, not for the high-low pen colour(i.e it is only working for the brush not for the pen colour). I have to make whole series transparency (including pen colour). Could you please tell me, how to make this programmatically ?
You should use TTeeCanvas.ColorFrom. Ie:

Code: Select all

//High/Low Transparencies (between 0 and 255)
(Chart1[0] as THighLowSeries).HighPen.Color:=TTeeCanvas.ColorFrom((Chart1[0] as THighLowSeries).HighPen.Color,150);
(Chart1[0] as THighLowSeries).LowPen.Color:=TTeeCanvas.ColorFrom((Chart1[0] as THighLowSeries).LowPen.Color,150);
Here you have the full example I have played with:

Code: Select all

uses ErrorBar, TeCanvas, DateUtils;

var XArray, YHighArray, YLowArray: array of double;
const mySize=10000;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  SetLength(XArray, mySize);
  SetLength(YHighArray, mySize);
  SetLength(YLowArray, mySize);

  XArray[0]:=Today;
  YHighArray[0]:=50+random*100;
  YLowArray[0]:=50+random*100;
  for i:=1 to mySize-1 do
  begin
    XArray[i]:=IncDay(XArray[i-1]);
    YHighArray[i]:=YHighArray[i-1]+random*10-5;
    YLowArray[i]:=YLowArray[i-1]+random*10-5;
  end;

  with Chart1.AddSeries(THighLowSeries) as THighLowSeries do
  begin
    //FillSampleValues();
    BeginUpdate;
    try
      for i:=Low(XArray) to High(XArray) do AddHighLow(XArray[i], YHighArray[i], YLowArray[i]);
    finally
      EndUpdate;
    end;

    Pen.Visible:=false;

    //High/Low Transparencies (between 0 and 255)
    HighPen.Color:=TTeeCanvas.ColorFrom(HighPen.Color,150);
    LowPen.Color:=TTeeCanvas.ColorFrom(LowPen.Color,150);
  end;
end;
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