Chart can bind with DataTable, List and any implementation of IList, IEnumerable, etc. We can use DataTable to connect and retrieve the data from SQL Database and then bind the DataTable with chart.
The following code snippet illustrates retrieving data from database
After retrieving the data from database, we can bind it with chart using the DataSource property and DataBind method of Chart. A field in data table that corresponds to the X values (values along x-axis) of chart should be mapped with the property XName of the series. Similarly, field corresponding to the Y values should be mapped with the YName property of series.
For the OHLC type series, you have to map four fields High, Low, Open and Close to bind the data source and for the bubble series you have to map the Size field along with the XName and YName properties.
The following code snippet illustrates binding the retrieved data with Chart
The following screenshot displays a simple chart bounded to data from SQL Database
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|
|7684||04/27/2017||04/27/2017||ASP.NET Web Forms||Chart|