2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Using the ChartDataBindModel class we can bind the data from database.First the datasource is set followed by the setting of the XName and YNames properties of the ChartDataBindModel.The labels for the X axis are also loaded from the database using an implementation of the ChartDataBindAxisLabelModel class. C#ChartDataBindModel model = null; ChartDataBindAxisLabelModel xAxisLabelModel = null; // A custom DataSet bound to the Demographics table private ChartAccessDataBind.DataSet1 dataSet11; this.oleDbDataAdapter1.Fill(this.dataSet11.Demographics); model = new ChartDataBindModel(this.dataSet11,"Demographics"); // The column that contains the X values. model.XName = "ID"; // The columns that contain the Y values. model.YNames = new string[]{"Population"}; ChartSeries series = this.chartControl1.Model.NewSeries("Data Bound Series"); series.Text = series.Name; series.SeriesModelImpl = model; series.Style.TextColor = Color.White ; series.Style.Font.Bold = true; this.chartControl1.Series.Add(series); this.xAxisLabelModel = new ChartDataBindAxisLabelModel(this.dataSet11,"Demographics"); // The columns that has the label values for the corresponding X values. this.xAxisLabelModel.LabelName = "City"; this.chartControl1.PrimaryXAxis.LabelsImpl = this.xAxisLabelModel; this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Custom; VBDim model As ChartDataBindModel = Nothing Dim xAxisLabelModel As ChartDataBindAxisLabelModel = Nothing ' A custom DataSet bound to the Demographics table Private dataSet11 As ChartAccessDataBind.DataSet1 Me.oleDbDataAdapter1.Fill(Me.dataSet11.Demographics) model = New ChartDataBindModel(Me.dataSet11,"Demographics") ' The column that contains the X values. model.XName = "ID" ' The columns that contain the Y values. model.YNames = New String(){"Population"} Dim series As ChartSeries = Me.chartControl1.Model.NewSeries("Data Bound Series") series.Text = series.Name series.SeriesModelImpl = model series.Style.TextColor = Color.White series.Style.Font.Bold = True Me.chartControl1.Series.Add(series) Me.xAxisLabelModel = New ChartDataBindAxisLabelModel(Me.dataSet11,"Demographics") ' The columns that has the label values for the corresponding X values. Me.xAxisLabelModel.LabelName = "City" Me.chartControl1.PrimaryXAxis.LabelsImpl = Me.xAxisLabelModel Me.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Custom This is illustrated in the Chart UG in this topic: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.