Using data from a XML file (the data may not always be the same, please keep that in mind) to draw a Profit/Loss graph, and using the MSChart library, I currently obtain two bar charts, one for positive values and the other for negative values. Combining the two series in a single ChartArea, I currently obtain a graph that looks like this:
https://i.sstatic.net/xSUkq.png
However, this is still not what I want. I would like for the 'middle' line of the Y axis (where the 5.4 is in the picture) to be '0'. However, every method I have checked can only do this if there are no negative values, which is why it wouldn't work in my case. Using the "Crossing" property is also incorrect, since it draws an additional line where I would like for my labels to use the '0' as a 'base', if you will. In other words, I would like my chart to look like this instead:
https://i.sstatic.net/T9ngi.png
I will be able to take care of the irregular values for the labels once I know how to show the 0 line, which is why it is important for me to know this. I would greatly appreciate any help you can give me, as my own research has been fruitless so far.
Make sure you let the control decide on the best Min
and Max
for the Y axis.
So do not do this:
chart1.ChartAreas[0].AxisY.Maximum = mymax;
chart1.ChartAreas[0].AxisY.Minimum = mymin;
instead make sure you set
auto
mode with:
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;