2016-11-04 59 views
2

現在、Pie Chartのウィンドウフォームを作成しています。パイの割合を表示する必要があります。円グラフで凡例に別のラベルを設定する方法

しかし、今、私はこの問題をeencounteredている:私はシリーズにこの#PERCENT{P2}を追加するとPie Chartは次のように表示されます:

enter image description here

しかし、私はそれを削除した場合、Pie Chartはこの

のように表示されます

enter image description here

Pie Chartはこのようにしますか? enter image description here

マイコード:

DataTable dt = new DataTable(); 
     dt.Columns.Add("completed", typeof(string)); 
     dt.Columns.Add("no", typeof(int)); 
     int noin = allitem - intime; 
     dt.Rows.Add("Complete In Time", intime); 
     dt.Rows.Add("OverDue", noin); 

     chart1.DataSource = dt; 

     chart1.DataBind(); 

答えて

3

はい、これは簡単にこのようなあなたのDataPointsごとにLegendTextを設定することによって行われます:あなたのx値は、あなたができる意味のある数字が含まれている場合は

foreach (DataPoint dp in yourSeries.Points) dp.LegendText = yourLabel; 

それらを使用してください:

foreach (DataPoint dp in s.Points) dp.LegendText = dp.XValue + ""; 

の文字列としてx値を追加すると、が失われ、が失われ、LegendTextsの別のソースを使用する必要があります。

あなただけがLegendTexts直接設定することができますDataPointsの固定数がある場合:通常LegendSeriesごとに1つのエントリを示し

yourSeries.Points[0].LegendText = "hi"; 
yourSeries.Points[1].LegendText = "ho"; 
yourSeries.Points[2].LegendText = "hum"; 

注意を。しかし、Pieチャートの場合、DataPointごとに1つのエントリが表示されます!

+0

私はちょうどその項目がコールの凡例のテキストであることを知っています、ありがとう –

関連する問題