Forum > TAChart

how to bring marks to front

(1/2) > >>

Muso:
I often have the case that a mark to a line series is covered by other series, see the attached screenshot.

Is there a way to force that notes are painted topmost/as last part when the chart is painted?

wp:
The marks are drawn along with the series. Therefore, the marks of the series drawn first may be overwritten by the series drawn later. But the drawing order of the series is determined by their ZPosition. So, if you want to fully see the marks of one particular series you simply must exchange the ZPosition of that series with the ZPosition of the top-most series. The only pre-requisite is that the series have a ZPosition different from the default 0.

You can even merge this into the OnPointClick handler of the TDatapointMarksClickTool (see the related sample code in the other thread; in the object inspector, set the ZPosition of the two series to 1 and 2, respectively):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.ChartToolset1DataPointMarksClickTool1PointClick(  ATool: TChartTool; APoint: TPoint);var  tool: TDatapointMarksClickTool;  ser1: TBasicChartSeries;  ser2: TBasicChartSeries;  i: Integer;  z1, z2: Integer;begin  tool := ATool as TDatapointMarksClickTool;   ser1 := tool.Series;  z1 := ser1.ZPosition;  z2 := -1;  for i := 0 to Chart1.SeriesCount-1 do    if (Chart1.Series[i] is TChartSeries) and        (Chart1.Series[i].ZPosition > z2) then    begin      ser2 := Chart1.Series[i];      z2 := ser2.ZPosition;    end;  if ser1 <> ser2 then  begin    ser1.ZPosition := z2;    ser2.ZPosition := z1;  end;   ShowMessage(Format('Series "%s" datapoint #%d clicked.', [(ser1 as TChartSeries).Title, tool.PointIndex]));end;

Muso:

--- Quote from: wp on July 27, 2022, 10:37:50 pm ---The marks are drawn along with the series. Therefore, the marks of the series drawn first may be overwritten by the series drawn later. But the drawing order of the series is determined by their ZPosition.

--- End quote ---
Thanks.
This is what I already tried, but the users want to see all marks by one view (no need to click to see them). In my example there are marks in the red and the blue series. Therefore changing the z-order does not solve the problem, since some notes will not be properly visible.

Therefore I thought that when the series are drawn first and then subsequently the marks, the issue should be solvable. If this is yet possible, this might be nice new feature  ;) .

Muso:

--- Quote from: wp on July 27, 2022, 10:37:50 pm ---You can even merge this into the OnPointClick handler of the TDatapointMarksClickTool

--- End quote ---

I gave this a try but get a crash when I try to access the Z-order see attached screenshot.
Is this a bug in the tool or do I have to do something special?

wp:

--- Quote from: Muso on July 27, 2022, 10:43:37 pm ---This is what I already tried, but the users want to see all marks by one view (no need to click to see them). In my example there are marks in the red and the blue series. Therefore changing the z-order does not solve the problem, since some notes will not be properly visible.
--- End quote ---
But there are other tools. The one which does not require a mouse press is the DatapointHintTool. Set its UseDefaultHintText to false to avoid a hint popping up. Then add the Z-reordering code into the OnHint event. This moves the series over which the mouse hovers to the top of the Z stack. Since in your case there are really lots of data points it should be almost impossible to miss a data point. If it is nevertheless, you should add the nptCustom option to the series' ToolTargets. This fires the OnHint event also when the mouse is over the interpolating line.


--- Quote from: Muso on July 27, 2022, 10:43:37 pm ---Therefore I thought that when the series are drawn first and then subsequently the marks, the issue should be solvable. If this is yet possible, this might be nice new feature  ;) .

--- End quote ---
This would mean that every series must be painted twice, once with its normal representation as lines, symbols, bars or whatever, and a second time with its labels only. This would double painting time, and charts almost completely covered by data points like in your case would draw even slower.

Navigation

[0] Message Index

[#] Next page

Go to full version