Hiding series in Chart Editor

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Errol
Newbie
Newbie
Posts: 10
Joined: Mon Oct 15, 2007 12:00 am

Hiding series in Chart Editor

Post by Errol » Thu Aug 30, 2012 1:16 am

To better control symbol placement for dense data sets, I create a LineSeries, a FastLineSeries and a PointSeries for each set of data. The LineSeries is used only for the legend, while the other two series show the line and the points respectively. I have a lot of custom code to format the resulting graph, but also make ChartEditor available so advanced users can "tweak" the graph to their own preference.
When I open ChartEditor, all 3 series are displayed. I have attempted to hide the FastLine and Point series with the following code:
procedure TformMain.acChartEditorExecute(Sender: TObject);
begin
PBQuickGraphMain.HideFastPointSeriesInEditor;
ChartEditor.Execute;
end;

procedure TPBQuickGraph.HideFastPointSeriesInEditor;
var
i: integer;

begin
for i:=0 to Dependent1Collection.SeriesList.Count-1 do
begin
TUnitFastLineSeries(Dependent1Collection.SeriesList.Objects).ShowInEditor := false;
TUnitPointSeries(Dependent1Collection.SeriesList.Objects).ShowInEditor := false;
end;
for i:=0 to Dependent2Collection.SeriesList.Count-1 do
begin
TUnitFastLineSeries(Dependent2Collection.SeriesList.Objects).ShowInEditor := false;
TUnitPointSeries(Dependent2Collection.SeriesList.Objects).ShowInEditor := false;
end;
end;

The code is unit-aware (e.g. with conversions between m and feet, etc). Dependent1Collection and Dependent2Collection are related to two dependent axes, each plotting data of a separate unit type.

This code has no effect on ChartEditor as seen in attachment. Any ideas what ShowInEditor fails would be appreciated.
Attachments
Chart_Editor_Example.jpg
Chart_Editor_Example.jpg (101.05 KiB) Viewed 7082 times

Errol
Newbie
Newbie
Posts: 10
Joined: Mon Oct 15, 2007 12:00 am

Re: Hiding series in Chart Editor

Post by Errol » Thu Aug 30, 2012 1:22 am

Further to my previous submission, I see that the HideInEditor code does not hide the FastLine and Point series but does hide the LineSeries. Without the code, all 3 series are shown in the editor.

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

Re: Hiding series in Chart Editor

Post by Yeray » Thu Aug 30, 2012 9:53 am

Hi,

I've made a simple example trying to reproduce your situation (all in a single unit) and it seems it works fine for me here, if I understood correctly what you are trying to achieve.

Code: Select all

uses Series, TeeEdit;

procedure TForm1.FormCreate(Sender: TObject);

  procedure CopySettings(FromSeries, ToSeries: TChartSeries);
  begin
    ToSeries.Title:=FromSeries.Title;
    ToSeries.Color:=FromSeries.Color;
    ToSeries.ShowInEditor:=false;
  end;

var i, count: Integer;
begin
  Chart1.View3D:=false;

  for i:=0 to 4 do
  begin
    with Chart1.AddSeries(TLineSeries) as TLineSeries do
    begin
      FillSampleValues;
      Pointer.Visible:=true;
      ShowInLegend:=false;
    end;
  end;
  Chart1[0].Title:='Temperatura del pozo';
  Chart1[1].Title:='Well Pressure';
  Chart1[2].Title:='WHP';
  Chart1[3].Title:='Cased Depth';
  Chart1[4].Title:='Major Feed';

  count:=Chart1.SeriesCount;
  for i:=0 to count-1 do
  begin
    CopySettings(Chart1[i], Chart1.AddSeries(TFastLineSeries));
    CopySettings(Chart1[i], Chart1.AddSeries(TPointSeries));
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TChartEditor.Create(Self) do
  begin
    Chart:=Chart1;
    Execute;
  end;
end;
test.png
test.png (28.89 KiB) Viewed 7040 times
The series with data, TLineSeries, are drawn in the chart and shown in the editor but hidden in the legend
The series without data, TFastLineSeries and TPointSeries copied (just the title and the color) from the TLineSeries, are hidden in the editor but shown in the legend.
Isn't it what you are trying to do?
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

Errol
Newbie
Newbie
Posts: 10
Joined: Mon Oct 15, 2007 12:00 am

Re: Hiding series in Chart Editor

Post by Errol » Thu Aug 30, 2012 11:47 pm

Hi Yeray

Thanks for your reply. Note that all 3 series have the same data and settings (line color, symbol, line type, etc) as appropriate. The LineSeries is used only to show the legend - its DataSource is set to nil just before the chart is drawn so no data is plotted. The legends of the FastLineSeries and the PointSeries are hidden but the data is plottted. Doing it this way means that I can control the point frequency (for example draw every 10th symbol in the series) while a FastLineSeries is plotted correctly for non-solid lines and dense data, at least for line width = 0 or 1.

However I have found the source of the problem. I had created the set of 3 series as objects in the same Series List (TStringList), as follows:
Dependent1Collection.SeriesList.AddObject(sTitle,TUnitLineSeries.Create(Owner));
Dependent1Collection.SeriesList.AddObject(sTitle,TUnitFastLineSeries.Create(Owner));
Dependent1Collection.SeriesList.AddObject(sTitle,TUnitPointSeries.Create(Owner));

Using 3 separate series lists as follows solved the problem:
Dependent1Collection.SeriesList.AddObject(sTitle,TUnitLineSeries.Create(Owner));
Dependent1Collection.SeriesListF.AddObject(sTitle,TUnitFastLineSeries.Create(Owner));
Dependent1Collection.SeriesListP.AddObject(sTitle,TUnitPointSeries.Create(Owner));

Thanks and regards

Errol

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

Re: Hiding series in Chart Editor

Post by Yeray » Fri Aug 31, 2012 12:11 pm

Hi Errol,

I'm glad to hear you found how to make it work :)
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