unit GraphBase;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ToolWin, ComCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Placemnt,
  ActnList,teePrevi,data;

const
  ClipBoardMetaFileExt : boolean = false;  

type
  TfmGraphBase = class(TForm)
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    Chart1: TChart;
    FormStorage: TFormStorage;
    ToolButton1: TToolButton;
    ActionList1: TActionList;
    actGraphProps: TAction;
    ToolButton2: TToolButton;
    actGraphCopy: TAction;
    ToolButton3: TToolButton;
    actGraphPrint: TAction;
    procedure actGraphPropsExecute(Sender: TObject);
    procedure actGraphCopyExecute(Sender: TObject);
    procedure actGraphPrintExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmGraphBase: TfmGraphBase;

  function GeneralGraph(
                       DateBase : TDateTime;
                       ChartTitle : string;
                       ChartData : array of Float
                     ) : boolean;

implementation

uses ieditcha,series;

{$R *.DFM}

function GeneralGraph(
                       DateBase : TDateTime;
                       ChartTitle : string;
                       ChartData : array of Float
                     ) : boolean;
var
  FChart : TFmGraphBase;
  FastS  : TFastLineSeries;
  i      : integer;
begin
  fChart := TFmGraphBase.Create(Application);
  FastS  := TFastLineSeries.Create(FChart);
  FastS.ParentChart := FChart.Chart1;
  FastS.XValues.DateTime := true;
  //FastS.HorizAxis.DateTime := true;

  for i:=0 to High(ChartData) do
      FastS.AddXY(DateBase+i/24,ChartData[i]);
  with FChart do
  try
    Result := ShowModal=mrOk;
  finally
    Free;
  end;
end;

procedure TfmGraphBase.actGraphPropsExecute(Sender: TObject);
var
  ef : TChartEditForm;
begin
  ef := TChartEditForm.Create(Application);
  with ef do
  try
    Caption := 'Ιδιότητες Γραφήματος';
    TheChart := Chart1;
    {
    ef.TabSeriesList.TabVisible := False;
    ef.TabSeries.TabVisible := False;
    ef.TheActivePageIndex   := 2;
    }
    ShowModal;
  finally
    Free;
  end;
end;

procedure TfmGraphBase.actGraphCopyExecute(Sender: TObject);
begin
  Chart1.CopyToClipboardMetafile(ClipBoardMetaFileExt);
end;

procedure TfmGraphBase.actGraphPrintExecute(Sender: TObject);
begin
  ChartPreview(Self,Chart1);
end;

end.
