I don't know. Of course I tested the idea, and it is working for my sample project
OK, my mistake, I used your code inside of
DataPointMarksClickToolBeforeMouseDown(ATool:...
But since I use the tool as
tool:= ATool as TDatapointMarksClickTool;
this cannot work.
However, I fixed this and implemented the z.order change code to a DataPintHintTool.
I debugged ans see that all my TLineSeries have the ZPosition 0.
I thought, OK, I set the current series to 0, the other visible ones to 1. But this made the other ones painted on top. Instead I have to paint my series in z-order 1, the others at 0.
Here is my final solution:
var
currentSeries, otherSeries : TBasicChartSeries;
i : integer;
begin
otherSeries:= nil;
currentSeries:= ATool.Series;
for i:= 0 to MainForm.SIXCH.SeriesCount - 1 do
begin
if (MainForm.SIXCH.Series[i] is TLineSeries)
and (MainForm.SIXCH.Series[i].Active)
then
begin
otherSeries:= MainForm.SIXCH.Series[i];
if currentSeries <> otherSeries then
otherSeries.ZPosition:= 0;
end;
end;
// repaint chart if necessary
if currentSeries.ZPosition < 1 then
begin
currentSeries.ZPosition:= 1;
MainForm.SIXCH.Invalidate;
end;
So there is a bug in the description of ZPosition, because it says, that to bring a series to front one should set it to 0.