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/README.md
+25-27Lines changed: 25 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,26 @@ search: en
3
3
---
4
4
5
5
# vue-chartjs
6
-
**vue-chartjs** is a wrapper for [Chart.js](https://github.com/chartjs/Chart.js) in vue. You can easily create reuseable chart components.
6
+
**vue-chartjs** is a wrapper for [Chart.js](https://github.com/chartjs/Chart.js) in Vue. You can easily create reusable chart components.
7
7
8
8
## Introduction
9
-
`vue-chartjs`let you use chart.js without much hassle inside vue. It's perfect for people who need simple charts up and running as fast as possible.
9
+
`vue-chartjs`lets you use Chart.js without much hassle inside Vue. It's perfect for people who need simple charts up and running as fast as possible.
10
10
11
-
It abstracts the basic logic but exposes the chart.js object to give you the most possible flexibility.
11
+
It abstracts the basic logic but exposes the Chart.js object to give you maximal flexibility.
12
12
13
13
## Installation
14
14
If you are working with Vue.js 2+ simple run:
15
15
16
16
`yarn add vue-chartjs chart.js`
17
17
18
-
If you are using vue 1.x please use the `legacy` tag. However the vue 1 version is not maintained anymore.
18
+
If you are using vue 1.x please use the `legacy` tag. However the Vue 1 version is not maintained anymore.
19
19
20
20
`yarn add vue-chartjs@legacy`
21
21
22
22
## Quick Start
23
23
24
-
You need to import the base chart and extend it. This gives much more flexibility when working with different data.
25
-
You can encapsulate your components and use props to pass data or you can directly imput them inside the component. However this way, your component is not reuseable.
24
+
You need to import the base chart and extend it. This gives more flexibility when working with different data.
25
+
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.
26
26
27
27
You can import the whole package or each module individual.
28
28
@@ -38,7 +38,7 @@ export default Bar.extend({
38
38
})
39
39
```
40
40
41
-
You can pass the `renderChart()` method, two arguments:
41
+
You can pass two arguments to the `renderChart()` method:
42
42
43
43
- Data object
44
44
- Options object
@@ -80,7 +80,7 @@ Here are some exmaples
80
80
81
81
### Chart with props
82
82
83
-
You can create the data and options props to pass data to the chart.
83
+
You can create data and options props to pass data to the chart.
84
84
85
85
```javascript
86
86
// LineChart.js
@@ -100,7 +100,7 @@ After you add your component you can use it:
100
100
<line-chart:data="{your data object}":options="{your options}"></line-chart>
101
101
```
102
102
103
-
If you want to overwrite the width and height:
103
+
If you want to overwrite width and height:
104
104
105
105
```html
106
106
<line-chart
@@ -113,7 +113,7 @@ If you want to overwrite the width and height:
113
113
```
114
114
115
115
<pclass="warning">
116
-
Please keep in mind, that you have to set `responsive: false` to be able to set a fix`width` and `height`.
116
+
Please keep in mind, that you have to set `responsive: false` to be able to set a fixed`width` and `height`.
117
117
</p>
118
118
119
119
### Chart with local data
@@ -142,21 +142,20 @@ export default Bar.extend({
142
142
})
143
143
```
144
144
145
-
### Reusebale Components
145
+
### Reusable Components
146
146
147
-
If you want to keep your chart components reuseable, it's the best to add a wrapper to them. This way the chart component is only responsable for the pure data representation and the wrapper component for the logic behind it. There are many different usecases and it is different if you're running a Single Page Application or integrate it in for example laravel.
147
+
If you want to keep your chart components reusable, it's the best to add a wrapper to them. This way the chart component is only responsible for the pure data representation and the wrapper component for the logic behind it. There are many different use cases and it is different if you're running a single page application or integrate it in for example laravel.
148
148
149
149
## Reactive Data
150
150
151
-
Chart.js does not provide a live update if you change the datasets. However `vue-chartjs` provides two mixins to achive this.
151
+
Chart.js does not provide a live update if you change the datasets. However `vue-chartjs` provides two mixins to achieve this.
152
152
153
153
-`reactiveProp`
154
154
-`reactiveData`
155
155
156
-
Both mixins to actually the same. Most of the time you will use `reactiveProp`. It extends the logic of your chart component and automatically creates a prop names`chartData` and add a `vue watch` on this prop. On data change, it will either call `update()` if only the data inside the datasets has changed or `renderChart()` if new datasets were added.
156
+
Both mixins do actually achieve the same. Most of the time you will use `reactiveProp`. It extends the logic of your chart component and automatically creates a prop named`chartData` and adds a `vue watch` on this prop. On data change, it will either call `update()` if only the data inside the datasets has changed or `renderChart()` if new datasets were added.
157
157
158
-
`reactiveData` simply creates a local chartData variable which is not a prop! And add a watcher.
159
-
This is only usefull, if you need single purpose charts and make an API call inside your chart component.
158
+
`reactiveData` simply creates a local chartData variable which is not a prop! and adds a watcher. This is only useful, if you need single purpose charts and make an API call inside your chart component.
160
159
161
160
```javascript
162
161
data () {
@@ -242,7 +241,7 @@ export default Line.extend({
242
241
```
243
242
244
243
<pclass="warning">
245
-
⚠ Attention: If you mutate your data in a parent component and pass it to your child chart component keep in mind the javascript limitiations.
244
+
⚠ Attention: If you mutate your data in a parent component and pass it to your child chart component keep the javascript limitations in mind.
246
245
More info in this [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
Sometimes you need more control over chart.js. Thats why you can access the chart.js instance over `this._chart`
257
+
Sometimes you need more control over Chart.js. That's why you can access the Chart.js instance over `this._chart`.
259
258
260
259
## Inline plugins
261
260
262
-
In Chart.js you can define global and inline plugins. Global plugins are working without problems with `vue-chartjs` like in the [chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html) described.
261
+
In Chart.js you can define global and inline plugins. Global plugins are working without problems with `vue-chartjs` like in the [Chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html) described.
263
262
264
263
If you want to add inline plugins, `vue-chartjs` exposes a helper method called `addPlugin()`
265
264
You should call `addPlugin()` before the `renderChart()` method.
@@ -281,7 +280,7 @@ mounted () {
281
280
282
281
### Bar Chart
283
282
<pclass="tip">
284
-
There are two versions of the Bar chart.`{Bar}` and `{HorizontalBar}`
283
+
There are two versions of the Bar chart:`{Bar}` and `{HorizontalBar}`
285
284
</p>
286
285
287
286

@@ -311,13 +310,13 @@ mounted () {
311
310
312
311
### Scatter
313
312
314
-
This chart has a different data structure then the others. Right now the reactive Mixins are not working for this chart type.
313
+
This chart has a different data structure then the others. Right now the reactive mixins are not working for this chart type.
315
314
316
315

317
316
318
317
319
318
## Explanation of Different Builds
320
-
There are three different entry points. It depends on which build setup do you have. The dependencies are bundled or required as a peerDependency.
319
+
There are three different entry points. It depends on your build setup. The dependencies are bundled or required as a peerDependency.
321
320
322
321
- Browser
323
322
- Browserify / Webpack 1
@@ -333,22 +332,21 @@ There are three different entry points. It depends on which build setup do you h
333
332
| es/index*| peerDependency | peerDependency |
334
333
335
334
### Browser
336
-
You can use `vue-chartjs` directly in the browser without any build setup. Like in this [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). For this case, please use the `vue-chartjs.full.min.js` which is the minified version. It has Vue.js and Chart.js bundled into it. And bundled to a UMD Module. So you only need that one file.
335
+
You can use `vue-chartjs` directly in the browser without any build setup, like in this [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). In this case, please use the `vue-chartjs.full.min.js` which is the minified version. It has Vue.js and Chart.js bundled into it and is bundled to a UMD module, so you only need that one file.
337
336
338
337
339
338
### Browserify / Webpack 1
340
339
341
340
If you're using Gulp, Browserify or Webpack 1 the entry is `vue-chartjs.js` which is __transpiled__ and __bundled__ UMD Module.
342
341
343
-
However Vue.js and Chart.js are `peerDependencies` so you have to install them seperately. In most projects you will have `Vue.js` already installed anyways. This way, you can have different versions of Vue.js and Chart.js then in this package.
342
+
However Vue.js and Chart.js are `peerDependencies` so you have to install them separately. In most projects you will have Vue.js already installed anyways. This way, you can have different versions of Vue.js and Chart.js then in this package.
344
343
345
344
### Webpack 2
346
-
If you're using Webpack 2 it will automatically use the `jsnext:main` / `module` entry point. Which is `es/index.js`
347
-
It is a __transpiled__ es version of the source. And is not __bundled__ to a module. This way your tree shaking will work. Like in the bundled version, `Vue.js` and `Chart.js` are `peerDependencies` and need to be installed.
345
+
If you're using Webpack 2 it will automatically use the `jsnext:main` / `module` entry point, which is `es/index.js`. It is a __transpiled__ es version of the source and is not __bundled__ to a module. This way your tree shaking will work. Like in the bundled version, Vue.js and Chart.js are `peerDependencies` and need to be installed.
348
346
349
347
## Resources
350
348
351
-
You can find here some Resources like tutorials on how to use `vue-chartjs`
349
+
You can find here some resources like tutorials on how to use `vue-chartjs`
352
350
353
351
-[Using vue-chartjs with WordPress](https://medium.com/@apertureless/wordpress-vue-and-chart-js-6b61493e289f)
354
352
-[Create stunning Charts with Vue and Chart.js](https://hackernoon.com/creating-stunning-charts-with-vue-js-and-chart-js-28af584adc0a)
0 commit comments