public static StackedChart GetMyChart(string title, params DataSeries[] series) { StackedChart chart = new StackedChart { Effect = new System.Windows.Media.Effects.DropShadowEffect { BlurRadius = 10, ShadowDepth = 3 }, Title = title, Margin = new Thickness(5, 5, 5, 20) }; StackedDataSeries stacked = new StackedDataSeries(); chart.XLabels = series[0].Data.Keys.ToList(); chart.YValues = new List <DataSeries>(); chart.YValues.Add(stacked); foreach (var s in series) { if (s is ColumnDataSeries) { stacked.Parts.Add(s as ColumnDataSeries); } else { chart.YValues.Add(s); } } chart.ReadyControl(); return(chart); }
private void DefaultData() { XLabels = new List <string> { "2011", "2012", "2013", "2014", "2015" }; var data1 = new Dictionary <string, double> { { "2011", 135 }, { "2012", 143 }, { "2013", 196 }, { "2014", 203 }, { "2015", 210 } }; var data2 = new Dictionary <string, double> { { "2011", 96 }, { "2012", 101 }, { "2013", 133 }, { "2014", 150 }, { "2015", 180 } }; var data3 = new Dictionary <string, double> { { "2011", 221 }, { "2012", 256 }, { "2013", 334 }, { "2014", 409 }, { "2015", 523 } }; ColumnDataSeries series1 = new ColumnDataSeries { Data = data1, Title = "DATA1", Background = BuildGradient(Colors.YellowGreen) }; ColumnDataSeries series2 = new ColumnDataSeries { Data = data2, Title = "DATA2", Background = BuildGradient(Colors.Yellow) }; LineDataSeries series3 = new LineDataSeries { Data = data3, Title = "DATA3", Background = Brushes.Red }; StackedDataSeries series12 = new StackedDataSeries { Parts = new List <ColumnDataSeries> { series1, series2 } }; YValues = new List <DataSeries> { series12, series3 }; }