Reputation: 1467
The resulting graphs must be represented in such a way that 1mm (1 unit) horizontal is exactly 1mm (1 unit) vertical (or any other measurement, basically a square in equal units MUST be square, not rectangular in any way).
I am using System.Windows.Forms.DataVisualization.Charting library and working on a Windows Forms application.
chart1.Width= 500;
chart1.Height = 500;
chart1.Legends.Clear();
var area = chart1.ChartAreas[0];
area.AxisX.Minimum = 0;
area.AxisX.Maximum = 10;
area.AxisX.Interval = 1;
area.AxisY.Minimum = 0;
area.AxisY.Maximum = 15;
area.AxisY.Interval = 1;
var lineSeries = chart1.Series[0];
lineSeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
//lineSeries.MarkerSize = 3;
lineSeries.BorderWidth = 3;
lineSeries.Points.AddXY(0, 0);
lineSeries.Points.AddXY(2, 2);
lineSeries.Points.AddXY(4, 6);
lineSeries.Points.AddXY(6, 10);
lineSeries.Points.AddXY(10, 10);
And here the output shows height and width ratio of the graph is not proper (width should be 2/3 of the height).
And this output shows height and width of graph is identical and square. If i make both axes equal. e.g.
area.AxisX.Minimum = 0;
area.AxisX.Maximum = 15;
area.AxisX.Interval = 1;
area.AxisY.Minimum = 0;
area.AxisY.Maximum = 15;
area.AxisY.Interval = 1;
Upvotes: 0
Views: 755
Reputation: 1467
I finally got the answer by @Taw's mentioned post and comments.
Given that your monitor is able to show square pixels you would have to make sure the the InnerPlotPosition of the ChartArea is a square.
Constrain aspect ratio in WindowsForms DataVisualization Chart
Upvotes: 1