Hello,
I see I have misread the initial post. The example I did was considering a threshold given by an horizontal line (an Y value) so I was calculating all the points crossing that line. Besides, I was changing the line color instead of the style.
To consider a threshold given by a vertical line (an X value) - since we are talking about a regular line series, and not a THorizLineSeries - we only have to calculate one crossing point. This part would be a simpler than what I did in that example.
To change the line style instead of changing the line color you should do it at OnGetPointerStyle. Changing the color of the line/pointer can be done through the according arrays but there isn't an array in the series to determine the line style; there's a unique LinePen.Style property in the series, so you should use the OnGetPointerStyle to change that series property depending on the valueindex being drawn.
Here note when OnGetPointerStyle is fired for a ValueIndex the line segment from ValueIndex-1 to ValueIndex+1 has been already drawn. So, at the time OnGetPointerStyle is fired you should interrogate XValue[ValueIndex+1] to set the series LinePen.Style for the next segment that will be drawn.
With this trick, the only question open is what happens with the first segment; how to set the according LinePen.Style for the first segment? You can use OnBeforeDrawSeries for that.
It would be something like this:
Code: Select all
const threshold = 1.5;
function TForm1.LineGetPointerStyle(Sender:TChartSeries; ValueIndex:Integer): TSeriesPointerStyle;
begin
lineSeries.LinePen.Style:=psSolid;
if (ValueIndex+1>-1) and (ValueIndex+1<Sender.Count) then
begin
if Sender.XValue[ValueIndex+1] < threshold then
lineSeries.LinePen.Style:=psDot;
end;
end;
procedure TForm1.BeforeDrawSeries(Sender: TObject);
begin
if (lineSeries<>nil) and (lineSeries.Count>0) and (lineSeries.XValue[0] < threshold) then
interpLine.LinePen.Style:=psDot
else
interpLine.LinePen.Style:=psSolid;
end;
So, your code snipped looks fine to me. I'd only change valueIndex for valueIndex+1 at OnGetPointerStyle and use BeforeDrawSeries as above.
If you still find problems with it, don't hesitate to let us know and keep in mind a simple example project we can run as-is would help us to reproduce the situation and try to find a more concrete solution for you.