Page 1 of 1

Series created by crosstab: SeriesMouseEnter event?

Posted: Mon Aug 17, 2015 5:05 pm
by 16475083
Hi,

Is it possible to establish a SeriesMouseEnter event for a series that is created by a crosstab and therefore doesn't exist until runtime?

I have one series at design time and at runtime, through the actions of the crosstab, it morphs into a total of 6 series. I have a SeriesMouseEnter & SeriesMouseLeave for Series1 and I want the same events to fire for each of the other series.

How do I do this?

Thanks.

Re: Series created by crosstab: SeriesMouseEnter event?

Posted: Tue Aug 18, 2015 11:58 am
by yeray
Hello,

When you use TDBCrossTabSource, the series are created when you activate the dataset associated to it; it can be at runtime but also at designtime.
If you are activating it at runtime, you can loop the series in the chart after it to assign the events for the new series. Ie:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Table1.Active:=true;

  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].OnMouseEnter:=SeriesMouseEnter;
    Chart1[i].OnMouseLeave:=SeriesMouseLeave;
  end;
end;

procedure TForm1.SeriesMouseEnter(Sender: TObject);
begin
  with Sender as TChartSeries do
    Caption:='Series ' + Title + ' entered';
end;

procedure TForm1.SeriesMouseLeave(Sender: TObject);
begin
  with Sender as TChartSeries do
    Caption:='Series ' + Title + ' left';
end;