You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need an API to fetch data? Consider [Cube](https://cube.dev/?ref=eco-vue-chartjs), an open-source API for data apps.
51
-
52
-
<br />
53
-
54
-
[](https://cube.dev/?ref=eco-vue-chartjs)
55
-
56
-
## How to use
57
-
58
-
This package works with version 2.x and 3.x of Vue.
59
-
60
-
Import the component.
61
-
62
-
```javascript
63
-
import { Bar } from'vue-chartjs'
64
-
```
65
-
66
-
For Vue 2 projects, you need to import from `vue-chartjs/legacy`.
67
-
68
-
```javascript
69
-
import { Bar } from'vue-chartjs/legacy'
70
-
```
71
-
72
-
Just create your own component.
46
+
Then, import and use individual components:
73
47
74
48
```vue
75
49
<template>
76
-
<Bar
77
-
:chart-options="chartOptions"
78
-
:chart-data="chartData"
79
-
:chart-id="chartId"
80
-
:dataset-id-key="datasetIdKey"
81
-
:plugins="plugins"
82
-
:css-classes="cssClasses"
83
-
:styles="styles"
84
-
:width="width"
85
-
:height="height"
86
-
/>
50
+
<Bar :data="data" :options="options" />
87
51
</template>
88
52
89
-
<script>
53
+
<script lang="ts">
54
+
import {
55
+
Chart as ChartJS,
56
+
Title,
57
+
Tooltip,
58
+
Legend,
59
+
BarElement,
60
+
CategoryScale,
61
+
LinearScale
62
+
} from 'chart.js'
90
63
import { Bar } from 'vue-chartjs'
91
-
import { Chart as ChartJS, Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale } from 'chart.js'
Need an API to fetch data? Consider [Cube](https://cube.dev/?ref=eco-vue-chartjs), an open-source API for data apps.
212
90
213
-
<script>
214
-
import BarChart from 'path/to/component/BarChart'
91
+
<br />
215
92
216
-
export default {
217
-
name: 'App',
218
-
components: { BarChart }
219
-
}
220
-
</script>
221
-
```
93
+
[](https://cube.dev/?ref=eco-vue-chartjs)
0 commit comments