We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ChartStripLine

Hi, I want to add vertical lines at positions on the x-axis. I have tried the ChartStripLine and it does almost what I want. The problem I''m having is that the ChartStripLine works for a range, and has a width. This means that when resizing or zooming, the width of the line you see changes. A series with a line does not do this (or the grid lines in the chart), and i want the strip line to behave like a line series. In other words, the vertical line should have the same width regardless of chart size and zoom. Is there a way to achieve this? Regards Rune

4 Replies

GM Geetha M Syncfusion Team September 5, 2005 01:52 PM UTC

Hi Rune, Sorry for the delayed response. Please refer the sample attached below. ChartStripLines_1665.zip You can use the ChartAreaPaint event handler to draw and to maintain the width of the stripline as constant while Zooming. Please let me know if this helps. Thanks for your interest in Syncfusion products. Regards, Geetha.


RS Rune Selvaag September 6, 2005 07:11 AM UTC

Hi Geetha, Thank you for the reply and the sample. This is not quite what i was looking for. I need the line to stay fixed to a position on the axis. When you resize in the sample, the line changes position relativ to the axis. I also asked for a vertical line on the x-axis. I need it to behave like a strip line, but with constant width. Regards Rune


AD Administrator Syncfusion Team September 6, 2005 01:55 PM UTC

Hi Rune, Please refer to the sample linked to below. This sample uses the ChartAreaPaint event and calculates the coordinates based on where you want the vertical line to appear. ChartStatLines_6068.zip Thanks, Davis


RS Rune Selvaag September 8, 2005 06:15 AM UTC

Thanks Davis, I adjusted the sample so that the line was clipped, and only visible inside the axes (chart area). In your sample the line is also shown outside the chart area when zooming. I uses VisibleRange to achieve this: double xPos = 100; if ((xPos >= chart.PrimaryXAxis.VisibleRange.Min) && (xPos <= chart.PrimaryXAxis.VisibleRange.Max)) { ChartPoint pt1 = new ChartPoint(xPos, chart.PrimaryYAxis.VisibleRange.Min); ChartPoint pt2 = new ChartPoint(xPos, chart.PrimaryYAxis.VisibleRange.Max); Point lineStart = chart.ChartArea.GetPointByValue(pt1); PointF lineEnd = chart.ChartArea.GetPointByValue(pt2); e.Graphics.DrawLine(new Pen(Color.Red),lineStart, lineEnd); } Again, thank you for great support. Rune

Loader.
Live Chat Icon For mobile
Up arrow icon