| |
 |
How to: Display Automatically Created Series in Separate Panes
This example demonstrates how to display automatically created series in separate Panes.
For this example to work correctly, do the following.
- Start MS Visual Studio (2008 or 2010), and create a new Windows Forms Application, or open an existing one.
- Include all necessary assemblies to the References list of your project.
-
Open the Solution Explorer window (e.g. by pressing CTRL+ALT+L), right-click the WindowsApplication1 item and in the invoked menu, point to Add and click Existing Item.... Then, locate the gsp.mdb file (it is shipped with XtraCharts suite and located in the directory, where you installed DevExpress demos) and click Add. In the displayed dialog, select the GSP table of this database.
A dataset (named gspDataSet) is automatically created after performing the above steps.
- Drop a button onto the form and add the following code to the Button1.Click event handler.
C# |
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraCharts;
using gspDataSetTableAdapters;
private void button1_Click(object sender, EventArgs e) {
XtraForm form = new XtraForm();
form.Text = "Multiple Panes and Chart Binding";
form.Size = new Size(800, 600);
ChartControl chart = new ChartControl();
chart.BoundDataChanged += new BoundDataChangedEventHandler(chart_BoundDataChanged);
gspDataSet dataSet = new gspDataSet();
GSPTableAdapter dataAdapter = new GSPTableAdapter();
dataAdapter.Fill(dataSet.GSP);
chart.DataSource = dataSet.GSP;
chart.SeriesDataMember = "Year";
chart.SeriesTemplate.ArgumentDataMember = "Region";
chart.SeriesTemplate.ValueDataMembers[0] = "GSP";
chart.Dock = DockStyle.Fill;
form.Controls.Add(chart);
form.Show();
}
private void chart_BoundDataChanged(object sender, EventArgs e) {
ChartControl chart = (ChartControl)sender;
if(chart.Series.Count > 0) {
XYDiagram diagram = (XYDiagram)chart.Diagram;
diagram.Panes.Clear();
for(int i = 1; i < chart.Series.Count; i++) {
XYDiagramPane pane = new XYDiagramPane("The Pane's Name");
diagram.Panes.Add(pane);
XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)chart.Series[i].View;
view.Pane = pane;
}
}
}
|
VB |
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Imports DevExpress.XtraCharts
Imports gspDataSetTableAdapters
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles button1.Click
Dim form As XtraForm = New XtraForm()
form.Text = "Multiple Panes and Chart Binding"
form.Size = New Size(800, 600)
Dim chart As ChartControl = New ChartControl()
AddHandler chart.BoundDataChanged, AddressOf chart_BoundDataChanged
Dim dataSet As gspDataSet = New gspDataSet()
Dim dataAdapter As GSPTableAdapter = New GSPTableAdapter()
dataAdapter.Fill(dataSet.GSP)
chart.DataSource = dataSet.GSP
chart.SeriesDataMember = "Year"
chart.SeriesTemplate.ArgumentDataMember = "Region"
chart.SeriesTemplate.ValueDataMembers(0) = "GSP"
chart.Dock = DockStyle.Fill
form.Controls.Add(chart)
form.Show()
End Sub
Private Sub chart_BoundDataChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim chart As ChartControl = CType(sender, ChartControl)
If chart.Series.Count > 0 Then
Dim diagram As XYDiagram = CType(chart.Diagram, XYDiagram)
diagram.Panes.Clear()
Dim i As Integer = 1
Do While i < chart.Series.Count
Dim pane As XYDiagramPane = New XYDiagramPane("The Pane's Name")
diagram.Panes.Add(pane)
Dim view As XYDiagramSeriesViewBase = CType _
(chart.Series(i).View, XYDiagramSeriesViewBase)
view.Pane = pane
i += 1
Loop
End If
End Sub
|

See Also
Is this topic helpful?
Additional Feedback
Close
|