Hi!
I have a Chart with Bars and are showing the Data Table, is it possible to get the sum of a column?
Have a look here:
[img]http:\\www.mgm-net.com\teechart\clip2.png[/img]
Thanks
Günter
Getting a summary for Data Table
Getting a summary for Data Table
Gruß aus den Bergen
Günter
Günter
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Günter,
The easiest way to achieve what you request is using a TAddTeeFunction which would do the sum for you and add the results at the TDataTableTool.
For further information about TeeChart functions please read Tutorial 7 - Working with Functions. Tutorials can be found at TeeChart's program group.
If you don't want to see the add function series in the chart but you want it visible in the TDataTableTool you can set its series colour to transparent:
As shown in the code snippet above you can also customize series's title and if they appear in the legend.
The easiest way to achieve what you request is using a TAddTeeFunction which would do the sum for you and add the results at the TDataTableTool.
For further information about TeeChart functions please read Tutorial 7 - Working with Functions. Tutorials can be found at TeeChart's program group.
If you don't want to see the add function series in the chart but you want it visible in the TDataTableTool you can set its series colour to transparent:
Code: Select all
Series4.Color:=clNone;
Series4.Title:='Sum';
Series4.ShowInLegend:=false;
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:
Hi Günter,
As an update to my previous reply, I've noticed that setting Series.Color to clNone caused sum not being displayed in the datatable either. An alternative is using this:
As an update to my previous reply, I've noticed that setting Series.Color to clNone caused sum not being displayed in the datatable either. An alternative is using this:
Code: Select all
Series4.LinePen.Visible:=false;
Series4.Brush.Style:=bsClear;
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 |
Hi!
Thank you. I have never worked with this 'Functions', so I have to look at the helpfile and tutorials to know where to begin.narcis wrote: As an update to my previous reply, I've noticed that setting Series.Color to clNone caused sum not being displayed in the datatable either. An alternative is using this:
Gruß aus den Bergen
Günter
Günter
I looked at this tutorial and I tried a lot, but I still not able to make this work, maybe you have a small example for something like this?narcis wrote:The easiest way to achieve what you request is using a TAddTeeFunction which would do the sum for you and add the results at the TDataTableTool.
For further information about TeeChart functions please read Tutorial 7 - Working with Functions. Tutorials can be found at TeeChart's program group.
Thats now the way I try it, but the 'summary' doesn't really work
Code: Select all
procedure SetzDatenLautKennezeichen(cKZ, cGfTyp : String; Value : Double);
var
oBar : TBarSeries;
nNr : Integer;
i : integer;
begin
if cKz = '_' then oBar := Series7
else if cKz = 'T' then oBar := Series8
else if cKZ = 'E' then oBar := Series9
else oBar := nil;
if cGfTyp = 'AN' then nNr := 0
else if cGfTyp ='AB' then nNr := 1
else if cGfTyp = 'LI' then nNr := 2
else if cGfTyp = 'RE' then nNr := 3
else nNr := 99;
if (nNr >90) or (oBar=nil) or (cGfTyp='') then exit;
case nNR of
0: nAnSumme := nAnSumme + Value;
1: nABSumme := nAbSumme + Value;
2: nLiSumme := nLiSumme + Value;
3: nReSumme := nReSumme + Value;
end;
i := oBar.Labels.IndexOfLabel(cGfTyp);
if i < 0
then oBar.AddXy(nNr, Value, cGftyp)
else oBar.VAluesList[1].Items[i] := oBar.VAluesList[1].Items[i] + Value;
end;
Code: Select all
Series10.AddXY(0, nANSumme, 'AN');
Series10.AddXY(0, nABSumme, 'AB');
Series10.AddXY(0, nLISumme, 'LI');
Series10.AddXY(0, nRESumme, 'RE');
Maybe you can help - Thank you.
Gruß aus den Bergen
Günter
Günter
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Günter,
Using the code in the functions tutorial you can do something like this:
Using the code in the functions tutorial you can do something like this:
Code: Select all
uses Series, TeeFunci, TeeDataTableTool;
procedure TForm1.FormCreate(Sender: TObject);
var tmpBarSeries1, tmpBarSeries2, tmpBarSeries3: TBarSeries;
tmpLineSeries: TLineSeries;
begin
With Chart1 do
begin
//Add data Series
tmpBarSeries1:=TBarSeries.Create(self);
tmpBarSeries2:=TBarSeries.Create(self);
tmpBarSeries3:=TBarSeries.Create(self);
AddSeries(tmpBarSeries1);
AddSeries(tmpBarSeries2);
AddSeries(tmpBarSeries3);
tmpBarSeries1.MultiBar:=mbStacked;
tmpBarSeries2.MultiBar:=mbStacked;
tmpBarSeries3.MultiBar:=mbStacked;
tmpBarSeries1.Marks.Visible:=false;
tmpBarSeries2.Marks.Visible:=false;
tmpBarSeries3.Marks.Visible:=false;
//Populate them with data (here random)
tmpBarSeries1.FillSampleValues(10);
tmpBarSeries2.FillSampleValues(10);
tmpBarSeries3.FillSampleValues(10);
//Add a series to be used for an Add Function
tmpLineSeries:=TLineSeries.Create(self);
AddSeries(tmpLineSeries);
//Define the Function Type for the new Series
tmpLineSeries.SetFunction(TAddTeeFunction.Create(self));
//Define the Datasource for the new Function Series
//Datasource accepts the Series titles of the other 2 Series
tmpLineSeries.DataSources.Clear;
tmpLineSeries.DataSources.Add( tmpBarSeries1 );
tmpLineSeries.DataSources.Add( tmpBarSeries2 );
tmpLineSeries.DataSources.Add( tmpBarSeries3 );
// *Note - When populating your input Series manually you will need to
// use the Checkdatasource method
// - See the section entitled 'Defining a Datasource'
// Change the Period of the Function so that it groups averages
// every 2 Points
//tmpLineSeries.FunctionType.Period := 2;
Tools.Add(TDataTableTool.Create(self));
tmpLineSeries.LinePen.Visible:=false;
tmpLineSeries.Brush.Style:=bsClear;
tmpLineSeries.Title:='Sum';
tmpLineSeries.ShowInLegend:=false;
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 |
narcis wrote: Using the code in the functions tutorial you can do something like this:Code: Select all
[/quote] Thank you. Now It works perfect. I modified the TTeeDataTabletool so every String with beginning '=' is painted bold.
Gruß aus den Bergen
Günter
Günter