翻譯|其它|編輯:吳園園|2019-08-27 15:59:22.170|閱讀 230 次
概述:本文整理了用戶在使用MindFusion.Charting for WPF常見的問題,希望對您有所幫助。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
MindFusion.Charting for WPF支持所有主流的圖表類型,以及許多自定義的圖表功能。線形圖表控件允許你創建折線圖、面積圖、散點圖或它們之間的任何組合形式。條形圖表控件支持創建集群、堆疊或重疊的條形和柱狀圖。餅圖圖表控件則允許你創建環形圖表,并且還可對它們的厚度進行自定義調整。
本文整理了用戶在使用MindFusion.Charting for WPF常見的問題,希望對您有所幫助。
點擊下載MindFusion.Charting for WPF最新試用版
問:我想在圖表軸上顯示DateTime值。我使用數字作為點,但我不想顯示這些數據,我想顯示它附帶的DateTime值。這可以用你的工具嗎?
答: Wpf的圖表支持在任何圖表軸上繪制自定義標簽。自定義標簽既可以在軸的間隔位置繪制,也可以在該軸的數據點位置繪制。
在您的情況下,我們假設您要在軸的數據點位置繪制從數據源獲取的DateTime標簽。這是你的代碼:
//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";
請注意,設置標簽的格式非常重要。如果不這樣做,控件將嘗試使用標準轉換將DateTime值轉換為字符串,結果將不會如預期的那樣。
問:我有8個類別的數據,每個類別有3個不同的值。我想在堆積圖表中顯示這些類別,每個類別的名稱作為標簽但不知道如何操作。
答:您想要顯示的內容可以通過在條形圖控件中添加3個BarSeries來完成。然后,您可以將每個系列的XDataPath或YDataPath屬性綁定到數據源中的相應字段。將條形的類型設置為堆疊。
以下是構建堆積柱形圖的方法:
//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;
這是一個示例列表,其中包含用于綁定圖表的數據:
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} };
我們分配數據源并將X軸的標簽類型設置為自定義文本。該XLabelPath屬性設置,提供了自定義標簽的字段的名稱:
barChart1.DataSource = salesList; barChart1.XAxisSettings.LabelType = LabelType.CustomText; barChart1.XLabelPath = "Category";
教程持續更新中,感興趣的朋友記得持續關注后續教程~
相關推薦:
MindFusion.Diagramming for WinForms常見問題集錦
MindFusion.Diagramming for Java問題集錦
想要購買MindFusion.Charting for WPF 正版授權的朋友可以。
更多精彩內容,歡迎關注下方的微信公眾號,及時獲取產品最新資訊▼▼▼
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: