7

我正在使用 Visual Studio 2010 中的标准图表库。图表工作正常,但我无法更改轴线网格线样式。这些是已经在 Form1.Designers.cs 中设置的属性

chartArea3.Name = "ChartArea1";
        this.chart1.ChartAreas.Add(chartArea3);
        legend3.Name = "Legend1";
        this.chart1.Legends.Add(legend3);
        this.chart1.Location = new System.Drawing.Point(12, 68);
        this.chart1.Name = "chart1";
        series5.ChartArea = "ChartArea1";
        series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
        series5.Color = System.Drawing.Color.Red;
        series5.Legend = "Legend1";
        series5.Name = "Temp";
        series6.ChartArea = "ChartArea1";
        series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
        series6.Color = System.Drawing.Color.Blue;
        series6.Legend = "Legend1";
        series6.Name = "Umid";
        this.chart1.Series.Add(series5);
        this.chart1.Series.Add(series6);
        this.chart1.Size = new System.Drawing.Size(647, 182);
        this.chart1.TabIndex = 8;
        this.chart1.Text = "chart1";
        this.chart1.ChartAreas[0].AxisY.Interval=5;

我想要轴网格类型的点或虚线。我尝试过:

this.chart1.ChartAreas[0].AxisX.LineDashStyle.??????

但是我不知道如何分配属性和/或上面的部分代码行是否正确。

4

2 回答 2

12

最后我做对了:

 this.chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;
        this.chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;

这是有效的,并且可以访问网格轴的线条样式。

 this.chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.availableStileSelectionHere;
于 2013-06-21T16:50:49.023 回答
1

您需要查看ChartDashStyle枚举。您的选择应该是Dash, DashDot, DashDotDot, Dot, Solid, 和NotSet

AxisX是类型Charting.Axis的,所以这是表达线型信息的地方。

所以试试:

this.chart1.ChartAreas[0].AxisX.LineDashStyle.Dot

或者

this.chart1.ChartAreas[0].AxisX.LineDashStyle.DashDot
于 2013-06-21T15:46:15.627 回答