簡體   English   中英

如何在圖表列c#中更改圖例文本?

[英]How to change text of legend in chart column c#?

我在c#中的圖表列有問題,當我想要更改文本圖例以獲取x值時,它會在圖例的位置顯示此(#VALX)。

這是我在formLoad()代碼

{
     chart1.DataSource = Remplir("SELECT count(*) AS Expr1, Candidat.Sourcing FROM Sourcing INNER JOIN Candidat ON Sourcing.Sourcing=Candidat.Sourcing GROUP BY Candidat.Sourcing");
     chart1.Series[0].XValueMember = "Sourcing";
     chart1.Series[0].YValueMembers = "Expr1";
     chart1.Series[0].IsVisibleInLegend = true;
}

你還沒有給你的series Name ,你的查詢也沒有提供。 所以你應該插入這個:

chart1.Series[0].Name = "Your Series Title"; 

很明顯,你只能顯示在一塊文本的Legend ,並非所有的x值!

如果要保留名稱並單獨設置Legend文本,請使用Series.LegendText屬性:

chart1.Series[0].LegendText = "Your Series Legend Text"; 

#VALX是x值的占位符(變量)。 在運行代碼時,應該使用系列的實際X值自動替換它。

您可以使用它在圖例中顯示動態數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM