Bar charts compare categorical data through the horizontal bars, where length of each bar represents the value of the corresponding category. Y-axis in these charts is a category axis. For example, sales of various product categories can be well presented through a bar chart.
Column charts are simply vertical version of bar charts and they use X- axis as a category axis. Though bar charts and column charts can be used interchangeably, column charts are preferred where number of values is too large to be accommodated on an X-axis while bar charts are preferred in the case of long category titles which are difficult to fit on an X-axis or in the case of large number of categories. For example, population share of different countries across the globe is good example that can be demonstrated using a column chart.
Bar Chart |
Column Chart |
---|---|
With FlexChart, you can create a bar chart and a column chart by setting the ChartType property of FlexChart class to Bar or Column. This property accepts the values from ChartType enumeration of C1.Chart namespace.
FlexChart also provides options to cluster and stack the bar and column charts. While cluster is simply created by adding the multiple series with same base category to the chart, stacking can be done by setting the Stacking property of FlexChart class to Stacked or Stacked100pc. Stacked charts are used for demonstrating the part-to-whole relationship that is, for displaying the cumulative values of categories. For example, population of each gender in different countries can be presented by a stacked column chart. On the other hand, stacked 100 charts are used to present the percentage share of the values.
Clustered Column Chart |
Stacked Column Chart |
Stacked 100 Column Chart |
---|---|---|
To create a bar or column chart using FlexChart:
At design-time
Using code
To create a WinForms bar chart through code, the first step after initializing the control is to clear the default series and add a new series using the Add method. Set up the data source through the DataSource property and configure the X and Y axes by setting the BindingX and Binding property. You also need to set up the chart by setting the ChartType property and other required properties.
Note that the above sample code uses a custom method named GetData to supply data. You can set up the data source as per your requirements.