How to display red numbers on the X-axis
Posted: Tue Jun 27, 2023 9:14 am
[img]C://Users//lyl//Desktop//222.png[/img]
How to display red numbers on the X-axis???
How to display red numbers on the X-axis???
Steema Software - Customer Support Forums
http://teechart.com/support/
LabelsFont.Color
:Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.Color:=clWhite;
Chart1.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Chart1.View3D:=False;
Chart1.Legend.Hide;
Chart1.AddSeries(TFastLineSeries).FillSampleValues(10);
Chart1.Axes.Bottom.Title.Text:='Time (sec)';
Chart1.Axes.Bottom.LabelsFont.Color:=clRed;
end;
OnDrawLabel
event to change the Bottom axis LabelsFont.Color
accordingly:Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.Color:=clWhite;
Chart1.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Chart1.View3D:=False;
Chart1.Legend.Hide;
Chart1.AddSeries(TFastLineSeries).FillSampleValues(11);
Chart1.Axes.Bottom.Title.Text:='Time (sec)';
Chart1.Axes.Bottom.OnDrawLabel:=BottomAxisDrawLabel
end;
procedure TForm1.BottomAxisDrawLabel(Sender:TChartAxis; var X,Y,Z:Integer; var Text:String; var DrawLabel:Boolean);
begin
if (Text<>'0') and (Text<>'10') then
Sender.LabelsFont.Color:=clRed
else
Sender.LabelsFont.Color:=clBlack;
end;
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.Align:=alClient;
Chart1.Color:=clWhite;
Chart1.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Chart1.View3D:=False;
Chart1.Legend.Hide;
Chart1.AddSeries(TFastLineSeries).FillSampleValues(11);
Chart1.Axes.Bottom.Title.Text:='Time (sec)';
Chart1.Draw;
with Chart1.Axes.Bottom do
begin
Items.Automatic:=False;
for i:=0 to Items.Count-1 do
if (Items[i].Text<>'0') and (Items[i].Text<>'10') then
Items[i].Format.Font.Color:=clRed;
end;
end;
Increment
is set to 0
which automatically tries to fit as many labels as possible.Code: Select all
Chart1.Axes.Bottom.Increment:=0;
1
:
Code: Select all
Chart1.Axes.Bottom.Increment:=1;
If you want labels at 0, 1, 2,..., and you want to force it so labels 0.5, 1, 1.5,... don't appear when zooming, you can set
Increment:=1
.You can press the "Add files" button in the "Attachments" tab to open the file explorer. I've edited the explanation here to mention it.wrote: ↑Fri Jun 30, 2023 3:21 amI suggest that you modify the insert image function to pop up a dialog box for users to select an image. This is a formal practice for many software applications.
Increment
of 0.5
, or to the minimum increment you want to support in your app.