0

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;
4

2 に答える 2

1

問題が見つかりました。

 series1.IsXValueIndexed = true;

これが起こった理由です。それは誤りであるはずです。皆様のご注目に感謝いたします。

于 2013-01-10T09:25:55.720 に答える
0

空のDataPointを使用する必要があると思います(http://msdn.microsoft.com/en-us/library/dd456677.aspxを参照)

IsEmptyプロパティを使用すると、次のコードになります。(DataManipulator.InsertEmptyPoints必要なコードは少ないはずですが、まだテストしていません)

chart1.Series[0].Points.Add(new DataPoint(0,1));
chart1.Series[0].Points.Add(new DataPoint(1,0){IsEmpty=true});
chart1.Series[0].Points.Add(new DataPoint(2,0){IsEmpty=true});
chart1.Series[0].Points.Add(new DataPoint(3,0){IsEmpty=true});
chart1.Series[0].Points.Add(new DataPoint(4,0){IsEmpty=true});
chart1.Series[0].Points.Add(new DataPoint(5,0){IsEmpty=true});
chart1.Series[0].Points.Add(new DataPoint(6,0){IsEmpty=true});
chart1.Series[0].Points.Add(new DataPoint(7,1));
chart1.Series[0].Points.Add(new DataPoint(8,1));
于 2013-01-10T08:55:20.587 に答える