翻譯|其它|編輯:吳園園|2019-08-27 15:59:22.170|閱讀 230 次
概述:本文整理了用戶(hù)在使用MindFusion.Charting for WPF常見(jiàn)的問(wèn)題,希望對(duì)您有所幫助。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
MindFusion.Charting for WPF支持所有主流的圖表類(lèi)型,以及許多自定義的圖表功能。線(xiàn)形圖表控件允許你創(chuàng)建折線(xiàn)圖、面積圖、散點(diǎn)圖或它們之間的任何組合形式。條形圖表控件支持創(chuàng)建集群、堆疊或重疊的條形和柱狀圖。餅圖圖表控件則允許你創(chuàng)建環(huán)形圖表,并且還可對(duì)它們的厚度進(jìn)行自定義調(diào)整。
本文整理了用戶(hù)在使用MindFusion.Charting for WPF常見(jiàn)的問(wèn)題,希望對(duì)您有所幫助。
點(diǎn)擊下載MindFusion.Charting for WPF最新試用版
問(wèn):我想在圖表軸上顯示DateTime值。我使用數(shù)字作為點(diǎn),但我不想顯示這些數(shù)據(jù),我想顯示它附帶的DateTime值。這可以用你的工具嗎?
答: Wpf的圖表支持在任何圖表軸上繪制自定義標(biāo)簽。自定義標(biāo)簽既可以在軸的間隔位置繪制,也可以在該軸的數(shù)據(jù)點(diǎn)位置繪制。
在您的情況下,我們假設(shè)您要在軸的數(shù)據(jù)點(diǎn)位置繪制從數(shù)據(jù)源獲取的DateTime標(biāo)簽。這是你的代碼:
//set the data source lineChart1.DataSource = data; //set the name of the property in the data source to bind to lineChart1.XLabelPath = "PurchaseDate"; //set the type of the labels for the X-axis lineChart1.XAxisSettings.LabelType = LabelType.CustomText; //set the position of the custom labels lineChart1.XAxisSettings.CustomLabelPosition = CustomLabelPosition.ChartDataPoints; //set the format of the labels lineChart1.XAxisSettings.LabelFormat = "MMMM dd";
請(qǐng)注意,設(shè)置標(biāo)簽的格式非常重要。如果不這樣做,控件將嘗試使用標(biāo)準(zhǔn)轉(zhuǎn)換將DateTime值轉(zhuǎn)換為字符串,結(jié)果將不會(huì)如預(yù)期的那樣。
問(wèn):我有8個(gè)類(lèi)別的數(shù)據(jù),每個(gè)類(lèi)別有3個(gè)不同的值。我想在堆積圖表中顯示這些類(lèi)別,每個(gè)類(lèi)別的名稱(chēng)作為標(biāo)簽但不知道如何操作。
答:您想要顯示的內(nèi)容可以通過(guò)在條形圖控件中添加3個(gè)BarSeries來(lái)完成。然后,您可以將每個(gè)系列的XDataPath或YDataPath屬性綁定到數(shù)據(jù)源中的相應(yīng)字段。將條形的類(lèi)型設(shè)置為堆疊。
以下是構(gòu)建堆積柱形圖的方法:
//the first series is predefined BarSeries series1 = barChart1.Series[0] as BarSeries; series1.YDataPath = "EuropeSales"; series1.XData = indexes; series1.BarType = BarType.VerticalStack; BarSeries series2 = new BarSeries(); series2.YDataPath = "AsiaSales"; series2.XData = indexes; barChart1.Series.Add(series2); series2.BarType = BarType.VerticalStack; BarSeries series3 = new BarSeries(); series3.YDataPath = "USASales"; series3.XData = indexes; barChart1.Series.Add(series3); series3.BarType = BarType.VerticalStack;
這是一個(gè)示例列表,其中包含用于綁定圖表的數(shù)據(jù):
var salesList = new List() { new Sales(){Category =“apples”,EuropeSales = 34,AsiaSales = 12,USASales = 24}, new Sales(){Category =“oranges”,EuropeSales = 23,AsiaSales = 17,USASales = 10} , new Sales(){Category =“bananas”,EuropeSales = 4,AsiaSales = 31,USASales = 27}, new Sales(){Category =“cherries”,EuropeSales = 8,AsiaSales = 9,USASales = 30} };
我們分配數(shù)據(jù)源并將X軸的標(biāo)簽類(lèi)型設(shè)置為自定義文本。該XLabelPath屬性設(shè)置,提供了自定義標(biāo)簽的字段的名稱(chēng):
barChart1.DataSource = salesList; barChart1.XAxisSettings.LabelType = LabelType.CustomText; barChart1.XLabelPath = "Category";
教程持續(xù)更新中,感興趣的朋友記得持續(xù)關(guān)注后續(xù)教程~
相關(guān)推薦:
MindFusion.Diagramming for WinForms常見(jiàn)問(wèn)題集錦
MindFusion.Diagramming for Java問(wèn)題集錦
想要購(gòu)買(mǎi)MindFusion.Charting for WPF 正版授權(quán)的朋友可以。
更多精彩內(nèi)容,歡迎關(guān)注下方的微信公眾號(hào),及時(shí)獲取產(chǎn)品最新資訊▼▼▼
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: