Bootstrap charts are graphical representations of data. They are responsive and easy to customize.
At your disposal are eight types of charts with multiple options for customization.
Initialization with data attributes.
DataLabels
plugin
In this section, you will find advanced information about the Line
,
Bar
, Pie
, Doughnut
, Polar
,
Radar
, Bubble
, Scatter
components. You
will learn which modules are required in this component, what are the
possibilities of configuring the component, and what events and methods you can
use in working with it.
Name | Parameters | Description | Example |
---|---|---|---|
update
|
data, config
|
Updates chart's data and calls .update(config) method |
instance.update(data, { duration: 800})
|
dispose
|
-
|
Removes a mdb.Chart instance |
instance.dispose()
|
You can initialize basic charts with not extensive options without using JavaScript. The data-type attribute is responsible for initialization via HTML if its value is valid.
Name | Type | Description |
---|---|---|
data-chart
|
String |
the attribute is responsible for initialization and is read as a type.
Bubble and scatter chart can't be
initialized via data attribute.
|
data-labels
|
String | Labels for x-axis |
data-dataset-label
|
String | label values ​​for datasets |
data-dataset-background-color
|
Color[ ] | It can be a single color or an array of colors for datasets |
data-dataset-border-color
|
Color[ ] | It can be a single border or line color or an array of border colors for datasets |
data-dataset-border-width
|
Number[ ] | It can be a single border thickness or a border thickness table for datasets |
data-dataset-data
|
Number[ ] | value sets for charts |
Charts have plenty of options that can you use.
The line 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 colour of a line is generally set this way.
All point* properties can be specified as an array. If these are set to an array value, the first value applies to the first point, the second value to the second point, and so on.
Name | Type | Description |
---|---|---|
label
|
String | The label for the dataset that appears in the legend and tooltips. |
xAxisID
|
String | The ID of the x-axis to plot this dataset on. If not specified, this defaults to the ID of the first found x-axis |
yAxisID
|
String | The ID of the y-axis to plot this dataset on. If not specified, this defaults to the ID of the first found y-axis. |
backgroundColor
|
Color | The fill color under the line. |
borderColor
|
Color | The color of the line. |
borderWidth
|
Number | The width of the line in pixels. |
borderDash
|
Number | The length and spacing of dashes. |
borderDashOffset
|
Number | Offset for line dashes. |
borderCapStyle
|
String | Cap style of the line. |
borderJoinStyle
|
String | Line joint style. |
cubicInterpolationMode
|
String | The algorithm used to interpolate a smooth curve from the discrete data points. |
fill |
Boolean/String | How to fill the area under the line. |
lineTension
|
Number | Bezier curve tension of the line. Set to 0 to draw straight lines. This option is ignored if monotone cubic interpolation is used. |
pointBackgroundColor
|
Color/Color[ ] | The fill color for points. |
pointBorderColor
|
Color/Color[ ] | The border color for points. |
pointBorderWidth
|
Number/Number[ ] | The width of the point border in pixels. |
pointRadius
|
Number/Number[ ] | The radius of the point shape. If set to 0, the point is not rendered. |
pointStyle
|
String/String[ ]/Image/Image[ ] | Style of the point. |
pointRotation
|
Number/Number[ ] | The rotation of the point in degrees. |
pointHitRadius
|
Number/Number[ ] | The pixel size of the non-displayed point that reacts to mouse events. |
pointHoverBackgroundColor
|
Color/Color[ ] | Point background color when hovered. |
pointHoverBorderColor
|
Color/Color[ ] | Point border color when hovered. |
pointHoverBorderWidth
|
Number/Number[ ] | The border width of a point when hovered over. |
pointHoverRadius
|
Number/Number[ ] | The radius of the point when hovered over. |
showLine
|
Boolean | If false, the line is not drawn for this dataset. |
spanGaps
|
Boolean | If true, lines will be drawn between points with no or null data. If false, points with NaN data will create a break in the line |
steppedLine
|
Boolean/String | If the line is shown as a stepped line. |
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 colour of the bars is generally set this way.
Some properties can be specified as an array. If these are set to an array value, the first value applies to the first bar, the second value to the second bar, and so on.
Name | Type | Description |
---|---|---|
label
|
String | The label for the dataset which appears in the legend and tooltips. |
xAxisID
|
String | The ID of the x axis to plot this dataset on. If not specified, this defaults to the ID of the first found x axis |
yAxisID
|
String | The ID of the y axis to plot this dataset on. If not specified, this defaults to the ID of the first found y axis. |
backgroundColor
|
Color/Color[ ] | The fill color of the bar. |
borderColor
|
Color/Color[ ] | The color of the bar border. |
borderWidth
|
Number/Number[ ] | The stroke width of the bar in pixels. |
borderSkipped
|
String | Which edge to skip drawing the border for. |
hoverBackgroundColor
|
Color/Color[ ] | The fill colour of the bars when hovered. |
hoverBorderColor
|
Color/Color[ ] | The stroke colour of the bars when hovered. |
hoverBorderWidth
|
Number/Number[ ] | The stroke width of the bars when hovered. |
The radar 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 colour of a line is generally set this way.
All point* properties can be specified as an array. If these are set to an array value, the first value applies to the first point, the second value to the second point, and so on.
Name | Type | Description |
---|---|---|
label
|
String | The label for the dataset which appears in the legend and tooltips. |
backgroundColor
|
Color | The fill color under the line. |
borderColor
|
Color | The color of the line. |
borderWidth
|
Number | The width of the line in pixels. |
borderDash
|
Number[ ] | Length and spacing of dashes. S |
borderDashOffset
|
Number | Offset for line dashes. |
borderCapStyle
|
String | Cap style of the line |
borderJoinStyle
|
String | Line joint style |
fill |
Boolean/String | How to fill the area under the line. |
lineTension
|
Number | Bezier curve tension of the line. Set to 0 to draw straightlines. |
pointBackgroundColor
|
Color/Color[ ] | The fill color for points. |
pointBorderColor
|
Color/Color[ ] | The border color for points. |
pointBorderWidth
|
Number/Number[ ] | The width of the point border in pixels. |
pointRadius
|
Number/Number[ ] | TThe radius of the point shape. If set to 0, the point is not rendered. |
pointRotation
|
Number/Number[ ] | The rotation of the point in degrees. |
pointStyle
|
String/String[ ]/Image/Image[ ] | Style of the point. |
pointHitRadius
|
Number/Number[ ] | The pixel size of the non-displayed point that reacts to mouse events. |
pointHoverBackgroundColor
|
Color/Color[ ] | Point background color when hovered. |
pointHoverBorderColor
|
Color/Color[ ] | Point border color when hovered. |
pointHoverBorderWidth
|
Number/Number[ ] | Border width of point when hovered. |
pointHoverRadius
|
Number/Number[ ] | The radius of the point when hovered. |
Name | Type | Description |
---|---|---|
backgroundColor
|
Color[ ] | The fill color of the arcs in the dataset. |
borderColor
|
Color[ ] | The border color of the arcs in the dataset. |
borderWidth
|
Number[ ] | The border width of the arcs in the dataset. |
hoverBackgroundColor
|
Color[ ] | The fill colour of the arcs when hovered. |
hoverBorderColor
|
Color[ ] | The stroke colour of the arcs when hovered. |
hoverBorderWidth
|
Number[ ] | The stroke width of the arcs when hovered. |
Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value. This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.
Name | Type | Description |
---|---|---|
backgroundColor
|
Color | The fill color of the arcs in the dataset. |
borderColor
|
Color | The border color of the arcs in the dataset. |
borderWidth
|
number | The border width of the arcs in the dataset. |
hoverBackgroundColor
|
Color | The fill colour of the arcs when hovered. |
hoverBorderColor
|
Color | The stroke colour of the arcs when hovered. |
hoverBorderWidth
|
number | The stroke width of the arcs when hovered. |
A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles.
Name | Type | Description |
---|---|---|
backgroundColor
|
Color | bubble background color |
borderColor
|
Color | bubble border color |
borderWidth
|
Number | bubble border width (in pixels) |
hoverBackgroundColor
|
Color | bubble background color when hovered |
hoverBorderColor
|
Color | bubble border color when hovered |
hoverBorderWidth
|
Number | bubble border width when hovered (in pixels) |
hoverRadius
|
Number | bubble additional radius when hovered (in pixels) |
hitRadius
|
Number | bubble additional radius for hit detection (in pixels). |
label
|
String | The label for the dataset which appears in the legend and tooltips. |
order
|
Number | The drawing order of dataset. |
pointStyle
|
String | bubble shape style. |
rotation
|
Number | bubble rotation (in degrees). |
radius
|
Number | bubble radius (in pixels). |
Scatter charts are based on basic line charts with the x axis changed to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties.
The scatter chart supports all of the same properties as the line chart |
---|
Charts displays data about the dataset that are appering on the chart.
Name | Type | Default | Description |
---|---|---|---|
display
|
Boolean | true | showing legend |
position
|
String | 'top' | Position of the legend. |
fullWidth
|
Boolean | true | Marks that this box should take the full width of the canvas (pushing down other boxes). This is unlikely to need to be changed in day-to-day use. |
onClick
|
Function |
A callback that is called when a click event is registered on a label item |
|
onHover
|
Function |
A callback that is called when a 'mousemove' event is registered on top of a label item |
|
reverse
|
Boolean | false |
Legend will show datasets in reverse order. |
labels
|
Object |
See documentation about labels in table below. |
The legend label configuration is nested below the legend configuration using
the labels
key.
Name | Type | Default | Description |
---|---|---|---|
boxWidth
|
Number | 40 | width of coloured box |
fontSize
|
Number | 12 | font size of text |
fontStyle
|
String | 'normal' | font style of text |
fontColor
|
Color | '#666' |
Color of text |
fontFamily
|
String | "Roboto" |
Font family of legend text. |
padding
|
Number | 10 |
Padding between rows of colored boxes. . |
generateLabels
|
Function |
Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. |
|
filter
|
Function | null |
Filters legend items out of the legend. Receives 2 parameters, a Legend Item and the chart data. |
usePointStyle
|
Boolean | false |
Label style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case). |
backgroundColor
|
Style/Null | Null |
Background color of datalabels. . |
Charts animates out of the box. A number of options are provided to configure how the animiaton looks and how long it takes.
Name | Type | Default | Description |
---|---|---|---|
duration
|
Number | 1000 | The number of milliseconds an animation takes |
easing
|
String | easeOutQuart | Easing function to use. |
onProgress
|
Function | null | Callback called at the end of an animation. |
onComplete
|
Function | null |
Callback called on each step of an animation. |
linear
easeInQuad
easeOutQuad
easeInOutQuad
easeInCubic
easeOutCubic
easeInOutCubic
easeInQuart
easeOutQuart
easeInOutQuart
easeInQuint
easeOutQuint
easeInOutQuint
easeInSine
easeOutSine
easeInOutSine
easeInExpo
easeOutExpo
easeInOutExpo
easeInCirc
easeOutCirc
easeInOutCirc
easeInElastic
easeOutElastic
easeInOutElastic
easeInBack
easeOutBack
easeInOutBack
easeInBounce
easeOutBounce
easeInOutBounce
Name | Type | Default | Description |
---|---|---|---|
events
|
string[ ] |
['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']
|
The events option defines the
browser events that the chart should listen to for tooltips and
hovering.
|
onHover |
function | null |
Called when any of the events fire. Called in the context of the chart and passed the event and an array of active elements (bars, points, etc). |
onClick
|
function | null |
Called if the event is of type
'mouseup' or
'click' . Called in the context
of the chart and passed the event and an array of active elements.
|