在Microsoft.Chart

时间:2019-05-06 18:52:51

标签: c# .net charts

我确信有办法做到这一点。我一直在寻找一阵子,但还没有发现。我在图表中定义了主要和次要刻度线,但Y轴的LH侧的值与图表中的线(每20条)不匹配。如何使值与行匹配?

enter image description here

编辑 这是创建值的代码行。这些是通过编辑ChartAreas集合在Designer中创建的。

        chartArea1.AxisX.MajorGrid.Interval = 20D;
        chartArea1.AxisX.MajorTickMark.Interval = 10D;
        chartArea1.AxisX.Maximum = 50D;
        chartArea1.AxisX.Minimum = 0D;
        chartArea1.AxisX2.Maximum = 50D;
        chartArea1.AxisX2.Minimum = 0D;
        chartArea1.AxisY.MajorGrid.Interval = 20D;
        chartArea1.AxisY.Maximum = 420D;
        chartArea1.AxisY.Minimum = 300D;
        chartArea1.AxisY.MinorGrid.Interval = 10D;
        chartArea1.AxisY2.Maximum = 420D;
        chartArea1.AxisY2.Minimum = 300D;
        chartArea1.Name = "ChartArea1";
        this.chart1.ChartAreas.Add(chartArea1);
        legend1.Name = "Legend1";
        this.chart1.Legends.Add(legend1);
        this.chart1.Location = new System.Drawing.Point(12, 27);
        this.chart1.Name = "chart1";
        series1.ChartArea = "ChartArea1";
        series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
        series1.IsValueShownAsLabel = true;
        series1.Legend = "Legend1";
        series1.Name = "TempHistory";
        series2.ChartArea = "ChartArea1";
        series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
        series2.Legend = "Legend1";
        series2.Name = "LowerLimit";
        series3.ChartArea = "ChartArea1";
        series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
        series3.Legend = "Legend1";
        series3.Name = "UpperLimit";
        this.chart1.Series.Add(series1);
        this.chart1.Series.Add(series2);
        this.chart1.Series.Add(series3);
        this.chart1.Size = new System.Drawing.Size(1326, 186);
        this.chart1.TabIndex = 53;
        this.chart1.Text = "chart1";

1 个答案:

答案 0 :(得分:0)

chartArea1.AxisY.Interval必须等于chartArea1.AxisX.MajorGrid.Interval