user3431418
user3431418

Reputation: 23

Same grid settings on multiple charts

enter image description here

I am trying to put the two charts to have the same grid lines vertically on the separate chart(Chart A and Chart B). I think have most of the settings correctly but somehow the grid on the charts don't line up.

I have same settings for these charts on the location x(not y) on the control property and the width. I also have the same AxisX interval for both graph and the data for the AxisX.Minimum and AxisX.Maximum are exactly the same for both chart. I believe by chart A and Chart B has a difference decimal and that why is causing this problem(see red box on the left of the image).

My question is how do i line this up vertically.

Below are my settings in C# ASP.NET

_chart.ChartAreas[0].AxisX.Interval = 30
_chart.ChartAreas[0].AxisX.Minimum = _Intra.Select(x => x.X).Min().ToOADate();
_chart.ChartAreas[0].AxisX.Maximum = _Intra.Select(x => x.X).Max().ToOADate();
_chartArea1.AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Minutes;
_chartArea1.AxisX.IntervalType = DateTimeIntervalType.Minutes;

Upvotes: 2

Views: 1671

Answers (1)

zeFrenchy
zeFrenchy

Reputation: 6591

You should investigate the alignment properties. Create your plots as two chart areas inside a single chart object to be able to use the .alignWithChartArea property.

using System.Windows.Forms.DataVisualization.Charting;
...

// Make Chart Area 2 align to Chart Area 1
Chart1.ChartAreas["Chart Area 2"].AlignWithChartArea = "Chart Area 1";

// Set the alignment type
Chart1.ChartAreas["Chart Area 2"].AlignmentStyle = AreaAlignmentStyles.Position |
                                            AreaAlignmentStyles.PlotPosition |
                                            AreaAlignmentStyles.Cursor |
                                            AreaAlignmentStyles.AxesView;

Upvotes: 2

Related Questions