2X faster development
The ultimate UWP UI toolkit to boost your development speed.
Description: The DataTable type can be bound to the ItemsSource property in ChartSeries. Solution: The following code example illustrates how to bind the data tables in ChartSeries. XAML <Grid x:Name="grid"> <Grid.DataContext> <local:DataViewModel/> </Grid.DataContext>22 <chart:SfChart> <chart:ColumnSeries ItemsSource="{Binding Data}" XBindingPath="ProductName" YBindingPath="UnitsInStock"></chart:ColumnSeries> </chart:SfChart> </Grid> C# public class DataViewModel { DataSet dataset = new DataSet(); public DataViewModel() { AddData(); } public void AddData() { //Sets Database connection. string connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", @"..\..\Model\DataBase_File.mdb"); OleDbConnection Connection = new OleDbConnection(connectionString); Connection.Open(); OleDbCommand command = new OleDbCommand("Select Top 10 * from [Products]", Connection); OleDbDataAdapter DataAdapter = new OleDbDataAdapter(command); DataAdapter.Fill(dataset, "Product"); //Sets the DataTable to Data property. this.Data = dataset.Tables["Product"]; Connection.Close(); } public DataTable _data; public DataTable Data { get { return _data; } set { _data = value; } } } OutputFigure 1: ColumnSeries renders based on data table fields. |
2X faster development
The ultimate UWP UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.