【发布时间】:2012-12-24 14:17:35
【问题描述】:
c# mschart vs2010 .net4
chart1.Series[0].Points.AddXY(0, 1);
chart1.Series[0].Points.AddXY(7, 1;
chart1.Series[0].Points.AddXY(8,1);
我希望这 3 个点看起来像这样
. . .
结果是这样的
. . .
为什么? 谢谢
图表代码
chartArea1.AxisX.InterlacedColor = System.Drawing.SystemColors.ControlLight;
chartArea1.AxisX.Interval = 1D;
chartArea1.AxisX.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.VariableCount;
chartArea1.AxisX.IntervalOffset = 1D;
chartArea1.AxisX.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
chartArea1.AxisX.IsInterlaced = true;
chartArea1.AxisX.IsLabelAutoFit = false;
chartArea1.AxisX.LabelStyle.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
chartArea1.AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
chartArea1.AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;
chartArea1.AxisX.MajorTickMark.LineColor = System.Drawing.Color.Maroon;
chartArea1.AxisX.ScrollBar.LineColor = System.Drawing.Color.White;
chartArea1.AxisY.ArrowStyle = System.Windows.Forms.DataVisualization.Charting.AxisArrowStyle.SharpTriangle;
chartArea1.AxisY.InterlacedColor = System.Drawing.Color.WhiteSmoke;
chartArea1.AxisY.Interval = 1D;
chartArea1.AxisY.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
chartArea1.AxisY.IsInterlaced = true;
chartArea1.AxisY.IsLabelAutoFit = false;
chartArea1.AxisY.LabelStyle.Font = new System.Drawing.Font("Lucida Grande", 8F);
chartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
chartArea1.AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDot;
chartArea1.AxisY.ScaleView.MinSizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Number;
chartArea1.CursorX.IsUserEnabled = true;
chartArea1.CursorX.IsUserSelectionEnabled = true;
chartArea1.CursorY.IsUserEnabled = true;
chartArea1.CursorY.IsUserSelectionEnabled = true;
chartArea1.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea1);
this.chart1.Location = new System.Drawing.Point(-4, 0);
this.chart1.Margin = new System.Windows.Forms.Padding(0);
this.chart1.Name = "chart1";
series1.BorderWidth = 3;
series1.ChartArea = "ChartArea1";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
series1.Font = new System.Drawing.Font("Calibri", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
series1.IsXValueIndexed = true;
series1.LabelBorderWidth = 2;
series1.MarkerColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
series1.Name = "Series1";
series1.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.UInt32;
series1.YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.UInt32;
this.chart1.Series.Add(series1);
this.chart1.Size = new System.Drawing.Size(1031, 618);
this.chart1.TabIndex = 5;
【问题讨论】:
-
你能给我们看更多代码和图表截图吗?
-
我很想上传,但我不能上传照片,因为我不被允许。我可能在属性窗口中触摸了一些设置,但我不记得它们了
-
ChartType 系列是哪个?点?
-
是的,它们是积分。我也尝试设置为阶梯线,但所有 x 距离都是相同的
-
我相信您应该将 X 轴的
Interval属性设置为 1,这应该有助于您在可视化时获得结果
标签: c# winforms visual-studio-2010 charts axes