2017-01-18 68 views
0

我的代碼有三個欄,我需要在它們之前留出一些空間:它應該從某個特定值開始,而不是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

酒吧(和列)總是從0開始。如果你想有所動作,你可以用圖表類型StackedBar和右在每個正常序列點之前添加透明虛擬序列數據點。 – TaW

回答

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 
+0

謝謝你的回答! – rdh1n

相關問題