2017-08-15 69 views
-1

enter image description here更改視覺工作室中的圖表欄顏色。 C#Winforms

如何在設計時更改這些藍色?我之前發現了一種方法,但它只改變了條上的顏色而不是傳說中的顏色。

該圖表可以顯示許多數據,這取決於用戶,所以我需要它來更改所有數據的顏色。謝謝

代碼:

private void loadchartFast() 
    { 
     chart1.Series[0].Points.Clear(); 
     chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; 
     using (SqlConnection connection = new SqlConnection("Data Source=BENJOPC\\SQLEXPRESS;Initial Catalog=MARISCHELLdatabase;Integrated Security=True")) 
     {   
      SqlCommand command = new SqlCommand("SELECT TOP 5 ProductName, Sum(QtySold) as QtySold FROM Sales_productholder group by ProductName order by SUM(QtySold) desc", connection); //top selling with desc 
      connection.Open(); 
      SqlDataReader read = command.ExecuteReader(); 

      while (read.Read()) 
      { 
       this.chart1.Series["Pieces Sold"].Points.AddXY(read["ProductName"], read["QtySold"]); 

      } 
      read.Close(); 
      // chart3.Series["Pieces Sold"].Points[0].Color = Color.LightSeaGreen; ; 
     } 
    } 

回答

0

可以使用Palette屬性有不同的顏色:

enter image description here

選擇任何可用的模板。

爲了添加自定義顏色,可以在PaletteCustomColors屬性中添加不同的顏色,然後將Palette屬性設置爲None

+0

謝謝先生。我在自定義調色板中添加了一種顏色。我如何在自定義調色板中使用該顏色? – FutureDev

+0

我明白了,我將調色板設置爲無。謝謝先生 – FutureDev

+0

好消息。很高興它的作品。 –