在 C# 图表控件中将网格线型设置为破折号
Set grid linetype as dash in C# Chart Control
我试过了
Chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
但不工作。
设置图表控件的完整代码是below.The设置LineDashStyle后网格线变宽
Chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.DashDotDot;
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
Chart1.ChartAreas[0].AxisY.MajorTickMark.Enabled = false;
Chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
Chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 3600;
Chart1.ChartAreas[0].AxisX.Interval = 3600;
Chart1.ChartAreas[0].AxisX.Maximum = 3600 * ((int)m / 3600 + 1);
Chart1.ChartAreas[0].AxisX.Minimum = 0;
Chart1.Series.Add("Latitude");
Chart1.ChartAreas[0].AxisX.Title = "Epoch[h]";
Chart1.ChartAreas[0].AxisX.TitleFont = new Font("TimesNewRoman", 10);
Chart1.ChartAreas[0].Position.Width = 45;
Chart1.ChartAreas[0].Position.Height = 30;
Chart1.Series[0].ChartType = SeriesChartType.Line;
Chart1.Series[0].Points.DataBindXY(time,rms_x);
Chart1.ChartAreas[0].AxisY.Title = "Latitude[m]";
Chart1.ChartAreas[0].AxisY.TitleFont = new Font("TimesNewRoman", 10);
Chart1.ChartAreas[0].AxisX.LabelStyle.IsStaggered = false;
//Chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1;
Chart1.ChartAreas[0].Name = "Latitude";
Chart1.ChartAreas[0].Position.X = 0;
Chart1.ChartAreas[0].Position.Y = 0;
Chart1.Series[0].ChartArea = "Latitude";
这是我得到的图片'LinshDashStyle'第一张图已经更新为破折号,第二张图是更新前的。
尝试将最后一行添加到您的代码中并告诉我们结果。
Chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].BorderDashStyle = ChartDashStyle.Dash;
txt_Report.Text += ts.ReadData(textBox1.Text, isChecked);
txt_Report.Text += ts.DrawGraph(chart1, textBox1.Text, isChecked);
感谢您的所有回答和评论,我终于发现我将 Chart 传递给对象以设置其 属性 是原因。
我试过了
Chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
但不工作。
设置图表控件的完整代码是below.The设置LineDashStyle后网格线变宽
Chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.DashDotDot;
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
Chart1.ChartAreas[0].AxisY.MajorTickMark.Enabled = false;
Chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
Chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 3600;
Chart1.ChartAreas[0].AxisX.Interval = 3600;
Chart1.ChartAreas[0].AxisX.Maximum = 3600 * ((int)m / 3600 + 1);
Chart1.ChartAreas[0].AxisX.Minimum = 0;
Chart1.Series.Add("Latitude");
Chart1.ChartAreas[0].AxisX.Title = "Epoch[h]";
Chart1.ChartAreas[0].AxisX.TitleFont = new Font("TimesNewRoman", 10);
Chart1.ChartAreas[0].Position.Width = 45;
Chart1.ChartAreas[0].Position.Height = 30;
Chart1.Series[0].ChartType = SeriesChartType.Line;
Chart1.Series[0].Points.DataBindXY(time,rms_x);
Chart1.ChartAreas[0].AxisY.Title = "Latitude[m]";
Chart1.ChartAreas[0].AxisY.TitleFont = new Font("TimesNewRoman", 10);
Chart1.ChartAreas[0].AxisX.LabelStyle.IsStaggered = false;
//Chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1;
Chart1.ChartAreas[0].Name = "Latitude";
Chart1.ChartAreas[0].Position.X = 0;
Chart1.ChartAreas[0].Position.Y = 0;
Chart1.Series[0].ChartArea = "Latitude";
这是我得到的图片'LinshDashStyle'第一张图已经更新为破折号,第二张图是更新前的。
尝试将最后一行添加到您的代码中并告诉我们结果。
Chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
Chart1.ChartAreas[0].BorderDashStyle = ChartDashStyle.Dash;
txt_Report.Text += ts.ReadData(textBox1.Text, isChecked);
txt_Report.Text += ts.DrawGraph(chart1, textBox1.Text, isChecked);
感谢您的所有回答和评论,我终于发现我将 Chart 传递给对象以设置其 属性 是原因。