Trying to figure out TeeChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Trying to figure out TeeChart

Post by tultalk » Fri Apr 05, 2019 12:12 am

1. In code below groups group nothing on chart.

2. Chart1.SeriesGroups.Items[0].Add(Series_0); does not add the series. I have to invoke Chart1.AddSeries(Series_0);
to get series to show. Why doesn't Chart1.SeriesGroups.Items[0].Add(Series_0); add the series?

I want two groups with 3 items in each. See screen shot below. Using TeeChart is not intuitively obvious. I used it years ago w/Delphi 5 and do not remember complications and misunderstanding of properties/methods.

As written, code produces no output displayed in chart.

Thanks

Robert

Code: Select all

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
  Chart, TeEngine, Series;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }

  end;

var
  Form1: TForm1;

  implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
var
  Chart1: TChart;
  Series_0, Series_1 : THorizBarSeries;
  sTest : String;
begin
  try
    Chart1 := TChart.Create(self);
    Chart1.Parent := self;
    Chart1.Top := 0;
    Chart1.Left := 0;
    Chart1.Height := 450;
    Chart1.Width := 800;
    Chart1.View3D := False;
    Chart1.View3DWalls := False;
    Chart1.RemoveAllSeries;
    Chart1.Pages.MaxPointsPerPage := 10;

    (Chart1.SeriesGroups.Add as TSeriesGroup).Name:='SeriesGgroup_0';
    Series_0 := THorizBarSeries.Create(Self);
//    Chart1.AddSeries(Series_0);
    sTest := Chart1.SeriesGroups.Items[0].Name;
    Chart1.SeriesGroups.Items[0].Add(Series_0);
//    Chart1.AddSeries(Series_0);
    Series_0.CustomBarHeight := 30;
    Series_0.OffsetPercent := 80;
    Series_0.BarWidthPercent := 200;
    Series_0.Marks.Style := smsValue;
    Series_0.Add(123, 'S0_1', clRed);
    Series_0.Add(456, 'S0_2', clBlue);
    Series_0.Add(789, 'S0_3', clGreen);

    (Chart1.SeriesGroups.Add as TSeriesGroup).Name:='SeriesGgroup_1';
    Series_1 := THorizBarSeries.Create(Self);
//    Chart1.AddSeries(Series_1);
    sTest := Chart1.SeriesGroups.Items[1].Name;
    Chart1.SeriesGroups.Items[1].Add(Series_1);
//    Chart1.AddSeries(Series_1);
    Series_1.CustomBarHeight := 30;
    Series_1.OffsetPercent := 80;
    Series_1.BarWidthPercent := 200;
    Series_1.Marks.Style := smsValue;
    Series_1.Add(456, 'S1_1', clRed);
    Series_1.Add(123, 'S1_2', clBlue);
    Series_1.Add(987, 'S1_3', clGreen);
  finally
    //Chart1.Free;
  end;
end;
end.
Chart_1.png
Chart_1.png (7.92 KiB) Viewed 27735 times

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Fri Apr 05, 2019 11:34 am

Got up this am and chart produced with Chart1.AddSeries(Series_0); commented out. Mysterious gremlins at work.

Never the less how do I get the two series bars grouped together

and why don't the S1_1 series labels show on the chart???

Series_1.Add(456, 'S1_1', clRed);
Series_1.Add(123, 'S1_2', clBlue);
Series_1.Add(987, 'S1_3', clGreen);

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to figure out TeeChart

Post by Yeray » Fri Apr 05, 2019 12:46 pm

Hello,

You can find an explanation at the TeeChart VCL Reference, concretely, for TSeriesGroups:
Chart Series can be grouped. Series groups can optionally be displayed at the chart editor.
The main purpose of groups is to have an easy way to show or hide multiple series, that is, show or hide individual groups of series.

A single series can pertain to no groups, to one group or to more than one group.
If you want to have 3 bars and 3 bars, you should have three series with two values each:

