i'm currently running into issues with MSChart, esp. a BarChart. The chart is meant to be exported and saved into an image file and has a huge amount of seperate bars to be shown, resulting in a height of 38960px.
The problem: It seems like the height of the axis' label is calculated percentual with a minimum of 1 (and again with a minimum of 10px afterwards). This way the label is about 390px away from the chart ...
To illustrate the issue, i set AxisX.Crossing = 0, so the axis should be drawn right below the upper border of the chart (green line). Actual position is marked red.
(as i'm not allowed to post more than 2 links, i have to remove the original image)
I would appreciate any help to fix or work around this issue.
Edit: A simple project to demonstrate the question/issue can be found here: https://www.dropbox.com/s/fgyxnf4dh9v36ny/HugeMSChart.zip?dl=1
Basically: A fixed chart. I increase the height of the chart for demonstration. Like:
// Increase height
chart1.Height += 100;
// Calculate percentual value for the inner plot position for 50px (absolute)
chart1.ChartAreas[0].InnerPlotPosition.Y = (float)((double)5000 / chart1.Height);
chart1.ChartAreas[0].InnerPlotPosition.Height = 100 - 2 * chart1.ChartAreas[0].InnerPlotPosition.Y;
Edit 2: As mentioned in the comments, the image above doesn't result from the sample project. Nevertheless the issue stays the same, as shown in the new image. The left images shows a small chart, where the label for the axis is situated right at the top (distance to top marked green). The right image shows the same chart but with a height of about 30.000px. As you can see, the label for the axis dislocates, as the distance to the top seems to scale with the chart height.
Edit 3: Unfortunately I have to admit the previous MCVE would not cover the whole issue (I thought so, but I was wrong .. sorry). The solutions proposed so far work for huge charts, but only with a limited number of datapoints. When increasing the number of datapoints, the margin between the axis and the labels is still visible (even with IsMarginVisible = false).
An updated MCVE may be found here (just execute and scroll down to the very bottom): https://dl.dropboxusercontent.com/u/24263856/HugeMSChart2.zip
As for the old solutions: The margin seems not to be applied when there is at least one datapoint above and below the crossing value for the axis. But as this moves the axis (and the labels) into the chart, this ain't no real solution.
See Question&Answers more detail:os