Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 图表网格线样式_C#_Charts - Fatal编程技术网

C# 图表网格线样式

C# 图表网格线样式,c#,charts,C#,Charts,我正在使用VisualStudio2010中的标准图表库。 图表运行良好,但我无法更改轴网格线样式。 这些是Form1.Designers.cs中已设置的属性 chartArea3.Name = "ChartArea1"; this.chart1.ChartAreas.Add(chartArea3); legend3.Name = "Legend1"; this.chart1.Legends.Add(legend3); this.c

我正在使用VisualStudio2010中的标准图表库。 图表运行良好,但我无法更改轴网格线样式。 这些是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.??????

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

您需要检查枚举。您的选择应该是
Dash
DashDot
DashDot
Dot
Solid
NotSet

AxisX
属于
Charting.Axis类型,因此表示线型信息的位置

因此,请尝试:

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


最后我说对了:

 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;

谢谢John,但我在代码中尝试了bot行,但不起作用。我已经修改了我帖子中的代码,显示了我从默认设置中获得的全部属性集,并添加了。你是否使图表无效/刷新了?您是否能够在图表中看到其他更改,这些更改与您尝试更改轴类型的方式相同(如在代码中的同一位置)?上面代码中我将间隔设置为5的最后一行工作正常。默认情况下已经存在的所有其他行。您是在设计器中更改这些行,还是手动在其中添加代码?如果你手工编辑设计器代码,事情可能不会发生,因为事情不同步?我试图在设计器中添加你建议的行。这两行的问题是,我得到了一个编译器错误。
 this.chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.availableStileSelectionHere;