我的代码有三个条形,我需要在它们之前留出一些空间:它应该以某个特定值开始,而不是0;
What I have now
What I want to get (example)
这是我的代码:
var ch = new Chart();
ch.Series.Clear();
var cha = new ChartArea();
ch.ChartAreas.Add(cha);
var datePlanSeries = new Series {ChartType = SeriesChartType.Bar };
var dateAgreedSeries = new Series { ChartType = SeriesChartType.Bar };
var dateFactSeries = new Series { ChartType = SeriesChartType.Bar };
datePlanSeries.Points.AddY(durationPlan);
dateAgreedSeries.Points.AddY(durationAgreed);
dateFactSeries.Points.AddY(durationFact);
// And what should I add to each series to "move" it?
ch.Series.Add(datePlanSeries);
ch.Series.Add(dateAgreedSeries);
ch.Series.Add(dateFactSeries);
答案 0 :(得分:1)
有一种名为Range Bar的图表类型。每个数据点都需要2个Y值,从-Y和-Y看。所以而不是:
var datePlanSeries = new Series {ChartType = SeriesChartType.Bar }; ... datePlanSeries.Points.AddY(durationPlan);
您使用:
var datePlanSeries = new Series { ChartType = SeriesChartType.RangeBar };
...
datePlanSeries.Points.Add(1, 10); // from Y = 1, to Y = 10