积极答复者
Winform Chart控件怎么设置格网为虚线,就像matlab中一样

问题
答案
-
谢谢!
我找到问题所在了,我是将Chart作为参数传递给一个对象来处理的,在对象里面设置的线形无效。
txt_Report.Text += ts.ReadData(textBox1.Text, isChecked);
txt_Report.Text += ts.DrawGraph(chart1, textBox1.Text, isChecked);
- 已建议为答案 Herro wongMicrosoft contingent staff 2016年6月6日 2:40
- 已标记为答案 CaillenModerator 2016年6月8日 5:02
全部回复
-
試試在ChartAreas = 0 設,看看有沒有效果
chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;
大家一齊探討、學習和研究,謝謝!
MCSD, MCAD, MCSE+I, MCDBA, MCDST, MCSA, MCTS, MCITP, MCPD,
MCT, Microsoft Community Star(TW & HK),
Microsoft MVP for VB.NET since 2003
My MSMVP Blog
請記得將對您有幫助的回覆 標示為解答 以幫助其他尋找解答及參與社群討論的朋友們。
Please remember to click Mark as Answer on the post that helps you. This can be beneficial to other community members reading the thread. -
Hi,
你可以试试以下的代码(除了这个两条语句没做任何修改):
chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot; chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;
参考链接:
如果无效的话你检查下你的代码,可能你在其他地方修改了这个地方的网格样式。
Regards,
Moonlight
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
都有试过,但是我发现我的网格线条没有变成虚线,而是变粗了,很奇怪,下面是我的代码。
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";
-
你好,
我把你的代码拿去测试了也没你提及的问题啊,你在属性面板那边看看是不是你在设计器里面修改了某些设置。
下面是我的测试代码(可能是chart1.ChartAreas[0].Position这个属性影响了,我试了下你原来的直接缩成一团了):
Random ran = new Random(); 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)2 / 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 = 99; chart1.ChartAreas[0].Position.Height = 99; 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"; chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100)); chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100)); chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100)); chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100)); chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100)); chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100)); chart1.Series[0].Points.AddXY(ran.Next(0, 3600), ran.Next(0, 100));
如果还是没效果的话,你能否提供重现样本程序,我会测试一下。
Regards,
Moonlight
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
- 已编辑 Moonlight ShengMicrosoft contingent staff 2016年6月3日 5:44
-
谢谢!
我找到问题所在了,我是将Chart作为参数传递给一个对象来处理的,在对象里面设置的线形无效。
txt_Report.Text += ts.ReadData(textBox1.Text, isChecked);
txt_Report.Text += ts.DrawGraph(chart1, textBox1.Text, isChecked);
- 已建议为答案 Herro wongMicrosoft contingent staff 2016年6月6日 2:40
- 已标记为答案 CaillenModerator 2016年6月8日 5:02