📄 frxchart.pas
字号:
procedure TfrxChartView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX,
OffsetY: Extended);
var
EMF: TMetafile;
begin
BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY);
DrawBackground;
FillChart;
if Color = clTransparent then
FChart.Color := clWhite else
FChart.Color := Color;
FChart.BufferedDisplay := True;
EMF := FChart.TeeCreateMetafile(False, Rect(0, 0, Round(Width), Round(Height)));
Canvas.StretchDraw(Rect(FX, FY, FX1, FY1), EMF);
EMF.Free;
DrawFrame;
end;
procedure TfrxChartView.AfterPrint;
var
i: Integer;
begin
for i := 0 to FSeriesData.Count - 1 do
with FSeriesData[i] do
begin
Values1 := '';
Values2 := '';
Values3 := '';
Values4 := '';
Values5 := '';
Values6 := '';
end;
end;
procedure TfrxChartView.GetData;
var
i: Integer;
begin
inherited;
for i := 0 to FSeriesData.Count - 1 do
with FSeriesData[i] do
if (DataType = dtDBData) and (DataSet <> nil) then
begin
Values1 := '';
Values2 := '';
Values3 := '';
Values4 := '';
Values5 := '';
Values6 := '';
DataSet.First;
while not DataSet.Eof do
begin
if Source1 <> '' then
Values1 := Values1 + ';' + VarToStr(Report.Calc(Source1));
if Source2 <> '' then
Values2 := Values2 + ';' + VarToStr(Report.Calc(Source2));
if Source3 <> '' then
Values3 := Values3 + ';' + VarToStr(Report.Calc(Source3));
if Source4 <> '' then
Values4 := Values4 + ';' + VarToStr(Report.Calc(Source4));
if Source5 <> '' then
Values5 := Values5 + ';' + VarToStr(Report.Calc(Source5));
if Source6 <> '' then
Values6 := Values6 + ';' + VarToStr(Report.Calc(Source6));
DataSet.Next;
end;
end
else if DataType = dtFixedData then
begin
Values1 := Source1;
Values2 := Source2;
Values3 := Source3;
Values4 := Source4;
Values5 := Source5;
Values6 := Source6;
end
end;
procedure TfrxChartView.BeforeStartReport;
var
i: Integer;
begin
for i := 0 to FSeriesData.Count - 1 do
with FSeriesData[i] do
begin
Values1 := '';
Values2 := '';
Values3 := '';
Values4 := '';
Values5 := '';
Values6 := '';
end;
Report.Engine.NotifyList.Add(Self);
end;
procedure TfrxChartView.OnNotify(Sender: TObject);
var
i: Integer;
begin
inherited;
for i := 0 to FSeriesData.Count - 1 do
with FSeriesData[i] do
if (DataType = dtBandData) and (DataBand = Sender) then
begin
Report.CurObject := Self.Name;
if Source1 <> '' then
Values1 := Values1 + ';' + VarToStr(Report.Calc(Source1));
if Source2 <> '' then
Values2 := Values2 + ';' + VarToStr(Report.Calc(Source2));
if Source3 <> '' then
Values3 := Values3 + ';' + VarToStr(Report.Calc(Source3));
if Source4 <> '' then
Values4 := Values4 + ';' + VarToStr(Report.Calc(Source4));
if Source5 <> '' then
Values5 := Values5 + ';' + VarToStr(Report.Calc(Source5));
if Source6 <> '' then
Values6 := Values6 + ';' + VarToStr(Report.Calc(Source6));
end;
end;
procedure TfrxChartView.AddSeries(Series: TfrxChartSeries);
var
sc: TSeriesClass;
s: TChartSeries;
b: Boolean;
{$IFDEF FR_COM}
item: TfrxSeriesItem;
{$ENDIF}
begin
sc := frxChartSeries[Integer(Series)];
s := TChartSeries(sc.NewInstance);
s.Create(Chart);
Chart.AddSeries(s);
{$IFNDEF FR_COM}
SeriesData.Add;
{$ELSE}
item := SeriesData.Add;
item.Series := s;
{$ENDIF}
with Chart do
begin
b := not (s is TPieSeries);
View3DOptions.Orthogonal := b;
AxisVisible := b;
View3DWalls := b;
end;
end;
procedure TfrxChartView.ClearSeries;
begin
FChart.Free;
CreateChart;
SeriesData.Clear;
end;
{$IFDEF FR_COM}
function TfrxChartView.GetSeriesItem(Index: Integer; out Value: IfrxSeriesItem): HResult; stdcall;
begin
Value := SeriesData.Items[Index] as IfrxSeriesItem;
Value._AddRef();
Result := S_OK;
end;
function TfrxChartView.AddSeriesItem(Type_: frxSeriesType; out NewItem: IfrxSeriesItem): HResult; stdcall;
begin
AddSeries( TfrxChartSeries(Type_) );
Result := GetSeriesItem(SeriesData.Count-1, NewItem);
end;
function TfrxChartView.SeriesCount(out Value: Integer): HResult; stdcall;
begin
Value := SeriesData.Count;
Result := S_OK;
end;
function TfrxChartView.Get_View3D(out Value: WordBool): HResult; stdcall;
begin
Value := Chart.View3D;
Result := S_OK;
end;
function TfrxChartView.Set_View3D(Value: WordBool): HResult; stdcall;
begin
Chart.View3D := Value;
Result := S_OK;
end;
function TfrxChartView.Get_View3dWalls(out Value: WordBool): HResult; stdcall;
begin
Value := Chart.View3DWalls;
Result := S_OK;
end;
function TfrxChartView.Set_View3dWalls(Value: WordBool): HResult; stdcall;
begin
Chart.View3dWalls := Value;
Result := S_OK;
end;
function TfrxChartView.Get_LeftAxis(out Value: IfrxChartAxis): HResult; stdcall;
begin
Value := FLeftAxis;
FLeftAxis._AddRef;
Result := S_OK;
end;
function TfrxChartView.Get_BottomAxis(out Value: IfrxChartAxis): HResult; stdcall;
begin
Value := FBottomAxis;
FBottomAxis._AddRef;
Result := S_OK;
end;
{$ENDIF}
{$IFDEF FR_COM}
{ TfrxChartAxis }
constructor TfrxChartAxis.Create(Axis: TChartAxis);
begin
FAxis := Axis;
end;
function TfrxChartAxis.Get_Automatic(out Value: WordBool): HResult; stdcall;
begin
Value := FAxis.Automatic;
Result := S_OK;
end;
function TfrxChartAxis.Set_Automatic(Value: WordBool): HResult; stdcall;
begin
FAxis.Automatic := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_Minimum(out Value: Double): HResult; stdcall;
begin
Value := FAxis.Minimum;
Result := S_OK;
end;
function TfrxChartAxis.Set_Minimum(Value: Double): HResult; stdcall;
begin
FAxis.Minimum := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_Maximum(out Value: Double): HResult; stdcall;
begin
Value := FAxis.Maximum;
Result := S_OK;
end;
function TfrxChartAxis.Set_Maximum(Value: Double): HResult; stdcall;
begin
FAxis.Maximum := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_AutomaticMaximum(out Value: WordBool): HResult; stdcall;
begin
Value := FAxis.AutomaticMaximum;
Result := S_OK;
end;
function TfrxChartAxis.Set_AutomaticMaximum(Value: WordBool): HResult; stdcall;
begin
FAxis.AutomaticMaximum := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_AutomaticMinimum(out Value: WordBool): HResult; stdcall;
begin
Value := FAxis.AutomaticMinimum;
Result := S_OK;
end;
function TfrxChartAxis.Set_AutomaticMinimum(Value: WordBool): HResult; stdcall;
begin
FAxis.AutomaticMinimum := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_AxisValuesFormat(out Value: WideString): HResult; stdcall;
begin
Value := FAxis.AxisValuesFormat;
Result := S_OK;
end;
function TfrxChartAxis.Set_AxisValuesFormat(const Value: WideString): HResult; stdcall;
begin
FAxis.AxisValuesFormat := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_EndPosition(out Value: Double): HResult; stdcall;
begin
Value := FAxis.EndPosition;
Result := S_OK;
end;
function TfrxChartAxis.Set_EndPosition(Value: Double): HResult; stdcall;
begin
FAxis.EndPosition := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_Width(out Value: Integer): HResult; stdcall;
begin
Value := FAxis.Axis.Width;
Result := S_OK;
end;
function TfrxChartAxis.Set_Width(Value: Integer): HResult; stdcall;
begin
FAxis.Axis.Width := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_Color(out Value: Integer): HResult; stdcall;
begin
Value := FAxis.Axis.Color;
Result := S_OK;
end;
function TfrxChartAxis.Set_Color(Value: Integer): HResult; stdcall;
begin
FAxis.Axis.Color := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_Labels(out Value: WordBool): HResult; stdcall;
begin
Value := FAxis.Labels;
Result := S_OK;
end;
function TfrxChartAxis.Set_Labels(Value: WordBool): HResult; stdcall;
begin
FAxis.Labels := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_LabelsExponent(out Value: WordBool): HResult; stdcall;
begin
{$IFDEF TEECHART7}
Value := FAxis.LabelsExponent;
Result := S_OK;
{$ELSE}
Result := E_NOTIMPL;
{$ENDIF}
end;
function TfrxChartAxis.Set_LabelsExponent(Value: WordBool): HResult; stdcall;
begin
{$IFDEF TEECHART7}
FAxis.LabelsExponent := Value;
Result := S_OK;
{$ELSE}
Result := E_NOTIMPL;
{$ENDIF}
end;
function TfrxChartAxis.Get_LabelsSeparation(out Value: Integer): HResult; stdcall;
begin
Value := FAxis.LabelsSeparation;
Result := S_OK;
end;
function TfrxChartAxis.Set_LabelsSeparation(Value: Integer): HResult; stdcall;
begin
FAxis.LabelsSeparation := Value;
Result := S_OK;
end;
function TfrxChartAxis.Get_LabelStyle(out Value: Integer): HResult; stdcall;
begin
Value := Integer(FAxis.LabelStyle);
Result := S_OK;
end;
function TfrxChartAxis.Set_LabelStyle(Value: Integer): HResult; stdcall;
begin
FAxis.LabelStyle := TAxisLabelStyle(Value);
Result := S_OK;
end;
function TfrxChartAxis.Get_Logarithmic(out Value: WordBool): HResult; stdcall;
begin
Value := FAxis.Logarithmic;
Result := S_OK;
end;
function TfrxChartAxis.Set_Logarithmic(Value: WordBool): HResult; stdcall;
begin
FAxis.Logarithmic := Value;
Result := S_OK;
end;
{$ENDIF}
initialization
{$IFNDEF TeeChartStd}
{$IFNDEF TeeChartStd7}
{$IFNDEF TeeChart4}
RegisterTeeStandardSeries;
{$ENDIF}
{$ENDIF}
{$ENDIF}
frxObjects.RegisterObject1(TfrxChartView, nil, '', '', 0, 25);
finalization
frxObjects.UnRegister(TfrxChartView);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -