SharpPlot Reference > SharpPlot Methods > DrawBarChart Method

SharpPlot.DrawBarChart Method

Constructs a grouped or stacked barchart from given data values.


sp = new SharpPlot(180,120);
data = new int[] {18,27,31,12,19,23};

Barcharts may be drawn vertically or horizontally – the short tutorial shows a few of the possibilities and some sample code.



Bar charts are generally used to represent data which fall in clear groupings (such as regional totals) where the bars are equally spaced along an arbitrary X-axis. The bars are often labelled with the data value, or possibly with the name of the group as an alternative to specifying X-axis labels.

SharpPlot treats arrays of arrays of values as representing multiple data series, and creates one group of bars for each series, so two series (each with 12 items) would make 12 pairs of bars, probably labelled ‘Jan’ ...’Dec’. By default, the bars are drawn as groups (you may control the spacing with the Gap and GroupGap properties) but the bars may also be stacked to show a cumulative total. The Key would generally be used to identify the groups – if you have used GroupBy to create the groups from a single column of data, the key is preset for you to the group names.

Barcharts are normally drawn vertically, but may be switched to horizontal if required. This is often a better style of the bar labels may be quite long, as it is easy to make more space in the left margin.

See also ...

Bar charts for small series | SharpPlot Members | SharpPlot.BarChartStyle Property | SharpPlot.DrawXBarChart Method

Send comments on this topic
© Dyalog Ltd 2016