Martin Wiboe
Martin Wiboe

Reputation: 2119

Align primary and secondary axis in MSChart

I am trying to plot two data series in an MSChart. I am using two axes, but I want the gridlines and tick marks to be aligned.
This is an example of what I have now: https://i.sstatic.net/a31ca.png (excuse the coloring)

As you can see, the dotted lines are not aligned. Ideally, I would have a fixed number of intervals on both axes, however doing the following does not work:

area.AxisY.IntervalAutoMode = IntervalAutoMode.FixedCount;
area.AxisY.IntervalAutoMode = IntervalAutoMode.FixedCount;

I can't set the minimum and maximum statically because the data is dynamic. How can I make this work?

Upvotes: 5

Views: 2211

Answers (1)

Steve Wellens
Steve Wellens

Reputation: 20620

After the grid is drawn you can get the minimum and maximum axis values. Then try setting the MajorGrid.Intervals:

Something like:

if Minimum  0, 0
and Maximum  36, 18
then MajorGrid.Interval 6, 3

So the grid lines line up (Note there will be 6 lines for each graph).

Upvotes: 1

Related Questions