Strings instead of values on an axis?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jan
Newbie
Newbie
Posts: 24
Joined: Fri Nov 15, 2002 12:00 am
Location: Germany

Strings instead of values on an axis?

Post by Jan » Thu Apr 01, 2004 12:35 pm

Hello!

1.) I have another question, that is (maybe) easy to answer: when generating a Boxplot-series at position x is there a possibility to name the corrosponding point on th bottom axis? I would like to have the string that can be found in 'name' (source below) on the bottom axis instead of 0, 1, 2, 3.....).
2.) the same with a tower-series.is there a possibility to write names on the bottom and depth axis instead of values (second code below) ?

if frmDataMining.DescriptiveColRadio.Checked then
begin
Chart1.Title.Text.Clear;
Chart1.Title.Text.Add('Boxplots / columns');
Chart1.View3D := False;
Chart1.ApplyZOrder := False;

for RunnerX := ErsteSpalte to LetzteSpalte do
begin
ValueNo := ValuesInColumn(frmMiningResults.ResultStringGrid, RunnerX, ErsteZeile, LetzteZeile);// check if there is more than text or empty fields

If ValueNo > 0 THen
Begin
Name := frmMiningResults.ResultStringGrid.Cells[RunnerX, 0]; // get the name from the table header
Chart1.AddSeries(TBoxSeries.Create(Self));
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).AreaColor := clRed;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Title := Name;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Position := RunnerX - ErsteSpalte;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Box.Color := clBlue;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).AreaLinesPen.Visible := True;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).VertAxis := aLeftAxis;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).HorizAxis := aBottomAxis;

Repeater := 0;
SetLength (SortierteListe, ValueNo);

for RunnerY := ErsteZeile to LetzteZeile do // get all the values from the column
begin
DummyString := frmMiningResults.ResultStringGrid.Cells[RunnerX, RunnerY];

If TryStrToFloat (DummyString, DummyExtended) THen
Begin
SortierteListe [Repeater] := DummyExtended;
Inc (Repeater);
end;
end;

Quicksort (SortierteListe, 0, High (SortierteLIste)); // and sort them for the box plot

for RunnerY := 0 to High(SortierteListe) do
begin
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Add (SortierteListe[RunnerY], name, clRed);
end;
end;
end;
end;

----------------------------------------
if frmDataMining.PercentGridRadio.Checked then
begin
Chart1.Title.Text.Clear;
Chart1.Title.Text.Add('Percent / grid');
Chart1.AddSeries(TTowerSeries.Create(Self));
(Chart1[0] as TTowerSeries).Clear;
(Chart1[0] as TTowerSeries).Title := 'Proportions in the grid';

(Chart1[0] as TTowerSeries).UseColorRange := True;

for RunnerY := LetzteZeile downto ErsteZeile do
begin
for RunnerX := ErsteSpalte to LetzteSpalte do
begin
DummyString := frmMiningResults.ResultStringGrid.Cells[RunnerX, RunnerY];
if TryStrToFloat(Copy(DummyString, 1, Length(DummyString) - 1), DummyExtended) then
begin
(Chart1[0] as TTowerSeries).AddXYZ(RunnerX - ErsteSpalte, DummyExtended, RunnerY-LetzteZeile);
end
else
begin
(Chart1[0] as TTowerSeries).Addxyz(RunnerX - ErsteSpalte, 0, RunnerY-LetzteZeile);
end;
end;
end;
end;

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Apr 01, 2004 2:40 pm

Hi Jan,

1) Have you tried to set the Bottom axis labels to "text"? :

Chart1.Axes.Bottom.LabelStyle := talText;

2) You can access individual depth axis labels and customize them via the OnGetAxisLabel and OnGetNextAxisLabel events:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues(6);
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if Sender.IsDepthAxis then LabelText := 'Depth';
end;

Jan
Newbie
Newbie
Posts: 24
Joined: Fri Nov 15, 2002 12:00 am
Location: Germany

Post by Jan » Fri Apr 02, 2004 10:23 am

Thanks,

but i am searching for a solution like chart1[x].xlabel[position] := 'text''.
The problem is that there are many procedures who try to draw on one chart. Sometimes at different times and sometimes some are excluded from drawing, while others are not.

Now i would like to have solution being as easy as possible to include it within the same procedure. When drawing the boxplots i place them with the position command (otherwise they would be drawn all on the same position). All are using the bottom and the left axis. Now i search for something to say: Instead of value 1 on the bottomaxis i would like to have the string 'Boxplot 2'.

For one series (like a ttowerseries) it is no problem and the (xlabel[position] := 'xyz') works correctly. But when generating several of boxplotseries i can't manage it. I am not really sure if it is a problem of the code. Maybe i havent seen a property that should be set to a special value. When generating a simple project it works! The code below just draws the strings for the smaller range between (ErsteZeile to LetzteZeile) and (ErsteSpalte to LetzteSpalte).....

