2011-12-23 96 views
0

我已經添加了三個堆棧圖的系列。我想在每個欄的頂部添加值。不是每個系列。因爲有些酒吧沒有一些系列。 所以,我想在每列的頂部添加vaue。堆棧圖頂部值在MSChart

  chart1.Legends.Add("Legend").Alignment = StringAlignment.Center; 
      chart1.Palette = ChartColorPalette.None; 
      chart1.PaletteCustomColors = new Color[] { Color.FromArgb(0, 255, 0), Color.FromArgb(0, 128, 0), Color.FromArgb(255, 0, 0), Color.Green }; 

      // Series for the graph. 
      Series series1; 
      Series series2; 
      Series series3; 
      Series series4; 


      series1= new Series("series1"); 
      series12= new Series("series2"); 
      series13= new Series("series3"); 
      series14= new Series("series4"); 

    series1.Points.AddXY(values); 
      series2.Points.AddXY(values); 
    series3.Points.AddXY(values); 
    series4.Points.AddXY(values); 

      series1.CustomProperties = "PixelPointWidth = 17"; 
      series2.CustomProperties = "PixelPointWidth = 17"; 
      series3.CustomProperties = "PixelPointWidth = 2"; 
      series4.CustomProperties = "PixelPointWidth = 17"; 

      series3.ChartType = SeriesChartType.Line; 
      series3.BorderWidth = 2; 
      series3.Color = Color.Blue; 

      series1.ChartType = series2 = series4.ChartType = SeriesChartType.StackedColumn; 
      series1.Font = series2.Font = series3.Font = series4.Font = new Font("Verdana", 8.25f, FontStyle.Regular); 

      chart1.Series.Add(series1); 
      chart1.Series.Add(series2); 
      chart1.Series.Add(series3); 
      chart1.Series.Add(series4); 

    foreach (Series series in chart1.Series) 
      { 
       if (series.Name == "series1") 
       { 
        series.ChartType = SeriesChartType.StackedColumn; 
        series["ColumnDrawingStyle"] = "series1Style"; 
        series["LabelStyle"] = "Top"; 
        // this willl shows the label at top of bar 
        series.IsValueShownAsLabel = true; 
       } 
      } 

回答

1

我相信你想顯示在列的中心StackColumn而不是一些頂級達爾與堆疊式的情況。

然後,最好再添加一個系列,即Total,它可以說是ChartType = Bubble,然後您只能爲此係列設置標籤並禁用堆疊列的形成。

+0

我已經添加了一個系列,但我想知道我可以在哪裏編寫這個系列的custome標籤。系列series_TOPValue =新系列(「TOPValue」); series_TOPValue.ChartType = SeriesChartType.Bubble; chart1.Series.Add(series_TOPValue); – user990897 2011-12-23 09:43:53

+0

俱樂部所需的一個,並將其分配爲標籤的數據源,如Series [0] .Points.DataBind(data,「Text」,「Total」,「Label = [customlabelproperyhere]」); – V4Vendetta 2011-12-23 09:57:34