Deleting more than one point in a series
Posted: Tue Jun 17, 2008 12:28 pm
I am attempting to deleting multiple points is a series. The code belows shows what I am trying to do.
The problem is that it does not delete all the points.
Please advise.
Thank you.[/code]
The problem is that it does not delete all the points.
Code: Select all
{*************************************************}
procedure TFormPlot.chrtPlotMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbLeft) and bDelete then
begin
nX0 := X;
nY0 := Y;
bMouseDown := TRUE;
end
else
end;
{**************************************************}
procedure TFormPlot.chrtPlotMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i, j : Integer;
nValue : Integer;
begin
if (Button = mbLeft) and bDelete then
begin
nX1 := X;
nY1 := Y;
bMouseDown := FALSE;
if (nX0 <> -1) and (nY0 <> -1) then
begin
//
//how many series are there in this plotsheet
//
for i:=0 to chrtPlot.SeriesCount-1 do
//how many points are there in this selected series
for j:=0 to chrtPlot.Series[i].Count-1 do
//is the point a valid selection
if chrtPlot.Series[i].CalcXPos(j) >= nX0) and
chrtPlot.Series[i].CalcYPos(j) >= nY0) and
chrtPlot.Series[i].CalcXPos(j) <= nX1) and
chrtPlot.Series[i].CalcYPos(j) <= nY1) then
begin
chrtPlot.Series[i].Delete(j);
end;//if
end;// if (nX0 <> -1) and (nY0 <> -1) then}
end
end;
{*************************************************}
procedure TFormPlot.chrtPlotMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
wX, wYl, wYr : double;
strX, strY : String;
begin
if bMouseDown then
begin
nX1 := X;
nY1 := Y;
//
chrtPlot.Draw;
end;
//
if bDelete then
begin
if (nX0 <> -1) and (nY0 <> -1) then
begin
//draw a rectangular square around the selected area
chrtPlot.Canvas.Brush.Style := bsClear;
chrtPlot.Canvas.Pen.Color := clBlack;
chrtPlot.Canvas.Rectangle(nX0, nY0, nX1, nY1);
end;
end
end;
Thank you.[/code]