Skip to main content

Data and Metadata

Data

The content of the code block will have the chart definition as YAML/JSON, available properties:

NameTypeDefault ValueRequiredDescription
typebar, bubble, doughnut, line,pie, polarArea, radar, scatteryesChart.js chart type.
dataObjectyesThe data object that is passed into the Chart.js chart (required). See more.
optionsObject{}noThe options object that is passed into the Chart.js chart. See more
redrawbooleanfalsenoTeardown and redraw chart on every update.
datasetIdKeystring"label"noKey name to identificate dataset.
updateModeresize, reset, none, hide, show, normal, activenoA mode string to indicate transition configuration should be used. See more

Examples:

```chartjs
type: pie
data:
labels: ["Red", "Green", "Blue"]
datasets:
- label: "Colors"
data: [1, 1, 1]
backgroundColor: [
"rgba(255, 0, 0, 0.5)",
"rgba(0, 255, 0, 0.5)",
"rgba(0, 0, 255, 0.5)",
]
```

Metadata

You can also specify some self-explanatory parameters inside the language metastring (leave a space after the language): width, height, center, and title. The order is important! the title should always be the last.

Example:

```chartjs width=50% height=200px center title=Multitype Charts
{
"type": "bar",
"data": {
"labels": ["January", "February", "March", "April", "May", "June", "July"],
"datasets": [
{
"type": "line",
"label": "Dataset 1",
"borderColor": "rgb(255, 99, 132)",
"borderWidth": 2,
"fill": false,
"data": [4,9,4,8,5,1,1]
},
{
"type": "bar",
"label": "Dataset 2",
"backgroundColor": "rgb(53, 162, 235)",
"data": [0,2,6,1,7,13,2]
}
]
}
}
```