And finally: is there another chance to get access for the depthaxis?

Thanks

Jan
----------------------------------------------------
This is working:

procedure TForm1.BitBtn1Click(Sender: TObject);
Var FirstColumn : Integer;
LastColumn : Integer;
RunnerY : Integer;
RunnerX : Integer;
RandomValue : Double;
begin
Chart1.RemoveAllSeries;
Chart1.View3D := False;
Chart1.ApplyZOrder := False;
Chart1.BottomAxis.LabelStyle := talText;
Chart1.BottomAxis.LabelsAngle := 340;
Chart1.BottomAxis.LabelsSeparation := 0;
Chart1.BottomAxis.Title.Caption := 'Rows';
Chart1.LeftAxis.Title.Caption := 'Values';

FirstColumn := 1;
LastColumn := 10;

for RunnerY := FirstColumn to LastColumn do
begin

Name := 'FakeName'+ IntToStr (RunnerY);
Chart1.AddSeries(TBoxSeries.Create(Self));

(Chart1[RunnerY - FirstColumn] as TBoxSeries).AreaColor := clRed;
(Chart1[RunnerY - FirstColumn] as TBoxSeries).Title := Name;
(Chart1[RunnerY - FirstColumn] as TBoxSeries).Position := RunnerY - FirstColumn;
(Chart1[RunnerY - FirstColumn] as TBoxSeries).Box.Color := clBlue;
(Chart1[RunnerY - FirstColumn] as TBoxSeries).VertAxis := aLeftAxis;
(Chart1[RunnerY - FirstColumn] as TBoxSeries).HorizAxis := aBottomAxis;


RandomValue := Random(100);

For RunnerX := 1 to 10 do
Begin
(Chart1[RunnerY - FirstColumn] as TBoxSeries).Add (RunnerX*RandomValue, '', clTeeColor);;
end;
(Chart1[RunnerY - FirstColumn] as TBoxSeries).Xlabel[RunnerY - FirstColumn] := Name;


end;
end;



--------------------------------------------
and this is not working... :


if frmDataMining.DescriptiveColRadio.Checked then
begin
Chart1.Title.Text.Clear;
Chart1.Title.Text.Add('Boxplots / columns');
Chart1.View3D := False;
Chart1.ApplyZOrder := False;
Chart1.BottomAxis.LabelStyle := talText;
Chart1.BottomAxis.LabelsAngle := 340;
Chart1.BottomAxis.LabelsSeparation := 0;
Chart1.BottomAxis.Title.Caption := 'Columns';
Chart1.LeftAxis.Title.Caption := 'Values';

for RunnerX := ErsteSpalte to LetzteSpalte do
begin
ValueNo := ValuesInColumn(frmMiningResults.ResultStringGrid, RunnerX, ErsteZeile, LetzteZeile);

If ValueNo > 0 THen
Begin
Name := frmMiningResults.ResultStringGrid.Cells[RunnerX, 0];
Chart1.AddSeries(TBoxSeries.Create(Self));

(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).AreaColor := clRed;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Title := Name;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Position := RunnerX - ErsteSpalte;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Box.Color := clBlue;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).MedianPen.Color := clRed;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).AreaLinesPen.Visible := True;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).VertAxis := aLeftAxis;
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).HorizAxis := aBottomAxis;


Repeater := 0;
SetLength (SortierteListe, ValueNo); // getting the values from the column

for RunnerY := ErsteZeile to LetzteZeile do
begin
DummyString := frmMiningResults.ResultStringGrid.Cells[RunnerX, RunnerY];

If TryStrToFloat (DummyString, DummyExtended) THen
Begin
SortierteListe [Repeater] := DummyExtended;
Inc (Repeater);
end;
end;

Quicksort (SortierteListe, 0, High (SortierteLIste)); // sorting them

for RunnerY := 0 to High(SortierteListe) do // and display as boxplots
begin
(Chart1[RunnerX - ErsteSpalte] as TBoxSeries).Add (SortierteListe[RunnerY], '', clRed);
end;
(Chart1[RunnerX - ErsteSpalte]).XLabel[RunnerX-ErsteSpalte] := Name;
end;
end;
end;

Jan
Newbie
Newbie
Posts: 24
Joined: Fri Nov 15, 2002 12:00 am
Location: Germany

Post by Jan » Sat Apr 03, 2004 11:42 am

Sorry, sorry, sorry,

i was not able, to understand the meaning of some of the functions. I finally found the items property of the the bottom and depthaxis and my problems are solved... Sorry for disturbing you... but the other problem still exists (posted below).

See you again

Jan

Post Reply