Example E1213
Visible to All Users

Chart for WinForms - Create a Side-by-Side Bar Chart

This example shows how to create a Side-by-Side Bar chart at runtime.

Resulting chart

In this example, you add Series objects to the ChartControl.Series collection and then populate the Series.Points collection with points for each series.

The Chart Control uses the XY-Diagram to display bar series. Cast the ChartControl.Diagram property to the XYDiagram type to access diagram settings. The Chart Control determines the diagram type based on the series that is added first. We recommend that you access the diagram to configure its settings after at least one series is added to the chart.

Note that you can cast the series' View property to the SideBySideBarSeriesView type to access bar series appearance settings.

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

Form1.cs(vb)
C#
using System; using System.Windows.Forms; using DevExpress.XtraCharts; // ... namespace SideBySideBar2D { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Create an empty chart. ChartControl sideBySideBarChart = new ChartControl(); // Create the first side-by-side bar series and add points to it. Series series1 = new Series("Side-by-Side Bar Series 1", ViewType.Bar); series1.Points.Add(new SeriesPoint("A", 10)); series1.Points.Add(new SeriesPoint("B", 12)); series1.Points.Add(new SeriesPoint("C", 14)); series1.Points.Add(new SeriesPoint("D", 17)); // Create the second side-by-side bar series and add points to it. Series series2 = new Series("Side-by-Side Bar Series 2", ViewType.Bar); series2.Points.Add(new SeriesPoint("A", 15)); series2.Points.Add(new SeriesPoint("B", 18)); series2.Points.Add(new SeriesPoint("C", 25)); series2.Points.Add(new SeriesPoint("D", 33)); // Add the series to the chart. sideBySideBarChart.Series.Add(series1); sideBySideBarChart.Series.Add(series2); // Hide the legend (if necessary). sideBySideBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; // Rotate the diagram (if necessary). ((XYDiagram)sideBySideBarChart.Diagram).Rotated = true; // Add a title to the chart (if necessary). ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "Side-by-Side Bar Chart"; sideBySideBarChart.Titles.Add(chartTitle1); // Add the chart to the form. sideBySideBarChart.Dock = DockStyle.Fill; this.Controls.Add(sideBySideBarChart); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.