2

これは私が現在持っているものです:

問題文

私が必要とするのは、次の不均一な間隔 (垂直線と x 軸のラベル) を持つことです。

1) 1 (i.e. must not cross at 0)
2) 1.5
3) 2.5
4) 3.5
5) 4

これを行う方法はありますか?それが余分なシリーズか何かを伴うクラッジであっても、それがIntervalOffsetと関係があることを望んでいますが、私が望むことをすることができません。

現在、私はちょうど持っています:

chartarea.AxisX.Maximum = 4;
chartarea.AxisX.Minimum = 1;
chartarea.AxisX.Interval = 1;
4

1 に答える 1

1

必要だったのは次のとおりです。

// set the max & min, with an interval of 1 which is offset by 0.5
// this gives the correct start (1), and three .5 intervals
// however, it doesn't give the closing vertical line at 4
chartarea.AxisX.Maximum = 4;
chartarea.AxisX.Minimum = 1;
chartarea.AxisX.Interval = 1;
chartarea.AxisX.IntervalOffset = 0.5;

// enable a secondary y axis for the line at 4
chartarea.AxisY2.Enabled = AxisEnabled.True;
// switch of all tickmarks & gridlines
chartarea.AxisY2.MajorTickMark.Enabled = false;
chartarea.AxisY2.MinorTickMark.Enabled = false;
chartarea.AxisY2.MajorGrid.Enabled = false;
chartarea.AxisY2.MinorGrid.Enabled = false;
chartarea.AxisY2.LabelStyle.Enabled = false;
// set the correct colour  & line style
chartarea.AxisY2.LineColor = Color.FromArgb(160, 160, 160);
chartarea.AxisY2.LineDashStyle = ChartDashStyle.Dash;

// add custom labels for the 5 points/lines
chartarea.AxisX.CustomLabels.Add(0.9, 1.1, "1");
chartarea.AxisX.CustomLabels.Add(1.4, 1.6, "1.5");
chartarea.AxisX.CustomLabels.Add(2.4, 2.6, "2.5");
chartarea.AxisX.CustomLabels.Add(3.4, 3.6, "3.5");
chartarea.AxisX.CustomLabels.Add(3.9, 4.1, "4");

そして出来上がり:(私のデータは変更されましたが)

ここに画像の説明を入力

于 2013-03-29T21:57:01.723 に答える