none
How to make x values start from yaxis in MS Chart? RRS feed

  • Question

  • Hi,

    In my application I am plotting datetime in x axis and interger in y axis.

    How to make x values start from yaxis in MS Chart?

    this is my code.

    chart.ChartAreas["history"].AxisX.Title = "X Axis";
    chart.ChartAreas["history"].AxisX.MajorGrid.LineColor = System.Drawing.Color.Black;
             
    chart.ChartAreas["history"].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
          
    chart.ChartAreas["history"].AxisY.Minimum = 0;
    chart.ChartAreas["history"].AxisY.Maximum = 1000;
    chart.ChartAreas["history"].AxisY.Interval = 250;
    chart.ChartAreas["history"].AxisY.Title = "Y Axis";
    chart.ChartAreas["history"].AxisY.MajorGrid.LineColor = Color.Black;
    chart.ChartAreas["history"].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
    chart.ChartAreas["history"].BackColor = Color.White;
    chart.ChartAreas["history"].AxisX.Interval = 1;
    chart.ChartAreas["history"].AxisX.LabelStyle.Angle = -90;
    chart.ChartAreas["history"].AxisX.LabelStyle.Format = "dd-MM-yyyy hh:mm:ss";

    Tuesday, May 21, 2019 9:45 AM

Answers

  • If I call

    chart.ChartAreas["history"].AxisX.IsMarginVisible = false;

    x values starts from y axis.

    • Marked as answer by sgrm123 Tuesday, May 21, 2019 12:32 PM
    Tuesday, May 21, 2019 12:32 PM