A bar chart provides a way of showing data values represented as vertical bars. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
Dataset Properties
Namespaces:
data.datasets[index]
– options for this dataset onlyoptions.datasets.bar
– options for all bar datasetsoptions.elements.bar
– options for all bar elementsoptions
– options for the whole chart
The bar chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the color of the bars is generally set this way. Only the data
option needs to be specified in the dataset namespace.
borderSkipped
This setting is used to avoid drawing the bar stroke at the base of the fill, or disable the border radius. In general, this does not need to be changed except when creating chart types that derive from a bar chart.
borderWidth
If this value is a number, it is applied to all sides of the rectangle (left, top, right, bottom), except borderSkipped
. If this value is an object, the left
property defines the left border width. Similarly, the right
, top
, and bottom
properties can also be specified. Omitted borders and borderSkipped
are skipped.
borderRadius
If this value is a number, it is applied to all corners of the rectangle (topLeft, topRight, bottomLeft, bottomRight), except corners touching the borderSkipped
. If this value is an object, the topLeft
property defines the top-left corners border radius. Similarly, the topRight
, bottomLeft
, and bottomRight
properties can also be specified. Omitted corners and those touching the borderSkipped
are skipped. For example if the top
border is skipped, the border radius for the corners topLeft
and topRight
will be skipped as well.
inflateAmount
This option can be used to inflate the rects that are used to draw the bars. This can be used to hide artifacts between bars when barPercentage
(#barpercentage) * categoryPercentage
(#categorypercentage) is 1. The default value 'auto'
should work in most cases
barPercentage
Percent (0-1) of the available width each bar should be within the category width. 1.0 will take the whole category width and put the bars right next to each other. more…
categoryPercentage
Percent (0-1) of the available width each category should be within the sample width. more…
barThickness
If this value is a number, it is applied to the width of each bar, in pixels. When this is enforced, barPercentage
and categoryPercentage
are ignored.
If set to 'flex'
, the base sample widths are calculated automatically based on the previous and following samples so that they take the full available widths without overlap. Then, bars are sized using barPercentage
and categoryPercentage
. There is no gap when the percentage options are 1. This mode generates bars with different widths when data are not evenly spaced.
If not set (default), the base sample widths are calculated using the smallest interval that prevents bar overlapping, and bars are sized using barPercentage
and categoryPercentage
. This mode always generates bars equally sized.
maxBarThickness
Set this to ensure that bars are not sized thicker than this