Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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: http://i.imgur.com/w5OvX.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?

like image 513
Martin Wiboe Avatar asked Nov 14 '22 20:11

Martin Wiboe


1 Answers

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).

like image 73
Steve Wellens Avatar answered Nov 30 '22 05:11

Steve Wellens