Code: Select all

    Series_0 := THorizBarSeries.Create(Self);
    Chart1.AddSeries(Series_0);
    Series_0.CustomBarHeight := 30;
    Series_0.BarWidthPercent := 200;
    Series_0.Marks.Style := smsValue;
    Series_0.Color := clRed;

    Series_1 := THorizBarSeries.Create(Self);
    Chart1.AddSeries(Series_1);
    Series_1.CustomBarHeight := 30;
    Series_1.BarWidthPercent := 200;
    Series_1.Marks.Style := smsValue;
    Series_1.Color := clBlue;

    Series_2 := THorizBarSeries.Create(Self);
    Chart1.AddSeries(Series_2);
    Series_2.CustomBarHeight := 30;
    Series_2.BarWidthPercent := 200;
    Series_2.Marks.Style := smsValue;
    Series_2.Color := clGreen;

    Series_0.Add(123, 'S0_1');
    Series_1.Add(456, 'S1_1');
    Series_2.Add(789, 'S2_1');

    Series_0.Add(456, 'S0_2');
    Series_1.Add(123, 'S1_2');
    Series_2.Add(987, 'S2_2');
Project1_2019-04-05_14-45-57.png
Project1_2019-04-05_14-45-57.png (13.68 KiB) Viewed 27725 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Fri Apr 05, 2019 1:37 pm

Retract nmy got up this morning.

Still problem with

2. Chart1.SeriesGroups.Items[0].Add(Series_0); does not add the series. I have to invoke Chart1.AddSeries(Series_0);
to get series to show. Why doesn't Chart1.SeriesGroups.Items[0].Add(Series_0); add the series?

But you say the group command doe snot really group. Kind of silly.

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Fri Apr 05, 2019 2:39 pm

Great. Code you posted facilitated my understanding of how this works.

That settled, I need to create series dynamically and the number of series based on parameters supplied in program.

Code: Select all

    for i := 0 to 1 do
      begin
        sSeriesName := 'Series' + IntToStr(i);
        THorizBarSeries(sSeriesName).Create(Self);  <<<< This is disliked!!!
      end;
How to cast string a THorizBarSeries?

Thanks

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to figure out TeeChart

Post by Yeray » Mon Apr 08, 2019 1:03 pm

Hello,

Here is how you could create the bars and assign a Name to each one dynamically.
I've also set the series marks to show the labels and the values (smsLabelValue) and the left axis labels to show the values (talValue).

Code: Select all

  Chart1.View3D := False;
  Chart1.View3DWalls := False;
  Chart1.Axes.Left.LabelStyle:=talValue;

  for i := 0 to 2 do
  begin
    with Chart1.AddSeries(THorizBarSeries) as THorizBarSeries do
    begin
      Name := 'Series' + IntToStr(Chart1.SeriesCount-1);
      CustomBarHeight := 30;
      BarWidthPercent := 200;
      Marks.Style := smsLabelValue;
    end;
  end;

  Chart1[0].Color := clRed;
  Chart1[1].Color := clBlue;
  Chart1[2].Color := clGreen;

  Chart1[0].Add(123, 'S0_1');
  Chart1[1].Add(456, 'S1_1');
  Chart1[2].Add(789, 'S2_1');

  Chart1[0].Add(456, 'S0_2');
  Chart1[1].Add(123, 'S1_2');
  Chart1[2].Add(987, 'S2_2');
Project1_2019-04-08_14-50-09.png
Project1_2019-04-08_14-50-09.png (14.48 KiB) Viewed 27696 times
A group of series in TeeChart only groups series objects to show them in the legend, activate or deactivate a set (a group) of series or to show groups instead of series in the chart editor.
The series groups in TeeChart don't modify the drawing of the bars/points. The bars and points are always draw respecting their values. In the case of bar series, all the values with the same xvalue (yvalues for horizbar series) are drawn side by side (when using the default mbSide MultiBar style), but these are not "series groups".

On the other hand, note toy cannot cast a string to a THorizBarSeries. Check this.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Tue Apr 09, 2019 1:09 am

New using groups which supposedly don't group. Not sure about that.

Code: Select all

type
  TForm1 = class(TForm)
    Chart1: TChart;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Series1, series2, series3 : THorizBarSeries;
  BaseSeries                : THorizBarSeries;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var g1,g2,g3:TSeriesGroup;
    Position : TMultibar;

begin
  Position := mbSide;
  Chart1.Pages.MaxPointsPerPage := 10;
  BaseSeries := THorizBarSeries.Create(Self);
  BaseSeries.CustomBarHeight := 15;
  BaseSeries.MultiBar := Position;
  BaseSeries.ParentChart := Chart1;
  BaseSeries.MultiBar := Position;
  BaseSeries.Depth := 100;
  BaseSeries.BarWidthPercent := 20;
  BaseSeries.Marks.Style := smsValue;
  BaseSeries.OffsetPercent := 50;

  Series1 := BaseSeries;
  Series2 := BaseSeries;
  Series3 := BaseSeries;

  Chart1.AddSeries(Series1);
  Chart1.AddSeries(Series2);
  Chart1.AddSeries(Series3);



  g3:=Chart1.SeriesList.AddGroup('Table 3');
  g3.Series.Add(Series3);
  with series3  do
    begin
      AddBar(854,'Table 3 Reads',clLime);
      AddBar(622,'Table 3 Writes',clRed);
      AddBar(815,'Table 3 Fetches',clBlue);
    end;

  g2:=Chart1.SeriesList.AddGroup('Table 2');
  g2.Series.Add(Series2);
  with series2 do
    begin
      AddBar(212,'Table 2 Reads',clLime);
      AddBar(89,'Table 2 Writes',clRed);
      AddBar(246,'Table 2 Fetches',clBlue);
    end;

  g1:=Chart1.SeriesList.AddGroup('Table 1');
  g1.Series.Add(Series1);
  with Series1 do
    begin
      AddBar(516,'Table 1 Reads',clLime);
      AddBar(156,'Table 1 Writes',clRed);
      AddBar(6366,'Table 1 Fetches',clBlue);
    end;

  end;

end.
And using groups (Does it work?)
gNewSeries.png
gNewSeries.png (10.88 KiB) Viewed 27689 times
The problem of course is to dynamically fill with varying number of table/series and the associated data.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to figure out TeeChart

Post by Yeray » Tue Apr 09, 2019 12:00 pm

Hello,

In this example you've posted, both BaseSeries, Series1, Series2 and Series3 point to the same series. So you are adding just one series and adding all the points to the same.

I have the impression that, what you would expect groups to be, is just the ValueIndex in the TeeChart Series.
Here using the same values with three HorizBarSeries:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=False;
  Chart1.Pages.MaxPointsPerPage := 10;
  Chart1.Legend.Visible:=False;

  for i:=0 to 2 do
  begin
    with Chart1.AddSeries(THorizBarSeries) as THorizBarSeries do
    begin
      CustomBarHeight := 25;
      OnGetMarkText:=SeriesMarkText;
    end;
  end;

  with Chart1[2] as THorizBarSeries do
  begin
    Title:='Table 3';
    AddBar(854,'Reads',clLime);
    AddBar(622,'Writes',clRed);
    AddBar(815,'Fetches',clBlue);
  end;

  with Chart1[1] as THorizBarSeries do
  begin
    Title:='Table 2';
    AddBar(212,'Reads',clLime);
    AddBar(89,'Writes',clRed);
    AddBar(246,'Fetches',clBlue);
  end;

  with Chart1[0] as THorizBarSeries do
  begin
    Title:='Table 1';
    AddBar(516,'Reads',clLime);
    AddBar(156,'Writes',clRed);
    AddBar(6366,'Fetches',clBlue);
  end;
end;

procedure TForm1.SeriesMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: string);
begin
  MarkText:=Sender.Title + ': ' + MarkText;
end;
Project1_2019-04-09_14-20-15.png
Project1_2019-04-09_14-20-15.png (18.97 KiB) Viewed 27676 times
If you still find problems with it, please post an image showing how would you expect the chart to be and I will try to prepare an example.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Wed Apr 10, 2019 12:37 pm

Got actual program working with groups

Code: Select all

function TfrmSQLPlanalyzer.UpdateChartData(pSeriesData : TSeriesData): boolean;
var
  Position : TMultiBar;
  i,iSeriesCount, ibarWidth : integer;
  labelsWidth : integer;
  lAxis       : TChartAxis;
  newGroup    : TSeriesGroup;
  newSeries   : THorizBarSeries;
  iSeriesNum  : integer;
  valTable    : String;
  valFetches  : Integer;
  sFetches    : String;
  valWrites   : integer;
  sWrites     : String;
  valReads    : integer;
  sReads      : String;

  aTableName  : String;
  aFetches    : String;
  aWrites     : String;
  aReads      : String;

  bTable1     : boolean;
  bTable2     : boolean;
  bTable3     : boolean;

begin
 if StatsChart = nil then
   begin
     StatsChart := TChart.Create(self);//Parented(self.tshtChart.Handle); //frmSQLPlanalyzer.tshtChart.Handle);
     StatsChart.Parent := frmSQLPlanalyzer.tshtChart;
     with StatsChart do
        begin
          RemoveAllSeries;
          Left := 12;
          Top := 60;
          Width := 800;
          Height := 390;
          sFetches := 'Fetches';
          sWrites := 'Writes';
          sReads  := 'Reads';
          Pages.MaxPointsPerPage := 10;
          AllowPanning := pmNone; //Vertical;
          Panning.MouseWheel := pmwNormal;
          BackWall.Brush.Style := bsClear;
          Gradient.EndColor := clWhite;
          Gradient.StartColor := clBtnFace;
          Legend.DividingLines.Visible := True;
          Legend.Inverted := False;
          Legend.LegendStyle := lsValues;
          Legend.MaxNumRows := 10;
          Legend.Shadow.Color := clBtnShadow;
          Legend.Shadow.HorizSize := 0;
          Legend.Shadow.VertSize := 0;
          Legend.TopPos := 0;
          Legend.LeftPercent := 100;
          Legend.Visible := True;
          MarginBottom := 0;
          MarginLeft := 0;
          MarginRight := 2;
          MarginTop := 0;
          Title.Text.Text := 'Database - Table Data';
          LeftAxis.ExactDateTime := False;
          LeftAxis.LabelsMultiLine := False;
          LeftAxis.TitleSize := 10;
          ScrollMouseButton := mbMiddle;
          Title.Font.Color := clBlack;
          Title.Font.Height := -19;
          Title.Font.Style := [fsBold];
          BottomAxis.Title.Caption := 'Fetches-Writes-Reads';
          Chart3DPercent := 0;
          LeftAxis.LabelsOnAxis := False;
          LeftAxis.LabelsSeparation := 0;
          LeftAxis.LabelStyle := talText;
          View3D := False;
          View3DWalls := False;
          BevelInner := bvLowered;
          BorderWidth := 2;
          TabOrder := 0;
          Anchors := [akLeft, akTop, akRight, akBottom];
          Position := mbSide;
          lAxis := StatsChart.LeftAxis;
          labelsWidth := StatsChart.Axes.Left.MaxLabelsWidth;
          ibarWidth := 20;
          BaseGroup := TSeriesGroup.Create(StatsChart.SeriesGroups);
          BaseSeries := THorizBarSeries.Create(StatsChart);
          AddSeries(BaseSeries);
          BaseSeries.MultiBar := Position;
          BaseSeries.Depth := 100;
          BaseSeries.CustomBarHeight := 15;
          BaseSeries.OffsetPercent := 5;
          BaseSeries.BarWidthPercent := ibarWidth;
          BaseSeries.Marks.Style := smsValue;
          BaseSeries.Marks.Arrow.Visible := False;
          BaseSeries.Marks.Callout.Arrow.Visible := False;
          BaseSeries.SideMargins := False;
          BaseSeries.XValues.Name := 'Bar';
          BaseSeries.XValues.Order := loNone;
        end;
   end;

 with pSeriesData1^ do
   begin
     if ((pSeriesData1 <> nil) and (pSeriesData1.bValid = true))then
       begin
         iSeriesNum := pSeriesData1.iSeriesNumber;
         newGroup  := BaseGroup;
         newGroup.DisplayName := 'group' + IntToStr(iSeriesNum);
         newSeries := BaseSeries;
         newSeries.Name := 'Series' + IntToStr(iSeriesNum);

         {Collect the data for the series}
         valTable := pSeriesData1.stabName1  + ': Fetches';
         valFetches := pSeriesData1.ivFetches1;
         valWrites := pSeriesData1.ivWrites1;
         valReads := pSeriesData1.ivReads1;
         aTableName := valTable;//'TableName_' + IntToStr(iSeriesNum);
         aFetches := sFetches {_' + IntToStr(iSeriesNum)} + ' : ' + intToStr(valFetches);
         aWrites := sWrites {_' + IntToStr(iSeriesNum)} + ' : ' + intToStr(valWrites);
         aReads := sReads {_' + IntToStr(iSeriesNum)}+ ' : ' + intToStr(valReads);
       end;
   end;

 {Update the Chart with the series data}
 with StatsChart do
   begin
     newGroup := StatsChart.SeriesList.AddGroup(newGroup.Name);
     newGroup.Series.Add(newSeries);
     with newSeries do
       begin
         AddBar(valReads,aReads,clYellow);
         AddBar(valWrites,aWrites,clLime);
         AddBar(valFetches,aTableName,clBlue);
       end;
     Pages.MaxPointsPerPage := ((iSeriesNum + 2)*3);
   end;
 Result := True;
end;
GoodChart_4-10-19.png
GoodChart_4-10-19.png (26.1 KiB) Viewed 27664 times
Now to figure out how to get rid of all the space between bars with only single table.
GoodChar_SingleTable_4-10-19.png
GoodChar_SingleTable_4-10-19.png (14.11 KiB) Viewed 27664 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to figure out TeeChart

Post by Yeray » Thu Apr 11, 2019 11:42 am

Hello,
tultalk wrote:
Wed Apr 10, 2019 12:37 pm
Got actual program working with groups
Great!
tultalk wrote:
Wed Apr 10, 2019 12:37 pm
Now to figure out how to get rid of all the space between bars with only single table.
You may be clearing some series and the chart keeps reserving space for them to be drawn.
Try hiding the empty series.
If you still find problems with it, please arrange a simple example we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Thu Apr 11, 2019 12:26 pm

You say: You may be clearing some series and the chart keeps reserving space for them to be drawn.
Try hiding the empty series.


If you still find problems with it, please arrange a simple example we can run as-is to reproduce the problem here.

Not so simple as it is connecting to interbase database for data.

Here is work program where I test dfm attached with zip extension Change to dfm

Code: Select all

unit gSeries_Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VclTee.TeeGDIPlus, VCLTee.TeEngine,
  Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series, Vcl.StdCtrls,
  Vcl.Buttons;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    btnFillChart: TBitBtn;
    procedure btnFillChartClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Chart1 : TChart;
  newGroup       : TSeriesGroup;
  newSeries      : THorizBarSeries;
  series0, Series1, series2, series3,series4 : THorizBarSeries;
  BaseSeries : THorizBarSeries;
  BaseGroup  : TSeriesGroup;
  valTable  : String; //TChartValueList;
  valFetches : Integer;//TChartValueList;
  valWrites : integer; // TChartValueList;
  namWrites :String;
  valReads  : integer; //TChartValueList;
  namReads  : String;
implementation

{$R *.dfm}

procedure TForm1.btnFillChartClick(Sender: TObject);
var
    Position       : TMultibar;
    i,iCount       : integer;
begin
  Chart1 := TChart.Create(Panel1);
  Chart1.Parent := Panel1;
  Chart1.Height := 514;
  Chart1.Width := 745;
  Chart1.View3D := false;
//  Chart1.Pages.MaxPointsPerPage := 15;
  Position := mbSideAll;

  namWrites := 'Writes';
  namReads  := 'Reads';

  BaseGroup := TSeriesGroup.Create(Chart1.SeriesGroups);
  BaseSeries := THorizBarSeries.Create(Chart1);
  Chart1.AddSeries(BaseSeries);

  BaseSeries.CustomBarHeight := 15;
  BaseSeries.MultiBar := Position;
  BaseSeries.ParentChart := Chart1;
  BaseSeries.Depth := 100;
  BaseSeries.CustomBarHeight := 20;
  BaseSeries.Marks.Style := smsValue;
  BaseSeries.OffsetPercent := 0;

{Create data}
  iCount := 0;
  for i := iCount downto 0 do
    begin
      newGroup := BaseGroup;
      newGroup.DisplayName := 'group' + IntToStr(i);
      newSeries := BaseSeries;
      newSeries.Name := 'Series' + IntToStr(i);

      if i = 0 then
        begin
          valTable := 'Table1 Fetches';
          valFetches := 6993;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 1  then
        begin
          valTable := 'Table2 Fetches';
          valFetches := 212;
          valWrites := 89;
          valReads := 146;
        end
      else if i = 2  then
        begin
          valTable := 'Table3 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 3  then
        begin
          valTable := 'Table4 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 4  then
        begin
          valTable := 'Table5 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end;

 {Popuilate chart}
        begin
          with Chart1 do
            begin
                begin
                  newGroup := Chart1.SeriesList.AddGroup(newGroup.Name);
                  newGroup.Series.Add(newSeries);
                  with newSeries do
                    begin
                      AddBar(valReads,namReads,clYellow);
                      AddBar(valWrites,namWrites,clLime);
                      AddBar(valFetches, valTable,clBlue);
                    end;
                end;
              Pages.MaxPointsPerPage := ((iCount + 1)*3);
            end;
        end;
    end;
end;
end.
Produces:
gSeries-SpacedOutSeries.png
gSeries-SpacedOutSeries.png (11.76 KiB) Viewed 27644 times
Attachments
gSeries_Unit1.zip
(663 Bytes) Downloaded 803 times

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Fri Apr 12, 2019 12:47 pm

So from reading, one way would be to fill chart with series and hide them?
How would one hide the series?

Secondly:"The SideMargins property controls if first and last displayed Bar will be separated from the Chart rectangle. By default, margins are set to half the sum of all Bar Series bar widths."

By default, margins are set to half the sum of all Bar Series bar widths. Half the sum of all Bar Series bar widths? Looks to me like is sets it at
half of Bar Series bar width, not half the sum of all???

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Fri Apr 12, 2019 2:49 pm

Hi:

I set

Code: Select all

     Chart1.Axes.Left.SetMinMax(-iCount -4,iCount+4); <--------------------------------------
             for i := iCount downto 0 do ,,,,,
and

Code: Select all

                      SideMargins := true; <---------------------------------------------
                      AddBar(valReads,namReads,clYellow);
                      AddBar(valWrites,namWrites,clLime);
                      AddBar(valFetches, valTable,clBlue);
The spacing is Ok (Single series centered) but multiple series up to high concealing upper series.
I thought side margins controlled that so entire series would be centered?
Setting Chart1.AllowPanning := pmNone; does not help except prevent scrolling to the hidden series.
gSeries-Space-SingleSeries-Centered.png
gSeries-Space-SingleSeries-Centered.png (11.4 KiB) Viewed 27635 times
gSeries-Space-NotCentered.png
gSeries-Space-NotCentered.png (30.4 KiB) Viewed 27635 times

tultalk
Newbie
Newbie
Posts: 13
Joined: Wed Mar 20, 2019 12:00 am

Re: Trying to figure out TeeChart

Post by tultalk » Fri Apr 12, 2019 7:59 pm

Works fine now. Acceptable spacing etc. Tested w 1-> 8 series

Code: Select all

procedure TForm1.btnFillChartClick(Sender: TObject);
var
    Position       : TMultibar;
    i,iCount       : integer;
    yMin, yMax : integer;
begin
  Chart1 := TChart.Create(Panel1);
  Chart1.Parent := Panel1;
  Chart1.Height := 514;
  Chart1.Width := 745;
  Chart1.View3D := false;
  Chart1.AllowPanning := pmNone;
  Position := mbSide;

  namWrites := 'Writes';
  namReads  := 'Reads';

  BaseGroup := TSeriesGroup.Create(Chart1.SeriesGroups);
  BaseSeries := THorizBarSeries.Create(Chart1);
  Chart1.AddSeries(BaseSeries);
  BaseSeries.SideMargins := True;
  BaseSeries.CustomBarHeight := 15;
  BaseSeries.MultiBar := Position;
  BaseSeries.ParentChart := Chart1;
  BaseSeries.Depth := 100;
  BaseSeries.CustomBarHeight := 10;
  BaseSeries.Marks.Style := smsValue;
  BaseSeries.OffsetPercent := 0;

  {Create data}
  iCount := 8;  {<-------------------------}
  yMin := 0;
  yMax := 6;
  Chart1.Axes.Left.SetMinMax((-(iCount +2)) + yMin,(iCount*3)+ yMax);
  for i := iCount downto 0 do
    begin
      newGroup := BaseGroup;
      newGroup.DisplayName := 'group' + IntToStr(i);
      newSeries := BaseSeries;
      newSeries.Name := 'Series' + IntToStr(i);

      if i = 0 then
        begin
          valTable := 'Table1 Fetches';
          valFetches := 6993;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 1  then
        begin
          valTable := 'Table2 Fetches';
          valFetches := 212;
          valWrites := 89;
          valReads := 146;
        end
      else if i = 2  then
        begin
          valTable := 'Table3 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 3  then
        begin
          valTable := 'Table4 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 4  then
        begin
          valTable := 'Table5 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 5  then
        begin
          valTable := 'Table6 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 6  then
        begin
          valTable := 'Table7 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 7  then
        begin
          valTable := 'Table8 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end
      else if i = 8  then
        begin
          valTable := 'Table9 Fetches';
          valFetches := 815;
          valWrites := 153;
          valReads := 627;
        end;

        {Popuilate chart}
        begin
          with Chart1 do
            begin
                begin
                  newGroup := Chart1.SeriesList.AddGroup(newGroup.Name);
                  newGroup.Series.Add(newSeries);
                  with newSeries do
                    begin
                      SideMargins := true;
                      AddBar(valReads,namReads,clYellow);
                      AddBar(valWrites,namWrites,clLime);
                      AddBar(valFetches, valTable,clBlue);
                    end;
                end;
              Pages.MaxPointsPerPage := ((iCount + 1)*3);
            end;
        end;
     end;
end;
end.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Trying to figure out TeeChart

Post by Yeray » Mon Apr 15, 2019 7:17 am

tultalk wrote:
Fri Apr 12, 2019 7:59 pm
Works fine now. Acceptable spacing etc. Tested w 1-> 8 series
Great!
Don't hesitate to let us know if still find any problem or doubt with it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply