Текущий архив: 2003.11.27;
Скачать: CL | DM;
ВнизПожалуйста гляньте - есть тут ошибка? Найти похожие ветки
← →
olookin (2003-11-14 21:59) [0]вот код
procedure TFileWindow.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i,j: integer;
begin
if adjusted then begin adjusted:=false;
for i:=ia to ib+1 do for j:=0 to Chart1.SeriesCount-1 do begin
with Chart1.Series[j] do
if (XValues.Count>0) and (Active) then ValueColor[i]:=Data.Color;
with Chart2.Series[j] do
if (XValues.Count>0) and (Active) then ValueColor[i]:=Data.Color; end;
ChartMinMax(Chart1); ChartMinMax(Chart2); end;
end;
однако возникает ошибка обращения к несуществующему элементу (ia и ib не вылезают за пределы количества точек)...Подскажите...
← →
olookin (2003-11-14 22:03) [1]Дополняю всем кодом
procedure TFileWindow.SeriesAdjusting(Series: TChartSeries; ValIndex,
Xc,Yc: integer);
var i,c,divider: integer;
average,coef: double;
mas: TDoubleArray;
begin
CurValue:=ValIndex; zeroy:=Yc; c:=0;
divider:=0; average:=0; SetLength(mas,10);
ia:=CurValue-(interval div 2); ib:=CurValue+(interval div 2);
with Series do begin
if (ia-10)>=0 then begin for i:=ia-10 to ia-1 do begin
mas[c]:=YValues.Value[i]; Inc(c); end;
average:=Mean(mas); c:=0; Inc(divider); end;
if (ib+10)<=XValues.Count-1 then begin
for i:=ib+1 to ib+10 do begin mas[c]:=YValues.Value[i]; Inc(c); end;
Inc(divider); average:=(average+Mean(mas))/divider; end; mas:=nil;
if ia<0 then begin interval:=interval-Abs(ia); ia:=0; end;
if ib>XValues.Count-1 then begin
interval:=interval-(ib-XValues.Count-1); ib:=XValues.Count-1; end;
if (interval mod 2)=0 then begin Dec(ib); Dec(interval); end;
SetLength(mas,interval); SetLength(dispose,interval);
for i:=ia to ib do mas[i-ia]:=YValues.Value[i];
coef:=Abs(YValues.Value[CurValue]-average);
for i:=ia to ib do dispose[i-ia]:=Abs(YValues.Value[i]-average)/coef;
DiapY:=Series.ParentChart.LeftAxis.Maximum-
Series.ParentChart.LeftAxis.Minimum; mas:=nil; end;
end;
procedure TFileWindow.Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var i,j: integer;
begin
if (Button=mbLeft) and (edited) then begin
adjusted:=true; i:=CorrectionTool.SpinEdit1.Value;
if (i mod 2)=0 then interval:=i+1 else interval:=i;
SetLength(dispose,interval); CurSeries:=Series;
SeriesAdjusting(CurSeries,ValueIndex,X,Y);
for i:=ia to ib+1 do for j:=0 to Chart1.SeriesCount-1 do begin
if Chart1.Series[j].XValues.Count>0 then
Chart1.Series[j].ValueColor[i]:=InvertColor(Data.Color);
if Chart2.Series[j].XValues.Count>0 then
Chart2.Series[j].ValueColor[i]:=InvertColor(Data.Color);
end; end;
end;
procedure TFileWindow.Chart1DblClick(Sender: TObject);
begin
if Flingopen1.Enabled then Flingopen1.Click else Foldup1.Click;
end;
procedure TFileWindow.Chart1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with (sender as TChart) do begin ChartIndex:=Tag;
if (Button=mbRight) and (ssShift in Shift) then begin
Collection.Popupmenu1.Popup(X+ClientOrigin.x,Y+Clientorigin.y);
Collection.CurChart:=(sender as TChart); end;
if Button=mbRight then Popupmenu1.Popup(
X+ClientOrigin.x,Y+Clientorigin.y); end;
end;
procedure TFileWindow.Chart1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var s: string;
i: integer;
begin
with (sender as TChart) do begin
if adjusted then if ((Y>=ChartRect.Top) and (Y<=ChartRect.Bottom)) and
((X>=ChartRect.Left) and (X<=ChartRect.Right)) then begin
for i:=ia to ib do CurSeries.YValue[i]:=
CurSeries.YValue[i]-dispose[i-ia]*DiapY*(Y-zeroy)/
(ChartRect.Bottom-ChartRect.Top); zeroy:=Y;
if not GlobChange then GlobChange:=true; end;
if stopplayer then begin s:=Data.Name;
if (Y>ChartRect.Top) and (Y<ChartRect.Bottom) then
s:=s+" [Y="+Format("%0.1f",[LeftAxis.CalcPosPoint(Y)])+"]";
if (X>ChartRect.Left) and (X<ChartRect.Right) then
s:=s+"[X="+Format("%0.1f",[BottomAxis.CalcPosPoint(X)])+"]";
self.Caption:=s; end; end;
end;
procedure TFileWindow.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i,j: integer;
begin
if adjusted then begin adjusted:=false;
for i:=ia to ib+1 do for j:=0 to Chart1.SeriesCount-1 do begin
with Chart1.Series[j] do
if (XValues.Count>0) and (Active) then ValueColor[i]:=Data.Color;
with Chart2.Series[j] do
if (XValues.Count>0) and (Active) then ValueColor[i]:=Data.Color; end;
ChartMinMax(Chart1); ChartMinMax(Chart2); end;
end;
← →
olookin (2003-11-14 22:37) [2]Код по правилам???
procedure TFileWindow.SeriesAdjusting(Series: TChartSeries; ValIndex,
Xc,Yc: integer);
var i,c,divider: integer;
average,coef: double;
mas: TDoubleArray;
begin
CurValue:=ValIndex;
zeroy:=Yc;
c:=0;
divider:=0;
average:=0;
SetLength(mas,10);
ia:=CurValue-(interval div 2);
ib:=CurValue+(interval div 2);
with Series do
begin
if (ia-10)>=0 then begin
for i:=ia-10 to ia-1 do
begin
mas[c]:=YValues.Value[i]; Inc(c);
end;
average:=Mean(mas);
c:=0;
Inc(divider);
end;
if (ib+10)<=XValues.Count-1 then
begin
for i:=ib+1 to ib+10 do
begin
mas[c]:=YValues.Value[i]; Inc(c);
end;
Inc(divider);
average:=(average+Mean(mas))/divider;
end;
mas:=nil;
if ia<0 then
begin
interval:=interval-Abs(ia); ia:=0;
end;
if ib>XValues.Count-1 then begin
interval:=interval-(ib-XValues.Count-1);
ib:=XValues.Count-1;
end;
if (interval mod 2)=0 then begin
Dec(ib);
Dec(interval);
end;
SetLength(mas,interval); SetLength(dispose,interval);
for i:=ia to ib do mas[i-ia]:=YValues.Value[i];
coef:=Abs(YValues.Value[CurValue]-average);
for i:=ia to ib do
dispose[i-ia]:=Abs(YValues.Value[i]-average)/coef;
DiapY:=Series.ParentChart.LeftAxis.Maximum-
Series.ParentChart.LeftAxis.Minimum; mas:=nil; end;
end;
procedure TFileWindow.Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var i,j: integer;
begin
if (Button=mbLeft) and (edited) then
begin
adjusted:=true; i:=CorrectionTool.SpinEdit1.Value;
if (i mod 2)=0 then interval:=i+1 else interval:=i;
SetLength(dispose,interval);
CurSeries:=Series;
SeriesAdjusting(CurSeries,ValueIndex,X,Y);
for i:=ia to ib+1 do for j:=0 to Chart1.SeriesCount-1 do
begin
if Chart1.Series[j].XValues.Count>0 then
Chart1.Series[j].ValueColor[i]:=InvertColor(Data.Color);
if Chart2.Series[j].XValues.Count>0 then
Chart2.Series[j].ValueColor[i]:=InvertColor(Data.Color);
end; end;
end;
procedure TFileWindow.Chart1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
with (sender as TChart) do
begin
ChartIndex:=Tag;
if (Button=mbRight) and (ssShift in Shift) then
begin
Collection.Popupmenu1.Popup(X+ClientOrigin.x,Y+Clientorigin.y);
Collection.CurChart:=(sender as TChart); end;
if Button=mbRight then Popupmenu1.Popup(
X+ClientOrigin.x,Y+Clientorigin.y);
end;
end;
procedure TFileWindow.Chart1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var s: string;
i: integer;
begin
with (sender as TChart) do
begin
if adjusted then if ((Y>=ChartRect.Top) and (Y<=ChartRect.Bottom)) and
((X>=ChartRect.Left) and (X<=ChartRect.Right)) then
begin
for i:=ia to ib do CurSeries.YValue[i]:=
CurSeries.YValue[i]-dispose[i-ia]*DiapY*(Y-zeroy)/
(ChartRect.Bottom-ChartRect.Top);
zeroy:=Y;
if not GlobChange then GlobChange:=true;
end;
if stopplayer then
begin
s:=Data.Name;
if (Y>ChartRect.Top) and (Y<ChartRect.Bottom) then
s:=s+" [Y="+Format("%0.1f",[LeftAxis.CalcPosPoint(Y)])+"]";
if (X>ChartRect.Left) and (X<ChartRect.Right) then
s:=s+"[X="+Format("%0.1f",[BottomAxis.CalcPosPoint(X)])+"]";
self.Caption:=s;
end;
end;
end;
procedure TFileWindow.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i,j: integer;
begin
if adjusted then
begin
adjusted:=false;
for i:=ia to ib+1 do for j:=0 to Chart1.SeriesCount-1 do
begin
with Chart1.Series[j] do if (XValues.Count>0) and
(Active) then ValueColor[i]:=Data.Color;
with Chart2.Series[j] do if (XValues.Count>0) and
(Active) then ValueColor[i]:=Data.Color;
end;
ChartMinMax(Chart1); ChartMinMax(Chart2); end;
end;
← →
Johnmen (2003-11-15 01:12) [3]Мало кода !!!!!!!!!!!!!!
Давай еще !!!!!!!!! Еще !!!!!!!!!
← →
Palladin (2003-11-15 06:53) [4]
> Johnmen © (15.11.03 01:12) [3]
:))) Класс...
Страницы: 1 вся ветка
Текущий архив: 2003.11.27;
Скачать: CL | DM;
Память: 0.47 MB
Время: 0.009 c