Topic: How can I change the colour of a line in a TChart

Hello, How can I change the colour of a line in a TChart

ex.

begin
    ChartLine.Series[0].Clear;
    ChartLine.Series[1].Clear;
    ChartLine.Series[2].Clear;
    ChartLine.Series[0].Title := 'Systolic';
    ChartLine.Series[1].Title := 'Diastolic';
    ChartLine.Series[2].Title := 'HB/Min';
   // ChartLine.Series[0].Color := clBlue;  Give a undeclared identifier error
  //  ChartLine.Series[1].Color := clRed;
   // ChartLine.Series[2].Color := clGreen;

Thanks in advance, Carlo

Re: How can I change the colour of a line in a TChart

Not tested, but  see if this works.

ChartLine.Series[0].linepen.color := clBlue;
On a clear disk you can seek forever

Re: How can I change the colour of a line in a TChart

Hi CDB,
Thank you.
Sorry, Linepen = result is the same error.  undeclared identifier.
Linepen settings In fast report no problem.

4 (edited by sparrow 2023-04-26 11:49:40)

Re: How can I change the colour of a line in a TChart

That's right

TLineSeries(ChartLine.Series[0]).LinePen.Color := clRed

But maybe you will only get a change in the color of the lines in the plot legend.


Your example would be better.
If you are passing data from a SQL query or manually forming it, you use ADD or ADDXY
Here is a piece of my code

Chart.Series[0].AddXY(DateValue, StrToFloat(ProfitValue),'',clRed);

OR

Chart.Series[0].Add( 1234, 'New', clRed );


function AddXY(Const AXValue, AYValue: TChartValue; Const ALabel: String; AColor: TColor)
function Add(Const AValue: TChartValue; Const ALabel: String; AColor: TColor):

Re: How can I change the colour of a line in a TChart

Thank you Sparrow and CDB,
Chart.Series[0].AddXY(DateValue, StrToFloat(ProfitValue),'',clRed);  is ok.
chart line color function is fantastic.
Greeting, Carlo