Hi
I am creating a line chart on a win form where y axis does not show zero level. I have tried setting diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false and setting min max range, nothing seems to work so far. Could you please help.
I have attached a sample project that has this issue. Please take a look. I am working on version 14.1
C#private void Form1_Load(object sender, EventArgs e) {
// Create a chart control.
//ChartControl chartControl1 = new ChartControl();
// Add the chart to the form.
//chartControl1.Dock = DockStyle.Fill;
//this.Controls.Add(chartControl1);
chartControl1.Series.Clear();
// Create a bar series and add points to it.
Series series1 = new Series("Series 1", ViewType.Line);
series1.ArgumentScaleType = ScaleType.DateTime;
DateTime d1 = DateTime.Now;
d1.AddDays(-1);
series1.Points.Add(new SeriesPoint(d1, new double[] { 26.25 }));
series1.Points.Add(new SeriesPoint(d1.AddDays(2), new double[] { 1.52 }));
series1.Points.Add(new SeriesPoint(d1.AddDays(3), new double[] { 22.21 }));
series1.Points.Add(new SeriesPoint(d1.AddDays(4), new double[] { 15.35 }));
series1.Points.Add(new SeriesPoint(d1.AddDays(5), new double[] { 4.15 }));
// Add the series to the chart.
chartControl1.Series.Add(series1);
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
// Enable the diagram's scrolling.
diagram.EnableAxisXScrolling = true;
diagram.EnableAxisYScrolling = true;
// Define the whole range for the X-axis.
diagram.AxisX.WholeRange.Auto = true;
//diagram.AxisX.WholeRange.SetMinMaxValues("A", "D");
// Disable the side margins
// (this has an effect only for certain view types).
diagram.AxisX.VisualRange.AutoSideMargins = false;
// Limit the visible range for the X-axis.
diagram.AxisX.VisualRange.Auto = true;
//diagram.AxisX.VisualRange.SetMinMaxValues("B", "C");
// Define the whole range for the Y-axis.
diagram.AxisY.WholeRange.Auto = false;
diagram.AxisY.WholeRange.AlwaysShowZeroLevel = true;
diagram.AxisY.WholeRange.SetMinMaxValues(1, 26.25 );
}
Edit 1:
Series series1 = new Series("Series 1", ViewType.Line);
series1.ArgumentScaleType = ScaleType.DateTime;
series1.ValueScaleType = ScaleType.Numerical;
series1.Points.Add(new SeriesPoint(new DateTime(2015,9,15),15 ));
series1.Points.Add(new SeriesPoint(new DateTime(2016, 9, 15), 10));
series1.Points.Add(new SeriesPoint(new DateTime(2017, 7, 15), 21));
series1.Points.Add(new SeriesPoint(new DateTime(2018, 9, 15), 16));
series1.Points.Add(new SeriesPoint(new DateTime(2020, 5, 15), 600));
// Add the series to the chart.
chartControl1.Series.Add(series1);
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
// Enable the diagram's scrolling.
diagram.EnableAxisXScrolling = false;
diagram.EnableAxisYScrolling = false;
// Define the whole range for the X-axis.
diagram.AxisX.WholeRange.Auto = false;
diagram.AxisX.Label.TextPattern = "{A:d}";
diagram.AxisX.WholeRange.SetMinMaxValues(new DateTime(2015,5,15), new DateTime(2021, 5, 15));
// Disable the side margins
// (this has an effect only for certain view types).
diagram.AxisX.VisualRange.AutoSideMargins = false;
// Limit the visible range for the X-axis.
diagram.AxisX.VisualRange.Auto = false;
//diagram.AxisX.VisualRange.SetMinMaxValues("B", "C");
// Define the whole range for the Y-axis.
//diagram.AxisY.WholeRange.Auto = false;
diagram.AxisY.WholeRange.SideMarginsValue = 0;
diagram.AxisY.WholeRange.SetMinMaxValues(5, 650);