Search code examples
delphiteechart

Delphi 7 creating tChart Bar Pyramids / Cylinders at run-time


I know - Delphi 7 is prehistoric and tChart is not the best. But I must use them, so...

I can change the type of the series at run-time with

var cs: tChartSeries;
begin
  cs := chart.Series[0];
  ChangeSeriesType(cs, TBarSeries);
end;

And I discovered most of them: tLineSeries, tBarSeries, tAreaSeries, tPointSeries,...

Unfortunately, I cannot find how to set it to Bar/Pyramids and Bar/Cylinders. If I try to create them at run-time, I see that the wizard calls them "Style", but if I try

chart.series[0].Style := …

that property (of type tChartSeriesStyles) refers to different things. Just for future references and because it was hard to find:

TChartSeriesStyle = set of ( tssIsTemplate, 
                             tssDenyChangeType, 
                             tssDenyDelete, 
                             tssDenyClone, 
                             tssIsPersistent, 
                             tssHideDataSource ); 

So, the question is: how can I change, at run-time, a Delphi 7 tChart serie to "pyramid" and "cylinder"?

Thank you


Solution

  • You need to "cast" that serie to a tBarSeries and THEN you can change the value. Example:

    (c.series[0] as tBarSeries).BarStyle := bsPyramid;
    (c.series[1] as tBarSeries).BarStyle := bsCilinder;
    

    Since it looks like it's not documented anywhere, simply type "bs" and press CTRL-SPACE to see all the possible values.