How to change the color of some label

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

How to change the color of some label

Post by elmec » Thu Jan 16, 2014 8:30 am

Hello,

We know

Code: Select all

Series->XLabel[i] = "Test"
could be used to change some label text.
but is there a property like

Code: Select all

Series->XLabel->Color[i]
used to change the label text color?

Thanks in advance.

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

Re: How to change the color of some label

Post by Yeray » Fri Jan 17, 2014 9:40 am

Hi,

I'm not sure if you want to change the Mark color or the Axis label color.
Here it is an example changing both a series Mark color and an Axis label font color:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1.AddSeries(TBarSeries) as TBarSeries do
  begin
    ColorEachPoint:=true;
    FillSampleValues(5);
    Labels[0]:='Apples';
    Labels[1]:='Bananas';
    Labels[2]:='Lemons';
    Labels[3]:='Oranges';
    Labels[4]:='Pears';

    Marks.Item[1].Color:=clRed;
  end;

  Chart1.Draw;
  Chart1.Axes.Bottom.Items.Automatic:=false;
  Chart1.Axes.Bottom.Items[3].Format.Font.Color:=RGB(255,128,0);
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

elmec
Advanced
Posts: 129
Joined: Mon Aug 26, 2013 12:00 am

Re: How to change the color of some label

Post by elmec » Fri Jan 17, 2014 11:00 am

Thank you!
Another question, How to access points by x value, not by valueindex?

Code: Select all

Series1->Marks->Visible = true;

	// Add 5 points to Series
	int xpoints[5] = {10, 20, 30, 40, 50};
	int y = 100;

	for (int i = 0; i < 5; i++)
	{
		Series1->AddXY(xpoints[i], y, IntToStr(i + 1));
	}


	// How to access some point by x value, not the valueindex.
	//
	//Just like	Series1->MarksXValue->Item[10]->Text->Text = "";
	// which works same with the code below.
	Series1->Marks->Item[0]->Text->Text = "";

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

Re: How to change the color of some label

Post by Yeray » Fri Jan 17, 2014 11:43 am

Hello,

Difficult to say because you can have several points in a same XValue.
To find the first point with a given XValue, you can loop into the series looking for it. Something like this:

Code: Select all

XValueToFind:=10;
valueIndex:=-1;
found:=false;
repeat
  Inc(valueIndex);
  if (valueIndex<Series1.Count) and (Series1.XValues[valueIndex]=XValueToFind) then
    found:=true;
until (found=true) or (valueIndex=Pred(Count));
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