Tchart 光滑

unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, TeeSpline, DBChart,
  StdCtrls, Buttons, TeeComma;
type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    Chart2: TChart;
    TeeCommander1: TTeeCommander;
    Series1: TLineSeries;
    Series2: TLineSeries;
    TeeFunction1: TSmoothingFunction;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
  Tfunctiona: TSmoothingFunction;
  i: Integer;
begin
   chart2.ClearChart;
  Series1:= TLineSeries.Create(self);
  Series2:= TLineSeries.Create(self);
  chart2.AddSeries(Series1);
  chart2.AddSeries(Series2);
  chart2.Series[0].Add(11.1,'1月');
  chart2.Series[0].Add(9.1,'2月');
  chart2.Series[0].Add(11.1,'3月');
  chart2.Series[0].Add(9.1,'4月');
  chart2.Series[0].Add(12.1,'1月');
  chart2.Series[0].Add(8.1,'2月');
  chart2.Series[0].Add(11.1,'3月');
  chart2.Series[0].Add(8.1,'4月');
  chart2.Series[1].Add(11.1,'1月');
  chart2.Series[1].Add(9.1,'2月');
  chart2.Series[1].Add(11.1,'3月');
  chart2.Series[1].Add(9.1,'4月');
  chart2.Series[1].Add(12.1,'1月');
  chart2.Series[1].Add(8.1,'2月');
  chart2.Series[1].Add(11.1,'3月');
  chart2.Series[1].Add(8.1,'4月');
  Tfunctiona := TSmoothingFunction.create(self);
  Series2.SetFunction(Tfunctiona);
  Tfunctiona.Interpolate := false;
  Tfunctiona.Factor := 4;

    Series2.datasources.clear;
    Series2.datasources.add(chart2.series[0]);
    Series2.CheckDataSource;
    chart2.series[1].assignvalues(Series1);
    chart2.Series[0].CheckDataSource;
 
 // Series1.visible := false;
  TFunctiona.free;
  chart2.View3D := false;
end;
end.

本文出自 “601880” 博客,谢绝转载!

你可能感兴趣的:(职场,休闲,tchart)