We use TeeCharts extensively for the presentation of a graphical representation of real world objects. Creating Series with TChartValueLists leads to a duplication of data and issues with synchronization of data changes since there is no longer a single source of truth. Is it possible to use TeeChart with domain objects in a manner similar to DeveloperExpress with their custom datasource for grids where the grid asks the datasource for the data to display and the datasource can ask a dataset, domain object etc.
Alternatively, has anyone written a domain adapter that can quickly transfer minimal domain information to the chart for presentation?
Using Domain Objects with TeeChart
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Using Domain Objects with TeeChart
Hi dras,
Yes, this is possible using reference types as I explained here. This is a .NET example but it also applies to Delphi:
The TeeChart example in Delphi is this:
Yes, this is possible using reference types as I explained here. This is a .NET example but it also applies to Delphi:
Code: Select all
var
Form1: TForm1;
MyArray, CopyArray: Array of Double;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
MyArray[1] := 7;
ShowMessage(FloatToStr(CopyArray[1]));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetLength(MyArray, 2);
MyArray[0]:=1;
MyArray[1]:=2;
CopyArray := MyArray;
end;
Code: Select all
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, VclTee.TeeGDIPlus,
VCLTee.TeEngine, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart;
type
TForm1 = class(TForm)
Button1: TButton;
Chart1: TChart;
Chart2: TChart;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure AddNewSeries(Chart: TChart);
procedure ModifySeries(Series: TChartSeries);
public
{ Public declarations }
end;
var
Form1: TForm1;
XValues, YValues: Array of Double;
implementation
{$R *.dfm}
uses VCLTee.Series;
procedure TForm1.AddNewSeries(Chart: TChart);
var Series1: TFastLineSeries;
begin
Series1 := TFastLineSeries.Create(Self);
Series1.ParentChart := Chart;
Series1.XValues.Value := TChartValues(XValues);
Series1.XValues.Count := Length(XValues);
Series1.YValues.Value := TChartValues(YValues);
Series1.YValues.Count := Length(YValues);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
YValues[1] := 7;
ModifySeries(Chart1[0]);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := False;
Chart2.View3D := False;
SetLength(XValues, 2);
XValues[0] := 1;
XValues[1] := 2;
SetLength(YValues, 2);
YValues[0] := 1;
YValues[1] := 2;
AddNewSeries(Chart1);
AddNewSeries(Chart2);
end;
procedure TForm1.ModifySeries(Series: TChartSeries);
begin
Series.XValues.Modified := True;
Series.YValues.Modified := True;
Series.Repaint;
end;
end.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Using Domain Objects with TeeChart
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |