problems with chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Friis
Newbie
Newbie
Posts: 26
Joined: Thu Oct 16, 2014 12:00 am

problems with chart

Post by Friis » Thu Sep 10, 2015 7:53 pm

Hi,

I'm having problems with the following code. It gives me the error "...EListError with message 'List index out of bounds (-1)'


I'm using TeeChart Pro 2013.09.131110 32 Bit VCL

1) it seems that disabling chart1.leftaxis.setminmax solves the problems but if I really need to setminmax...
2) If you disable chart1.leftaxis.setminmax, the problems disapperas but reappears when trying to zoom

Code: Select all


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, TeeGDIPlus, ExtCtrls, TeeProcs, TeEngine, Chart, Series;

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Chart1: TChart;
    Series1: THorizBarSeries;
    Procedure MakeLegendChart2;
    Procedure InitializeChart(const XChart:TChart);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.FormShow(Sender: TObject);
begin

InitializeChart(Chart1);
MakeLegendChart2;


Chart1.leftaxis.Title.Caption := 'Production Order Number';
Chart1.BottomAxis.Title.Caption := 'Number of Profiles';
Chart1.Title.Clear;
Chart1.Title.Text.Add('Production Order Number vs. Number of Profiles');
Chart1.Legend.Alignment := laBottom;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'Number of Profiles to be Produced';
    ShowInLegend := False;
    shadow.Visible := false;
    XValues.DateTime := false;
    Marks.Style := smsValue;
    Marks.Shadow.Visible := false;
    brush.Style := bsSolid;
    StackGroup := 2;
    Marks.Clip := true;
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'Number of Profiles Already Produced';
    ShowInLegend := false;
    shadow.Visible := false;
    XValues.DateTime := false;
    Marks.Style := smsValue;
    Marks.Shadow.Visible := false;
    brush.Style := bsDiagCross;
    seriescolor := clBlack;
    StackGroup := 1;
    Marks.Clip := true;
  end;

//=====================================

with Chart1[Chart1.SeriesCount -2] as THorizBarSeries do
  addxy(420,0,'P04567',clred);

with Chart1[Chart1.SeriesCount -2] as THorizBarSeries do
  addxy(210,1,'P04566',cllime);

chart1.LeftAxis.SetMinMax(-1,2);

end;

Procedure TForm1.InitializeChart(const XChart:TChart);
begin

with XChart do
begin
Color := clwhite;
Gradient.Visible := false;
BackWall.Color := clWhite;
BackWall.Gradient.Visible := false;
View3D := false;
BevelOuter := BvNone;

FreeAllSeries();
RemoveAllSeries;
Title.Text.Clear;
Legend.Shadow.Visible := false;
legend.Font.Size := 14;
legend.Symbol.Width := 50;
legend.Symbol.Squared := true;
end;
end;



Procedure TForm1.MakeLegendChart2;
begin

Chart1.Legend.Visible := true;
Chart1.Legend.Alignment := laBottom;
Chart1.Legend.LegendStyle := lsSeries;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040059';
    ShowInLegend := true;
    seriescolor := clred;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clred);
  end;


with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040170';
    ShowInLegend := true;
    seriescolor := clAQUA;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clAQUA);
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040190';
    ShowInLegend := true;
    seriescolor := clLIME;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clLIME);
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040198';
    ShowInLegend := true;
    seriescolor := clFuchsia;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clFuchsia);
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040211';
    ShowInLegend := true;
    seriescolor := clGray;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clGray);
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040193';
    ShowInLegend := true;
    seriescolor := clBlue;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clBlue);
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'ItemNumber 040182';
    ShowInLegend := true;
    seriescolor := clPurple;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clPurple);
  end;

with Chart1.AddSeries(THorizBarSeries.Create(self)) as THorizBarSeries do
  begin
    ParentChart := Chart1;
    Title := 'Amount Produced';
    ShowInLegend := true;
    brush.Style := bsDiagCross;
    seriescolor := clBlack;
    StackGroup := 0;
    MultiBar := mbStacked;

    with Chart1[Chart1.SeriesCount-1] as THorizBarSeries do
        addxy(1,-2,'',clBlack);
  end;

end;

end.


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

Re: problems with chart

Post by Yeray » Mon Sep 14, 2015 10:48 am

Hello,

I could reproduce the error with your code and TeeChart v2013.09 and v2014.10 but not with v2014.11 and neither with the actual version v2015.16.
So I'd suggest you to upgrade to the latest version.
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