Categories &

Functions List

Class Definition: BarData

chartjs: obj = BarData (data)

Create a BarData object.

obj = BarData (data) returns a BarData object, in which data must be a nonempty numerical vector containing the bar heights of a single dataset. Constructing a BarData object always assigns the default property values, which can later be modified using dot notation syntax.

A BarData object, obj, contains the following properties:

FieldDescription
backgroundColorA Color object defining the color of the face of the bars. Default is empty, in which case and a color is assigned automatically by the Chart.js library.
baseA numeric scalar value. It defines the base value for the bar in data units along the value axis (the y-axis by default).
barPercentageA numeric scalar value. It defines the percent, in the range [0-1], of the available width each bar should be within the category width. barPercentage = 1.0 will take the whole category width and put the bars right next to each other.
barThicknessEither a numeric scalar or a character vector. When numeric, it defines the width of each bar in pixels, in which case barPercentage and categoryPercentage properties 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 the barPercentage and categoryPercentage properties. There is no gap when the percentage options are 1. This mode generates bars with different widths when data are not evenly spaced. By default it is empty, in which case the base sample widths are calculated using the smallest interval that prevents bar overlapping, and bars are sized using barPercentage and categoryPercentage properties. This mode always generates bars equally sized.
borderColorA Color object defining the color of the border line of the bars. Default is empty, in which case a color is assigned automatically by the Chart.js library.
borderSkippedA boolean scalar or a character vector. This setting is used to avoid drawing any given border of each bar. As a boolean value, false does not skip any borders and true skips drawing all borders. As a character vector, it can take any of the following values: 'start', 'end', 'middle', 'bottom', 'left', 'top', and 'right'. 'middle' is only valid on stacked bars, in which case the borders between stacked bars are skipped.
borderRadiusA numeric scalar value defining the corner radius of the each bar in pixels. Omitted borders as defined by the borderSkipped property are unaffected.
borderWidthA numeric scalar value defining the width of the each bar’s borders in pixels. Omitted borders as defined by the borderSkipped property are unaffected.
categoryPercentageA numeric scalar value, which defines the percent, in the range [0-1], of the available width each category should be within the sample width.
clipA numeric scalar value defining the pixels to clip relative to the chart’s area. Positive value allows overflow, negative value clips that many pixels inside chartArea. Defaults to zero pixels.
dataA numeric vector assigned at construction of the BarData object. It cannot be empty.
groupedA boolean scalar defining how the bars are grouped on the index axis (the x-axis by default). When true, all the datasets at same index value will be placed next to each other centering on that index value. When false, each bar is placed on its actual index-axis value.
hoverBackgroundColorA Color object defining the color of the face of each bar, when the mouse hovers over it. Default is empty, in which case the color is the same as in backgroundColor.
hoverBorderColorA Color object defining the color of the borders of each bar, when the mouse hovers over it. Default is empty, in which case the color is the same as in borderColor.
hoverBorderWidthA numeric scalar value defining the width of the each bar’s borders in pixels, when the mouse hovers over it. Omitted borders as defined by the borderSkipped property are unaffected.
hoverBorderRadiusA numeric scalar value defining the corner radius of the each bar in pixels, when the mouse hovers over it. Omitted borders as defined by the borderSkipped property are unaffected.
indexAxisA character vector defining the base axis of the dataset. 'x' defines a vertical bar chart (default) and 'y' defines a horizontal bar chart
inflateAmountEither a numeric scalar or a character vector. When numeric, it defines the amount to inflate the rectangulars used to draw the bars. This is useful for hiding artifacts between bars when barPercentage× categoryPercentage = 1. The default value is 'auto', which should work in most cases.
labelA character vector defining the label of the dataset which appears in the legend and tooltips.
maxBarThicknessA numeric scalar value defining the maximum thickness of the bars in pixels.
minBarLengthA numeric scalar value defining the minimum height of the bars in pixels.
orderA numeric scalar defining the order of the dataset, which affects order for stacking, tooltip and legend.
skipNullA boolean scalar. If true or empty (default), the null or undefined values in data will not be used for spacing calculations when determining bar size.
stackA character vector defining the ID of the group which this dataset belongs to (when stacked, each group will be a separate stack).

See also: BarChart, Color, Fill

Source Code: BarData

Method: jsonstring

BarData: json = jsonstring (obj)

Generate the JSON string from a BarData object.

jsonstring (obj) returns a character vector, json, describing the context of a BarData dataset in json format.

See also: BarData, BarChart