Scatter Chart : Axis Intersect

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Scatter Chart : Axis Intersect

Post by Quant » Tue Nov 17, 2015 11:38 am

We need to develop scatter chart as shown in below screenshot:
Excel Scatter Chart.png
Excel Scatter Chart Example
Excel Scatter Chart.png (16.49 KiB) Viewed 7228 times
In TeeChart we used Points series to achieve the same, but we are not getting the desired result as shown in above screenshot.
Scatter Chart Error.png
TeeChart Scatter Chart 1
Scatter Chart Error.png (24.45 KiB) Viewed 7225 times
By manually setting teechart properties using TeeChart Editor, it is possible to achieve desired result as shown in below screenshot:
Scatter Chart.png
TeeChart Scatter Chart 2
Scatter Chart.png (25.39 KiB) Viewed 7230 times
But we need to achieve the same programmatically at run time (instead of design time) by setting the axis relative position according to (0,0) coordinates.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Scatter Chart : Axis Intersect

Post by Christopher » Tue Nov 17, 2015 1:14 pm

Quant wrote:But we need to achieve the same programmatically at run time (instead of design time) by setting the axis relative position according to (0,0) coordinates.
I think the code you need you should already have in the following method:

Code: Select all

private void InitializeComponent()
which is in the e.g. Form1.Designer.cs unit. That is to say that all changes to TChart made by the Chart Editor are written to the InitializeComponent() by the Visual Studio designer.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Scatter Chart : Axis Intersect

Post by Quant » Wed Nov 18, 2015 5:05 am

I think the code you need you should already have in the following method:

Code: Select all

private void InitializeComponent()
Hi Christopher,
This is not as required. Nevertheless we found the way to solve this programmatically. We added following code snippet which solve our problem:

Code: Select all

ColorLine vertiColorLine = new ColorLine(tChart1.Chart);
vertiColorLine.Axis = tChart1.Axes.Left;
vertiColorLine.Value = 0;
vertiColorLine.AllowDrag = false;

ColorLine horizColorLine = new ColorLine(tChart1.Chart);
horizColorLine.Axis = tChart1.Axes.Bottom;
horizColorLine.Value = 0;
horizColorLine.AllowDrag = false;

this.tChart1.Axes.Left.AxisPen.Visible = false;
this.tChart1.Axes.Left.MinorTicks.Visible = false;
this.tChart1.Axes.Left.Ticks.Visible = false;

this.tChart1.Axes.Bottom.AxisPen.Visible = false;
this.tChart1.Axes.Bottom.MinorTicks.Visible = false;
this.tChart1.Axes.Bottom.Ticks.Visible = false;
Check out the final output as shown below:
Scatter Chart Final.png
Scatter Chart Final.png (23.51 KiB) Viewed 7195 times

Post Reply