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
Copy file name to clipboardExpand all lines: docs/guide/README.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,20 @@ It abstracts the basic logic but exposes the Chart.js object to give you maximal
12
12
13
13
### NPM
14
14
15
-
You can install `vue-chartjs` over `npm`. However you also need to add `chart.js` as a dependency to your project. Because `Chart.js` is a peerDependency. This way you have full control over the versioning of Chart.js
15
+
You can install `vue-chartjs` over `npm`. However, you also need to add `chart.js` as a dependency to your project. Because `Chart.js` is a peerDependency. This way you have full control over the versioning of Chart.js
16
16
17
17
`yarn add vue-chartjs chart.js` or `npm install vue-chartjs chart.js --save`
18
18
19
19
::: tip
20
-
If you are using vue 1.x please use the `legacy` tag. However the Vue 1 version is not maintained anymore.
20
+
If you are using vue 1.x please use the `legacy` tag. However, the Vue 1 version is not maintained anymore.
21
21
22
22
`yarn add vue-chartjs@legacy`
23
23
:::
24
24
25
25
### Browser
26
26
27
27
You can also use `vue-chartjs` directly in the browser.
28
-
First add the `Chart.js` script and then the `vue-chartjs` script.
28
+
First, add the `Chart.js` script and then the `vue-chartjs` script.
@@ -36,13 +36,13 @@ First add the `Chart.js` script and then the `vue-chartjs` script.
36
36
37
37
Every chart type that is available in `Chart.js` is exported as a named component and can be imported as such. These components are normal Vue components, however you need to `extend` it.
38
38
39
-
The idea behind `vue-chartjs` is to provide easy to use components, with maximum flexibility and extensibility. To achive this, you need to create your own *Chart Component* and extend it with the provided `vue-chartjs` components.
39
+
The idea behind `vue-chartjs` is to provide easy to use components, with maximum flexibility and extensibility. To achieve this, you need to create your own *Chart Component* and extend it with the provided `vue-chartjs` components.
40
40
41
41
This way, the methods and logic in the Chart components, get merged into your own chart component.
42
42
43
43
## Creating your first Chart
44
44
45
-
You need to import the base chart and extend it. This gives more flexibility when working with different data. You can encapsulate your components and use props to pass data or you can input them directly inside the component. However your component is not reusable this way.
45
+
You need to import the base chart and extend it. This gives more flexibility when working with different data. You can encapsulate your components and use props to pass data or you can input them directly inside the component. However, your component is not reusable this way.
46
46
47
47
You can import the whole package or each module individual. Then you need either to use `extends:` or `mixins:[]`. And then in the `mounted()` hook, call `this.renderChart()`. This will create your chart instance.
48
48
@@ -63,11 +63,11 @@ You can either use `extends: Bar` or `mixins: [Bar]`
63
63
64
64
The method `this.renderChart()` is provided by the `Bar` component and is accepting two parameters. Both are `objects`. The first one is your chart data and the second one is an options object.
65
65
66
-
Check out the offical[Chart.js docs](http://www.chartjs.org/docs/latest/#creating-a-chart) to see the object structure you need to provide.
66
+
Check out the official[Chart.js docs](http://www.chartjs.org/docs/latest/#creating-a-chart) to see the object structure you need to provide.
67
67
68
68
### Vue Single File Components
69
69
70
-
Most examples in the docs are based on javascript files and not `.vue` files. This is because you mostly will only need the `<script>` block. You can however use `.vue` files as well.
70
+
Most examples in the docs are based on javascript files and not `.vue` files. This is because you mostly will only need the `<script>` block. You can, however, use `.vue` files as well.
71
71
72
72
**Chart.vue**
73
73
@@ -94,7 +94,7 @@ Do not include the `<template>` tag to your `.vue` files. Vue can **not** merge
94
94
95
95
## Updating Charts
96
96
97
-
Chart.js does not provide a live update if you change the datasets. However `vue-chartjs` provides two mixins to achieve this.
97
+
Chart.js does not provide a live update if you change the datasets. However,`vue-chartjs` provides two mixins to achieve this.
98
98
99
99
-`reactiveProp`
100
100
-`reactiveData`
@@ -202,7 +202,7 @@ The reactive mixins will emit events if the data changes. You can listen to them
202
202
203
203
### Troubleshooting
204
204
205
-
The reactivity system at it's current state is not **robust**. You will run into several problems with it, because there are many use-cases and ways to pass in your data.
205
+
The reactivity system at its current state is not **robust**. You will run into several problems with it because there are many use-cases and ways to pass in your data.
206
206
207
207
#### Options
208
208
@@ -260,9 +260,9 @@ watch: {
260
260
261
261
### Chart with props
262
262
263
-
Your goal should be to create reuseable chart components. For this purpose you should utilize Vue.js props to pass in your options and your chart data. This way the chart itself does not care,about fetching data and is only for presentation.
263
+
Your goal should be to create reusable chart components. For this purpose, you should utilize Vue.js props to pass in your options and your chart data. This way the chart itself does not care,about fetching data and is only for presentation.
264
264
265
-
First create your component
265
+
First, create your component
266
266
267
267
```js
268
268
import { Line } from'vue-chartjs'
@@ -327,7 +327,7 @@ export default {
327
327
328
328
### Chart with API data
329
329
330
-
It is a common pattern to use an API to get your data. However there are some things to keep in mind. The most common problem is, that you mount your chart component directly and pass in data from an async api call. The problem with this approach is, that chart.js tries to render your chart and access the chart data, but your api call is async. So you chart mounts before your data arrives.
330
+
It is a common pattern to use an API to get your data. However, there are some things to keep in mind. The most common problem is, that you mount your chart component directly and pass in data from an async API call. The problem with this approach is, that chart.js tries to render your chart and access the chart data, but your API call is async. So you chart mounts before your data arrives.
331
331
332
332
To prevent this, a simple `v-if` is the best solution.
333
333
@@ -395,7 +395,7 @@ export default {
395
395
396
396
### Chart with dynamic styles
397
397
398
-
You can set `responsive: true` and pass in an styles object which get applied as inline styles to the outer div. This way you can change the height and width of the outer container dynamically. Which is not the default behaviour of chart.js. It is best to use computed properties for this.
398
+
You can set `responsive: true` and pass in a styles object which get applied as inline styles to the outer div. This way you can change the height and width of the outer container dynamically. Which is not the default behaviour of chart.js. It is best to use computed properties for this.
399
399
400
400
::: warning
401
401
You need to set `position: relative`
@@ -437,7 +437,7 @@ export default {
437
437
438
438
Sometimes you need to extend the default Chart.js charts. There are a lot of [examples](http://www.chartjs.org/docs/latest/developers/charts.html) how to extend and modify the default charts. Or you want to create a own chart type.
439
439
440
-
In `vue-chartjs` you can do this pretty much the same way.
440
+
In `vue-chartjs`, you can do this pretty much the same way.
441
441
442
442
```js
443
443
// 1. Import Chart.js so you can use the global Chart object
0 commit comments