using Syncfusion.UI.Xaml.Charts;
public static SfChart InitCompareChart(string fundName, double tenThousandRate, double sevenRate) { List<FundDay> fdl = new List<FundDay>(); fdl.Add(new FundDay(fundName, tenThousandRate, sevenRate)); fdl.Add(new FundDay("定期三年", 1.0274, 3.75)); fdl.Add(new FundDay("定期二年", 0.5753, 2.10)); fdl.Add(new FundDay("定期一年", 0.4109, 1.50)); fdl.Add(new FundDay("定期半年", 0.3562, 1.30)); fdl.Add(new FundDay("定期三月", 0.3014, 1.10)); fdl.Add(new FundDay("活期", 0.0959, 0.35)); SfChart chart = new SfChart(); chart.HorizontalAlignment = HorizontalAlignment.Stretch; chart.VerticalAlignment = VerticalAlignment.Stretch; chart.Header = string.Format("{0}与央行基准存款利率比较", fundName); chart.FontSize = 20; //https://www.syncfusion.com/products/wpf/sfchart/chart-types BarSeries series1 = new BarSeries();//ColumnSeries 垂直;BarSeries 水平 series1.Label = "七日年化收益(%)"; series1.ItemsSource = fdl; series1.XBindingPath = "Date"; // XBindingPath to provide the path for category data in the source object. series1.YBindingPath = "SevenRate"; // YBindingPath to provide the path for numeric data in the source object. series1.AdornmentsInfo = new ChartAdornmentInfo(); series1.AdornmentsInfo.ShowLabel = true; BarSeries series2 = new BarSeries(); series2.Label = "当日万份收益(元)"; series2.ItemsSource = fdl; series2.XBindingPath = "Date"; series2.YBindingPath = "TenThousandRate"; series2.AdornmentsInfo = new ChartAdornmentInfo(); series2.AdornmentsInfo.ShowLabel = true; //Adding Series to the Chart Series Collection chart.Series.Add(series1); chart.Series.Add(series2); //http://help.syncfusion.com/winrt/sfchart/axis chart.PrimaryAxis = new CategoryAxis(); chart.PrimaryAxis.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Green); chart.SecondaryAxis = new NumericalAxis(); chart.SecondaryAxis.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Green); //Adding Legends for the chart chart.Legend = new ChartLegend() { Visibility = Visibility.Visible }; return chart; }
this.chartGrid.Children.Clear(); SfChart chart = Functions.WinrtChartHelper.InitCompareChart(CurrentFund); this.chartGrid.Children.Add(chart);
//https://www.syncfusion.com/downloads/communitylicense/confirmation
//http://help.syncfusion.com/winrt/sfchart/getting-started