Xuni User Guide > Xuni Controls > FlexChart > Features > Mixed Charts |
You can add multiple series to your charts and set a different ChartType
for each series. Such charts are helpful in analyzing complex chart data on a single canvas. The same data can be used with different visualizations or related data can be displayed together to convey trends.
The following image shows a FlexChart with multiple series.
The following code examples demonstrate how to create multiple instances of type ChartSeries
with different ChartType
s and add them to the FlexChart.
C# |
Copy Code |
---|---|
public static FlexChart GetChartControl() { //Create an instance of the Control and set its properties FlexChart chart = new FlexChart(); FlexChartDataSource ds = new FlexChartDataSource(); chart.ItemsSource = ds.Data; chart.BindingX = "Name"; //Create the first series ChartSeries _series = new ChartSeries(chart, "2014 Sales", "Sales"); _series.ChartType = ChartType.Column; _series.Color = Color.FromHex("#89BE44"); //Create the second series series ChartSeries _series2 = new ChartSeries(chart, "2014 Expenses", "Expenses"); _series2.ChartType = ChartType.Column; _series2.Color = Color.FromHex("#F6546A"); //Create the third series ChartSeries _series3 = new ChartSeries(chart, "2014 Downloads", "Downloads"); _series3.ChartType = ChartType.Line; _series3.Color = Color.FromHex("#FFAA00"); //Add all the series to the chart chart.Series.Add(_series) ; chart.Series.Add(_series2); chart.Series.Add(_series3); return chart; } |
XAML |
Copy Code |
---|---|
<xuni:FlexChart x:Name="chart" ItemsSource="{Binding Data}" BindingX="Name" Grid.Row="1" Grid.ColumnSpan="2"> <xuni:FlexChart.Series> <xuni:ChartSeries x:Name="SalesData" Name="2014 Sales" Binding="Sales" ChartType="Column" Color="#89BE44"> </xuni:ChartSeries> <xuni:ChartSeries x:Name="ExpensesData" Name="2014 Expenses" Binding="Expenses" ChartType="Column" Color="#F6546A"> </xuni:ChartSeries> <xuni:ChartSeries x:Name="DownloadsData" Name="2014 Downloads" Binding="Sales" ChartType="Line" Color="#FFAA00"> </xuni:ChartSeries> </xuni:FlexChart.Series> </xuni:FlexChart> |