Using chart windows forms control to display:
STACKED COLUMN
Several series, ~70 datapoints per series. Let's say x: 0 - 70. Secondary Y-axis.
POINT/LINE
0-3 series displayed, ~20 datapoints per series. X-values are 0-20, so only covering part of the chartarea. Primary Y-axis.
I am adding custom labels to the x-axis. The user can choose to show 24, 48 or 72 datapoints. Depending on the number of datapoints, the interval on the x-axis is changed.
24 -> Interval 1
48 -> Interval 2
72 -> Interval 3
FIRST PROBLEM
I do not want the primary Y-axis to be displayed when the point/line graphs are not visible. This is working, but when I add the graphs, the whole chartarea moves and resizes in order to fit in the axis. I would like the chartarea to remain still, just adding the axis to the area. See difference between images 24_Point and 24_NoPoint.
SECOND PROBLEM
The interval on the axis seems to work, but the numbers are scaled and moved up/down in order to fit in, even though there doesn't seem to be any space issues. Is there any way to force orientation, font and distance so they don't move? A problem I see with fixing the font, is that if the labels are to close, they will overlap or disappear. In this case though, the program will be in full control of the number of labels and size of the chartarea, so it should be able to control it. See difference between images 24_Point and 48_Point.
RELEVANT CODE
Chart.ChartAreas["Default"].AxisX.CustomLabels.Clear();
if (PlotHours == 24){
interval = 1;
} else if (PlotHours == 48){
interval = 2;
} else {
interval = 3;
}
q = 0;
for (int i = 0; i=72; i++){
if (q==0){
Chart.ChartAreas["Default"].AxisX.CustomLabels.Add((i-0.5, (i+0.5), AxisLabels[i]);
}
if (q == (interval-1)){
q = 0;
} else {
q++;
}
}
Chart.ChartAreas["Default"].AxisX.Interval = interval;
Chart.ChartAreas["Default"].AxisX.IntervalOffset = 1;
REFERENCED IMAGES
The reason I have not removed the black areas of the pictures, is to keep them in scale.
24_Point
24_NoPoint
48_Point