Open TChartEditor on a particular series

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Open TChartEditor on a particular series

Post by sde » Thu Jun 09, 2016 9:41 pm

Hi,

I'm sorry if this should be really obvious but for some reason I can't figure it out. I have a button to launch the TChartEditor for a particular series. I am using the TreeView of editor and have hidden all of the tabs except for Series and themes. Two questions.

1) There doesn't seem to be a way to hide the themes tab. Is there a way to do this?

2) I can't find a way to have the particular series I want to edit already selected in the tree under the series node. It opens with the Series Node selected and then I have to expand it to click on the series. Is there a way to have the editor launch with the series I want to edit already selected?

Thanks!
SDE

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

Re: Open TChartEditor on a particular series

Post by Yeray » Fri Jun 10, 2016 3:30 pm

Hello,

This seems to work as you describe:

Code: Select all

uses Series, TeeEditCha;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  ComboBox1.Clear;

  for i:=0 to 5 do
  begin
    Chart1.AddSeries(TBarSeries).FillSampleValues;
    ComboBox1.Items.Add('Series'+IntToStr(i+1));
  end;

  ComboBox1.ItemIndex:=0;
end;

procedure TForm1.Button1Click(Sender: TObject);
var myEditor: TChartEditForm;
begin
  myEditor:=TChartEditForm.Create(Self);
  myEditor.Chart:=Chart1;
  myEditor.CheckHelpFile;
  TeeTranslateControl(myEditor,[myEditor.LBSeries]);

  myEditor.TheHiddenTabs:=[{cetMain,}cetGeneral,cetAxis,cetTitles,cetLegend,cetPanel,cetPaging,cetWalls,
  cet3D,cetSeriesGeneral,cetSeriesMarks,cetAllSeries,cetSeriesData,cetExport,
  cetExportNative,cetTools,cetAnimations,cetPrintPreview];
  try
    myEditor.TheEditSeries:=Chart1[ComboBox1.ItemIndex];
    myEditor.ShowModal;
  finally
    myEditor.Free;
  end;
end;
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

sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Re: Open TChartEditor on a particular series

Post by sde » Fri Jun 10, 2016 7:42 pm

Hi,

Thanks for that solution. I just ran it and it is almost perfect. It doesn't include the Format Tab which is the one I was really after. Is there a way to add that?

Also, I was going about it in a completely different way. In the code you provided, you use the object TChartEditForm from the Unit TeeEditCha, and I was using the object TChartEditor from the unit TeeEdit. In TChartEditor, there is no cetThemes enumerated type to hide the themes tab. Also, in TChartEditor there is no "TheEditSeries" property where you can set the selected series. Can you please explain the difference between TChartEditor and TChartEditForm and why someone may want to use one over the other?

SDE

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

Re: Open TChartEditor on a particular series

Post by Yeray » Mon Jun 13, 2016 8:47 am

Hello,
sde wrote:Thanks for that solution. I just ran it and it is almost perfect. It doesn't include the Format Tab which is the one I was really after. Is there a way to add that?
The format tab is a different editor that depends on the series type. You can add the units for the series you are using to show this format tab. Ie: TeeBarEdit, TeeAreaEdit.
Or you can add the EditChar unit, that adds some editors for you.
sde wrote:Also, I was going about it in a completely different way. In the code you provided, you use the object TChartEditForm from the Unit TeeEditCha, and I was using the object TChartEditor from the unit TeeEdit. In TChartEditor, there is no cetThemes enumerated type to hide the themes tab. Also, in TChartEditor there is no "TheEditSeries" property where you can set the selected series. Can you please explain the difference between TChartEditor and TChartEditForm and why someone may want to use one over the other?
TChartEditor uses a TChartEditForm internally. So this is basically the same I did in my last post:

Code: Select all

uses TeeEdit;

procedure TForm1.Button2Click(Sender: TObject);
var myEditor: TChartEditor;
begin
  myEditor:=TChartEditor.Create(Self);
  myEditor.Chart:=Chart1;
  myEditor.Series:=Chart1[ComboBox1.ItemIndex];
  myEditor.TreeView:=true;
  myEditor.HideTabs:=[cetGeneral,cetAxis,cetTitles,cetLegend,cetPanel,cetPaging,cetWalls,
  cet3D,cetSeriesGeneral,cetSeriesMarks,cetAllSeries,cetSeriesData,cetExport,
  cetExportNative,cetTools,cetAnimations,cetPrintPreview];

  myEditor.Execute;
end;
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

sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Re: Open TChartEditor on a particular series

Post by sde » Tue Jun 21, 2016 5:05 pm

Hello,

Thank you for that code. It works great, but I'm still having an issue. I'm not sure what's going on and am hoping you can point me in the right direction.

When I run your code in a brand new project (created in Delphi 10), it works exactly as you describe. However, when I add it to my existing project (originally created in Delphi 7), I get a "Themes" tab in the TChartEditor (please see attached screenshot). So I figured it had to be something with my project settings. I've gone through and made all the same changes to the new project (disabled runtime themes, added styles, etc). I've compared the .dpr line by line and also the form code for the TChart. They are exactly the same. Yet my old project has the Themes tab and the new one doesn't. Do you know what triggers that themes tab to appear in the editor? I can't send you my project because it's huge and proprietary, so I need to troubleshoot through discussion only. What I need is to either prevent the Themes node from appearing in the tree view to begin with, or a way to hide the tab (there is no cetThemes...).

Thanks!
SDE
Attachments
Screenshot.jpg
Screenshot.jpg (58.96 KiB) Viewed 2187 times

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

Re: Open TChartEditor on a particular series

Post by Yeray » Wed Jun 22, 2016 10:35 am

Hello,

You may be loading TeeThemeEditor at some unit in your project. Note TeeThemeEditor is used in a few units: TeeChart, TeeChartPro, TeeDesignOptions and TeeEditPro. And some of these units are used in others, ie TeeChartActions and TeeComma units use TeeEditPro.
sde wrote:(there is no cetThemes...).
I think that's not an option because this tab is included by a method called in TeeThemeEditor initialization.

An option would be to call this in your project to clear any tab added by this method:

Code: Select all

TeeOnShowEditor.Clear;
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

sde
Newbie
Newbie
Posts: 21
Joined: Fri Jun 21, 2013 12:00 am

Re: Open TChartEditor on a particular series

Post by sde » Thu Jun 23, 2016 4:55 pm

Yeray, you're a genius! I removed the TeeComma unit that I wasn't even using anymore and voila, the themes tab went away. Thanks so much for troubleshooting with me!

SDE

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

Re: Open TChartEditor on a particular series

Post by Yeray » Tue Jun 28, 2016 7:08 am

Hello,

I'm glad to hear I was of any help!
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