Page 1 of 1
How to change the color of some label
Posted: Thu Jan 16, 2014 8:30 am
by 16566869
Hello,
We know
could be used to change some label text.
but is there a property like
used to change the label text color?
Thanks in advance.
Re: How to change the color of some label
Posted: Fri Jan 17, 2014 9:40 am
by yeray
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;
Re: How to change the color of some label
Posted: Fri Jan 17, 2014 11:00 am
by 16566869
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 = "";
Re: How to change the color of some label
Posted: Fri Jan 17, 2014 11:43 am
by yeray
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));