I have a time axis and I want to display my Y axis labels inside the chart area instead of outside
here is my code
Series newSeries = new Series("hkld");
newSeries.ChartType = SeriesChartType.Line;
newSeries.BorderWidth = 2;
newSeries.Color = Color.OrangeRed;
newSeries.XValueType = ChartVal
chart1.ChartAreas[0].AxisY.IsReversed = true;
chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
chart1.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 2;
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Gray;
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisX.Maximum = 1000000;
chart1.ChartAreas[0].AxisX.Interval = 200000; //major interval
chart1.ChartAreas[0].AxisX.MinorGrid.Interval = 20000; //minor interval
chart1.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
chart1.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
chart1.ChartAreas[0].AxisY.MajorTickMark.Enabled = false;
chart1.ChartAreas[0].AxisY.IntervalType = DateTimeIntervalType.Minutes;
chart1.ChartAreas[0].AxisY.Interval = 2;
chart1.ChartAreas[0].AxisY.LabelStyle.Format = "HH:mm:ss";
chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
chart1.ChartAreas[0].AxisY.MinorGrid.Enabled = true;
chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 2;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Gray;
chart1.ChartAreas[0].AxisY.MinorGrid.IntervalType = DateTimeIntervalType.Minutes;
chart1.ChartAreas[0].AxisY.MinorGrid.Interval = 2;
chart1.ChartAreas[0].AxisY.MinorGrid.LineDashStyle = ChartDashStyle.Dash;
chart1.ChartAreas[0].BorderColor = Color.Black;
chart1.ChartAreas[0].BorderWidth = 3;
chart1.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid;
chart1.ChartAreas[0].Position.X = 5;
chart1.ChartAreas[0].Position.Y = 5;
chart1.ChartAreas[0].Position.Width = 90;
chart1.ChartAreas[0].Position.Height = 90;
chart1.ChartAreas[0].InnerPlotPosition.Height = 100;
chart1.ChartAreas[0].InnerPlotPosition.Width = 80;
chart1.ChartAreas[0].InnerPlotPosition.X = 20;
chart1.ChartAreas[0].Position.Auto = false;
Here is a pic of my chart :
And here is what i want to achieve :
NOTE : my chart is a real time chart, so the time value will be updated and goes up as the time continues (dynamic axis)
I don't think you can move the labels but you can move the axis along with the labels. To do so set a suitable value for the AxisX.Crossing
.
MSDN:
Setting this property for a primary axis will determine where the other primary axis crosses it, and similarly setting it for a secondary axis will determine where the other secondary axis crosses it. For example, setting the Crossing property of the primary X-axis determines where the primary Y-axis will cross it.
Four modes can be used for the Crossing property of an axis:
"Auto", which means that the crossing value will be set to the minimum or maximum value for the relevant axis...
"Minimum", which means the crossing value of the axis will be its minimum value...
"Maximum", which means the crossing value of the axis will be its maximum value...
A specified double value that is between the minimum and maximum values for the relevant axis...
This moves it to the x-value of the last datapoint:
Axixs ax = chart1.ChartAreas[0].AxisX;
ax.Crossing = mySeries.Points.Last().XValue;
You can use fixed values if you know your data..