Hide series in chartlistbox lazarus / 55-TAChart ---------------------------------------------------------------------- madepabloh · 2014-09-09 22:08 I have a chart showing some datetime vs value line series as well as constantline series at selected dates. Everything works well, and the series are shown in a chartlistbox. However, i have three issues i would like to solve, although i don´t imagine how to do it. 1) I would like to hide the constant series from the chartlist box, but still show them in the chart. I tried "legend.visible := true", but i see now that it affects to the legend, not the chartlistbox. I don't know how to do it. 2) I would like to show/hide the constantline series in the chart (all at the same time) by the use of a checkbox or a radiobutton or a button. I suposse that first thing to do is to search for all the series in the chart, discover which type of serie it is, and then, activate or disactivate it. Something like this: Code: [Select]procedure TMain.CheckBox5Change(Sender: TObject); var   ser: TConstantLine; begin   if CheckBox5.Checked = True then     begin       for i:= 0 to Charteng1.Series.Count-1 do         begin           if Charteng1.Series.Items[i] = ser then ChartEng1.Series.Items[i].Active:= True;         end;     end   else     begin       for i:= 0 to Charteng1.Series.Count-1 do         begin           if Charteng1.Series.Items[i] = ser then ChartEng1.Series.Items[i].Active:= False;         end;     end; end; This code compiles, but evidently it is not correct (do nothing). How could i see which kind of series is each one in the chart? 3) I would like to show only one line representing all the constat series in the legend. I suposse i should select one of the constantline serie, and to assing "legend.Visible := True", meanwhile for the other constant series they should be setted to false. How could i do this? I mean, the option i have on mind is to search for the first constantline serie in the chartlist box to made it visible in the legent and hide the other constantlines in the legend. However, since in the first task i will remove (hopefully) those series from the chartlistbox, i should search directly in the chart... but then i am back to problem i have in the task 2. How to search for the type of series is each serie in the chart? i appreciate any tip to help me to solve those issues. thanks! ---------------------------------------------------------------------- wp · 2014-09-09 22:26 (1) There's a special event for the ChartListbox that is fired when a series is added: OnAddSeries. It has a "Skip" parameter which you can set to false in order to skip the series: Code: [Select]procedure TForm1.ChartListbox1AddSeries(ASender: TChartListbox;   ASeries: TCustomChartSeries; AItems: TChartLegendItems; var ASkip: Boolean); begin   if ASeries is TConstantLine then ASkip := true;  // this hides all constant line series from the listbox, or   if ASeries.Index = 0 than ASkip := true;   // this hide the series with index 0 from the listbox, etc. end; (2) No, this code does not work: the local variable "ser" is not initialized. Instead of looking for series variables I'd look for the class: Code: [Select]procedure TMain.CheckBox5Change(Sender: TObject); begin   for i:= 0 to Charteng1.Series.Count-1 do     if ChartEng1.Series[i] is TConstantLine then ChartEng1.Seres[i].Active := Checkbox5.Checked; end; (3) To search for a given series "type" use the "is" operator along with the class name: Code: [Select]  if Chart1.Series[i] is TBarSeries then ...  // true for all bar series   if Chart1.Series[i] is TBasicPointSeries then ... // true for all bar series, line series, area series since they inherit from TBasicPointSeries ---------------------------------------------------------------------- madepabloh · 2014-09-09 22:33 You are perfect (as ever) @WP!! I will study your code, not only to apply, but to learn with this. Thanks so much. I really appreciate. Thanks!