Page 1 of 1

How to draw multiple line without adding series?

Posted: Tue Dec 17, 2019 1:48 am
by 16082909
For example, I have a sales chart by item with teechart.
before.jpg
before.jpg (143.94 KiB) Viewed 17475 times
I want to add break-even point line on 450.
after.jpg
after.jpg (150.85 KiB) Viewed 17475 times
How can I implement it? I think it would be good if you give me a sample

Thank you.

Re: How to draw multiple line without adding series?

Posted: Wed Dec 18, 2019 7:34 am
by Christopher
goodsj wrote:
Tue Dec 17, 2019 1:48 am
How can I implement it? I think it would be good if you give me a sample
Of course - you can find the sample I refer to below in the TeeChart for .NET C# Windows Forms examples repo under the 'Feature Demo' folder. The sample shows TeeChart's canvas events which allow you to draw lines, shapes, text and images at any point of the chart at different times of its painting routine:
TeeChartNetExamples_Ek94xF71VG.png
TeeChartNetExamples_Ek94xF71VG.png (187.6 KiB) Viewed 17454 times

Re: How to draw multiple line without adding series?

Posted: Fri Dec 20, 2019 2:36 am
by 16082909
Thanks for answering.

I could draw line with Graphics3D, Point.

but, I couldn't set 450 its line position dynamically regardless of chart size.

Re: How to draw multiple line without adding series?

Posted: Fri Dec 20, 2019 9:47 am
by Christopher
goodsj wrote:
Fri Dec 20, 2019 2:36 am
but, I couldn't set 450 its line position dynamically regardless of chart size.
You can fix the point by getting the Axis to calculate the pixel value of the Axis value for you, e.g.

Code: Select all

		private void TChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			var yVal = tChart1.Axes.Left.CalcPosValue(450);
			g.Pen.Color = Color.Red;
			g.HorizontalLine(tChart1.Chart.ChartRect.Left, tChart1.Chart.ChartRect.Right, yVal);
		}

Re: How to draw multiple line without adding series?

Posted: Mon Dec 23, 2019 7:04 am
by 16082909
Thanks to you, we solved the problem. :D