How to place a 'point' on a horizontal bar graph.
Posted: Tue Oct 09, 2018 11:08 am
I want to draw a horizontal bar graph series and draw one of more points at some location over the horizontal bar.
The bars work fine until I want to add the points, and then only every second bar is displayed.
How can I show TPoints and also display every horizontal bar?
The bars work fine until I want to add the points, and then only every second bar is displayed.
How can I show TPoints and also display every horizontal bar?
Code: Select all
var
HSeries : array of THorizBarSeries;
PSeries : array of TPointSeries;
Code: Select all
procedure TForm4.Button1Click(Sender: TObject);
var
Rnd : Integer;
i : Integer;
j : Integer;
MyColour : TColor;
begin
SetLength(HSeries, 0);
SetLength(PSeries, 0);
Chart1.RemoveAllSeries;
Chart1.LeftAxis.Items.Clear;
series1.StackGroup := 0;
Chart1.LeftAxis.Items.Clear;
Chart1.LeftAxis.Items.Count := 0;
Chart1.Pages.MaxPointsPerPage := 16;
for i := 0 to 150 do
begin
SetLength(HSeries, i+1);
SetLength(PSeries, i+1);
HSeries[i] := THorizBarSeries.Create(Chart1);
Hseries[i].MultiBar := mbNone;
HSeries[i].StackGroup := i;
HSeries[i].Marks.Visible := False;
HSeries[i].BarWidthPercent := 90;//100; //95;
Chart1.AddSeries(HSeries[i]);
MyColour := clGreen;
Rnd := Random(45);
Rnd := 45 + Rnd;
HSeries[i].AddX(Rnd, '', MyColour);
Hseries[i].MultiBar := mbSelfStack;
Chart1.LeftAxis.Items.Add(i); {i+1}
Chart1.LeftAxis.Items.Item[i].Text:= IntToStr(i+1)+' Chk'+IntToStr(Rnd);
{draw the yellow and red}
for j := 2 to 3 do
begin
if j = 2 then myColour := clYellow
else MyColour := clRed;
HSeries[i].AddX(j*2, '', MyColour);
end;
{draw the point over the top of the horizontal bar graph}
Rnd := Random(25);
Rnd := 20 + Rnd;
PSeries[i] := TPointSeries.Create(Chart1); // (self);
PSeries[i].Marks.Visible := False;
PSeries[i].Pointer.Style := psTriangle;
PSeries[i].AddXY(Rnd, i, '', clYellow);
Chart1.AddSeries(PSeries[i]);
end; {for i}
end;