mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60f87e72ae | ||
|
|
896b7ddfa3 | ||
|
|
c9bc36ee59 | ||
|
|
7e52380bd4 | ||
|
|
32229fbfdd | ||
|
|
e0c771f3d3 | ||
|
|
57cff76747 | ||
|
|
79c138d65a | ||
|
|
64c6cedd74 | ||
|
|
188ab83989 | ||
|
|
d9f53e6ef4 | ||
|
|
7d1dacf77c | ||
|
|
67c01133d0 | ||
|
|
ab9721b577 | ||
|
|
71bcafa804 | ||
|
|
882bdd86b8 | ||
|
|
4f7dda3c3b | ||
|
|
f04441ab36 | ||
|
|
acb3d5c823 | ||
|
|
92bac84dae | ||
|
|
85e946dbe1 |
59
CHANGELOG.md
59
CHANGELOG.md
@@ -1,5 +1,64 @@
|
||||
# Change Log
|
||||
|
||||
## [v2.7.2](https://github.com/apertureless/vue-chartjs/tree/v2.7.2) (2017-07-22)
|
||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.7.1...v2.7.2)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Accessibility - Add unique titles to frames [\#150](https://github.com/apertureless/vue-chartjs/issues/150)
|
||||
- update\(\) not refreshing chart [\#148](https://github.com/apertureless/vue-chartjs/issues/148)
|
||||
- Custome label y axis [\#147](https://github.com/apertureless/vue-chartjs/issues/147)
|
||||
- Access specific points on the canvas and labels for styling [\#146](https://github.com/apertureless/vue-chartjs/issues/146)
|
||||
- legendCallback\(\) doesn't render a custom legend [\#144](https://github.com/apertureless/vue-chartjs/issues/144)
|
||||
- where can i get the demo sources code? thanks [\#143](https://github.com/apertureless/vue-chartjs/issues/143)
|
||||
- Props not works as expected, updating of value doesn't work [\#138](https://github.com/apertureless/vue-chartjs/issues/138)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- ⬆️ Update dependency vue to 2.4.2 [\#154](https://github.com/apertureless/vue-chartjs/pull/154) ([apertureless](https://github.com/apertureless))
|
||||
- Remove useless labels [\#153](https://github.com/apertureless/vue-chartjs/pull/153) ([clarkdo](https://github.com/clarkdo))
|
||||
- :pencil2: Remove generateLegend\(\) from initialization codes [\#145](https://github.com/apertureless/vue-chartjs/pull/145) ([k-rumi](https://github.com/k-rumi))
|
||||
|
||||
## [v2.7.1](https://github.com/apertureless/vue-chartjs/tree/v2.7.1) (2017-07-05)
|
||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.7.0...v2.7.1)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Default backgroundColor needed [\#142](https://github.com/apertureless/vue-chartjs/issues/142)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fix links to images in translated documents [\#141](https://github.com/apertureless/vue-chartjs/pull/141) ([k-rumi](https://github.com/k-rumi))
|
||||
|
||||
## [v2.7.0](https://github.com/apertureless/vue-chartjs/tree/v2.7.0) (2017-07-04)
|
||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.5...v2.7.0)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Reactive Data Tutorial [\#132](https://github.com/apertureless/vue-chartjs/issues/132)
|
||||
- Using inline plugins [\#130](https://github.com/apertureless/vue-chartjs/issues/130)
|
||||
- Scatter Chart [\#129](https://github.com/apertureless/vue-chartjs/issues/129)
|
||||
- Generating Chart after clicking submit button [\#128](https://github.com/apertureless/vue-chartjs/issues/128)
|
||||
- Ticks not working with reactive props [\#127](https://github.com/apertureless/vue-chartjs/issues/127)
|
||||
- Error in callback for watcher "chartData": "TypeError: Cannot read property 'data' of undefined" [\#126](https://github.com/apertureless/vue-chartjs/issues/126)
|
||||
- Passing the data from vue to chartjs [\#125](https://github.com/apertureless/vue-chartjs/issues/125)
|
||||
- Combination of Bar and Line Chart [\#123](https://github.com/apertureless/vue-chartjs/issues/123)
|
||||
- Reactive data example not working [\#122](https://github.com/apertureless/vue-chartjs/issues/122)
|
||||
- vue-chartjs height was 0 when i set v-show [\#120](https://github.com/apertureless/vue-chartjs/issues/120)
|
||||
- Bar chart, barPercentage in X axis [\#119](https://github.com/apertureless/vue-chartjs/issues/119)
|
||||
- update event not firing on data change [\#118](https://github.com/apertureless/vue-chartjs/issues/118)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- ✅ Update tests for addPlugin method [\#140](https://github.com/apertureless/vue-chartjs/pull/140) ([apertureless](https://github.com/apertureless))
|
||||
- Fix beforeDestory when renderChart was not called [\#139](https://github.com/apertureless/vue-chartjs/pull/139) ([ZhangYiJiang](https://github.com/ZhangYiJiang))
|
||||
- Add support for inline plugins [\#137](https://github.com/apertureless/vue-chartjs/pull/137) ([kurbar](https://github.com/kurbar))
|
||||
- Feature/scatter chart [\#136](https://github.com/apertureless/vue-chartjs/pull/136) ([apertureless](https://github.com/apertureless))
|
||||
- 🐛 Fix \#122 reactive mixin [\#135](https://github.com/apertureless/vue-chartjs/pull/135) ([apertureless](https://github.com/apertureless))
|
||||
- 📝 Add resources & tutorials to docs [\#133](https://github.com/apertureless/vue-chartjs/pull/133) ([apertureless](https://github.com/apertureless))
|
||||
- fix a typo in an example [\#131](https://github.com/apertureless/vue-chartjs/pull/131) ([JobV](https://github.com/JobV))
|
||||
- Update README [\#121](https://github.com/apertureless/vue-chartjs/pull/121) ([stoykostanchev](https://github.com/stoykostanchev))
|
||||
|
||||
## [v2.6.5](https://github.com/apertureless/vue-chartjs/tree/v2.6.5) (2017-06-10)
|
||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.4...v2.6.5)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
After the final release of vue.js 2, you also get the v2 by default if you install vue-chartjs over npm.
|
||||
No need for the @next tag anymore. If you want the v1 you need to define the version or use the legacy tag.
|
||||
If you're looking for v1 check this [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.1.3)
|
||||
If you're looking for v1 check this [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.x)
|
||||
|
||||
## Install
|
||||
|
||||
@@ -38,7 +38,7 @@ Simply run `yarn add vue-chartjs chart.js`
|
||||
Or if you want to use it directly in the browser add
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/vue-chartjs@2.6.0/dist/vue-chartjs.full.min.js"></script>
|
||||
<script src="https://unpkg.com/vue-chartjs/dist/vue-chartjs.full.min.js"></script>
|
||||
```
|
||||
to your scripts. See [Codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010)
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ There are some basic props defined in the BaseCharts. Because you `extend()` the
|
||||
| width | chart width |
|
||||
| height | chart height |
|
||||
| chart-id | id of the canvas |
|
||||
|
||||
| css-classes | String with css classes for the surrounding div |
|
||||
| styles | Object with css styles for the surrounding div container |
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -176,7 +177,8 @@ export default Line.extend({
|
||||
mixins: [reactiveProp],
|
||||
props: ['options'],
|
||||
mounted () {
|
||||
// this.chartData is created in the mixin
|
||||
// this.chartData is created in the mixin.
|
||||
// If you want to pass options please create a local options object
|
||||
this.renderChart(this.chartData, this.options)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,7 +2,8 @@ const langs = [
|
||||
{title: 'English', path: '/home', matchPath: /^\/(home|changelog)/},
|
||||
{title: 'Deutsch', path: '/de/', matchPath: /^\/de/},
|
||||
{title: '日本語', path: '/ja/', matchPath: /^\/ja/},
|
||||
{title: 'Português do Brasil', path: '/pt-br/', matchPath: /^\/pt-br/}
|
||||
{title: 'Português do Brasil', path: '/pt-br/', matchPath: /^\/pt-br/},
|
||||
{title: '中文(简体)', path: '/zh-cn/', matchPath: /^\/zh-cn/}
|
||||
]
|
||||
|
||||
docute.init({
|
||||
|
||||
@@ -262,30 +262,30 @@ Sometimes you need more control over chart.js. Thats why you can access the char
|
||||
There are two versions of the Bar chart. `{Bar}` and `{HorizontalBar}`
|
||||
</p>
|
||||
|
||||

|
||||

|
||||
### Line Chart
|
||||
|
||||

|
||||

|
||||
|
||||
### Doughnut
|
||||
|
||||

|
||||

|
||||
|
||||
### Pie
|
||||
|
||||

|
||||

|
||||
|
||||
### Radar
|
||||
|
||||

|
||||

|
||||
|
||||
### Polar Area
|
||||
|
||||

|
||||

|
||||
|
||||
### Bubble
|
||||
|
||||

|
||||

|
||||
|
||||
## Webpack, Browserify and dist files.
|
||||
|
||||
|
||||
@@ -264,30 +264,30 @@ export default Line.extend({
|
||||
棒グラフには `{Bar}` と `{HorizontalBar}` の2つのバージョンがあります。
|
||||
</p>
|
||||
|
||||

|
||||

|
||||
### 折れ線グラフ
|
||||
|
||||

|
||||

|
||||
|
||||
### ドーナツチャート
|
||||
|
||||

|
||||

|
||||
|
||||
### パイチャート
|
||||
|
||||

|
||||

|
||||
|
||||
### レーダーチャート
|
||||
|
||||

|
||||

|
||||
|
||||
### 鶏頭図
|
||||
|
||||

|
||||

|
||||
|
||||
### バブルチャート
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## ビルド方法の違い
|
||||
|
||||
@@ -221,31 +221,31 @@ export default Line.extend({
|
||||
|
||||
### Gráfico de Barra
|
||||
|
||||

|
||||

|
||||
|
||||
### Gráfico de Linha
|
||||
|
||||

|
||||

|
||||
|
||||
### Donut
|
||||
|
||||

|
||||

|
||||
|
||||
### Pizza
|
||||
|
||||

|
||||

|
||||
|
||||
### Radar
|
||||
|
||||

|
||||

|
||||
|
||||
### Área Polar
|
||||
|
||||

|
||||

|
||||
|
||||
### Bolha
|
||||
|
||||

|
||||

|
||||
|
||||
## Configurações de Build
|
||||
|
||||
|
||||
358
docs/zh-cn/README.md
Normal file
358
docs/zh-cn/README.md
Normal file
@@ -0,0 +1,358 @@
|
||||
---
|
||||
search: zh-cn
|
||||
---
|
||||
|
||||
# vue-chartjs
|
||||
**vue-chartjs** 是基于 vue 的 [Chart.js](https://github.com/chartjs/Chart.js) 封装。你可以轻松的创建可复用的图表组件。
|
||||
|
||||
## 简介
|
||||
`vue-chartjs` 让你在 vue 中使用 chart.js 省去很多麻烦。非常适合需要快速生成简单图表的人。
|
||||
|
||||
它抽象化了基本逻辑但提供了非常灵活的 chart.js 对象。
|
||||
|
||||
## 安装
|
||||
如果你正在使用 Vue.js 2.x 的版本,只需要运行:
|
||||
|
||||
`yarn add vue-chartjs chart.js`
|
||||
|
||||
如果你正在使用 Vue.js 1.x 的版本,请使用 `legacy` 标签。然而这个版本已经不再维护了。
|
||||
|
||||
`yarn add vue-chartjs@legacy`
|
||||
|
||||
## 快速开始
|
||||
|
||||
你需要引入基本图表并且扩展它。这在处理不同的数据时提供了更多的灵活性。
|
||||
|
||||
你可以封装您的组件,并使用 props 来传递数据。或者直接将数据放入组件中,但是这样做组件就不能复用了。
|
||||
|
||||
你可以加载整个包或者按需加载。
|
||||
|
||||
```javascript
|
||||
// CommitChart.js
|
||||
import { Bar } from 'vue-chartjs'
|
||||
|
||||
export default Bar.extend({
|
||||
mounted () {
|
||||
// Overwriting base render method with actual data.
|
||||
this.renderChart(data, options)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
你可以给 `renderChart()` 方法传递两个参数:
|
||||
|
||||
- Data object
|
||||
- Options object
|
||||
|
||||
### 数据对象
|
||||
|
||||
数据对象如下所示:
|
||||
|
||||
```javascript
|
||||
{
|
||||
labels: ['January', 'February'],
|
||||
datasets: [
|
||||
{
|
||||
label: 'GitHub Commits',
|
||||
backgroundColor: '#f87979',
|
||||
data: [40, 20]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
详细信息请查阅 [Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) 的文档。
|
||||
|
||||
## 属性
|
||||
|
||||
基本图表中定义了一些属性。因为你 `extend()` 了它们,他们使用 *初始值*,但是你可以覆盖它们:
|
||||
|
||||
| 属性 | 说明 |
|
||||
|---|---|
|
||||
| width | 图表宽度 |
|
||||
| height | 图表高度 |
|
||||
| chart-id | canvas的id |
|
||||
|
||||
|
||||
## 实例
|
||||
|
||||
下面是一些实例。
|
||||
|
||||
### 图表和属性
|
||||
|
||||
你可以创建数据和选项传递给图表。
|
||||
|
||||
```javascript
|
||||
// LineChart.js
|
||||
import { Line } from 'vue-chartjs'
|
||||
|
||||
export default Line.extend({
|
||||
props: ['data', 'options'],
|
||||
mounted () {
|
||||
this.renderChart(this.data, this.options)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
然后你可以把它作为组件使用。
|
||||
|
||||
```html
|
||||
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
|
||||
```
|
||||
|
||||
如果你想要覆盖宽度和高度:
|
||||
|
||||
```html
|
||||
<line-chart
|
||||
:data="{your data object}"
|
||||
:options="{responsive: false, maintainAspectRatio: false}"
|
||||
:width="400"
|
||||
:height="200"
|
||||
>
|
||||
</line-chart>
|
||||
```
|
||||
|
||||
<p class="warning">
|
||||
请注意,你必须设置 `responsive: false` 才可以使用 `width` 和 `height`。
|
||||
</p>
|
||||
|
||||
### 使用本地数据创建图表
|
||||
|
||||
```javascript
|
||||
import {Bar} from 'vue-chartjs'
|
||||
|
||||
export default Bar.extend({
|
||||
data () {
|
||||
return {
|
||||
datacollection: {
|
||||
labels: ['January', 'February'],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Data One',
|
||||
backgroundColor: '#f87979',
|
||||
data: [40, 20]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### 可复用的组件
|
||||
|
||||
如果你希望你的组件可以复用,那么你最好封装它们。这样图表组件只是负责显示你封装的数据。单页应用和集成到 laravel 中有不同的使用方式。
|
||||
|
||||
## 动态数据
|
||||
|
||||
Chart.js 并不提供实时更新,然而 `vue-chartjs` 提供了两种方式。
|
||||
|
||||
- `reactiveProp`
|
||||
- `reactiveData`
|
||||
|
||||
两种方式其实是一样的。多部分情况会使用 `reactiveProp`。它扩展了图表逻辑并且自动添加 `chartData` props 和 `vue watch`。当数据改变,它将会调用 `update()`。当添加了新的数据集,将会调用 `renderChart()`。
|
||||
|
||||
`reactiveData` 只是创建了本地变量并且添加到 watcher,而不是 prop,他只用在你创建单一图表并且在组件创建 api 的时候。
|
||||
|
||||
```javascript
|
||||
data () {
|
||||
return {
|
||||
chartData: null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 实例
|
||||
|
||||
**LineChart.js**
|
||||
```javascript
|
||||
import { Line, mixins } from 'vue-chartjs'
|
||||
const { reactiveProp } = mixins
|
||||
|
||||
export default Line.extend({
|
||||
mixins: [reactiveProp],
|
||||
props: ['options'],
|
||||
mounted () {
|
||||
// this.chartData is created in the mixin
|
||||
this.renderChart(this.chartData, this.options)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**RandomChart.vue**
|
||||
|
||||
```javascript
|
||||
<template>
|
||||
<div class="small">
|
||||
<line-chart :chart-data="datacollection"></line-chart>
|
||||
<button @click="fillData()">Randomize</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LineChart from './LineChart.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LineChart
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
datacollection: null
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.fillData()
|
||||
},
|
||||
methods: {
|
||||
fillData () {
|
||||
this.datacollection = {
|
||||
labels: [this.getRandomInt(), this.getRandomInt()],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Data One',
|
||||
backgroundColor: '#f87979',
|
||||
data: [this.getRandomInt(), this.getRandomInt()]
|
||||
}, {
|
||||
label: 'Data One',
|
||||
backgroundColor: '#f87979',
|
||||
data: [this.getRandomInt(), this.getRandomInt()]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
getRandomInt () {
|
||||
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.small {
|
||||
max-width: 600px;
|
||||
margin: 150px auto;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
<p class="warning">
|
||||
⚠ 注意:如果在父组件中修改数据并将数据传递给子图表组件时,请注意 JavaScript 的限制。
|
||||
更多信息请查阅 [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
|
||||
</p>
|
||||
|
||||
### 限制
|
||||
<ul>
|
||||
<li>[Caveats](https://vuejs.org/v2/guide/list.html#Caveats)</li>
|
||||
<li>[Change-Detection-Caveats](https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats)</li>
|
||||
<li>[vm.$watch](https://vuejs.org/v2/api/#vm-watch)</li>
|
||||
</ul>
|
||||
|
||||
## Chart.js 对象
|
||||
|
||||
有时你需要更多的调整 chart.js。你可以访问 `this._chart` 实例。
|
||||
|
||||
## 内联插件
|
||||
|
||||
在 Chart.js 你可以定义全局和内联插件。全局插件在 `vue-chartjs` 中没有问题,参照 [chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html) 的说明。
|
||||
|
||||
如果你想添加内联插件 `vue-chartjs` 提供了一个方法 `addPlugin()`
|
||||
|
||||
你必须在 `renderChart()` 之前调用 `addPlugin()` 方法。
|
||||
|
||||
### 实例
|
||||
|
||||
```javascript
|
||||
mounted () {
|
||||
this.addPlugin({
|
||||
id: 'my-plugin',
|
||||
beforeInit: function (chart) {
|
||||
....
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## 支持的图表
|
||||
|
||||
### 柱状图
|
||||
|
||||
<p class="tip">
|
||||
柱状图有两个版本。 `{Bar}` 和 `{HorizontalBar}`
|
||||
</p>
|
||||
|
||||

|
||||
|
||||
### 折线图
|
||||
|
||||

|
||||
|
||||
### 环形图
|
||||
|
||||

|
||||
|
||||
### 饼图
|
||||
|
||||

|
||||
|
||||
### 雷达图
|
||||
|
||||

|
||||
|
||||
### 极坐标
|
||||
|
||||

|
||||
|
||||
### 热点图
|
||||
|
||||

|
||||
|
||||
### 散点图
|
||||
|
||||
这个图表有不同的数据结构。目前动态数据不适用于此图表类型。
|
||||
|
||||

|
||||
|
||||
|
||||
## 不同构建工具的说明
|
||||
有三种不同的切入点,取决于你用哪种构建工具。作为 dependencies 或者 peerDependency。
|
||||
|
||||
- Browser
|
||||
- Browserify / Webpack 1
|
||||
- Webpack 2
|
||||
|
||||
|
||||
| Build | Chart.js | Vue.js |
|
||||
|---|---|---|
|
||||
| vue-chartjs.full.js | Bundled | Bundled |
|
||||
| vue-chartjs.full.min.js | Bundled | Bundled |
|
||||
| vue-chartjs.js | peerDependency | peerDependency |
|
||||
| vue-chartjs.min.js | peerDependency | peerDependency |
|
||||
| es/index* | peerDependency | peerDependency |
|
||||
|
||||
### 浏览器
|
||||
你可以在浏览中直接使用 `vue-chartjs`。像是 [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010) 这种情况,请使用 `vue-chartjs.full.min.js` 捆绑版本。他将 Vue.js 和 Chart.js 绑定在了一起,你只需要一个文件。
|
||||
|
||||
|
||||
### Browserify / Webpack 1
|
||||
|
||||
如果你使用 Gulp, Browserify 或者 Webpack 1,`vue-chartjs.js` 被捆绑到 UMD 模块。
|
||||
|
||||
然而 Vue.js 和 Chart.js 是 `peerDependencies` 所以你需要独立安装它们。 大部分情况下你已经安装了 `Vue.js`,你可以使用不同版本的 Vue.js 和 Chart.js。
|
||||
|
||||
### Webpack 2
|
||||
如果你使用 Webpack 2 它将自动使用 `jsnext:main` / `module` 入口。
|
||||
像捆绑版本一样,`Vue.js` 和 `Chart.js` 都是 `peerDependencies`,需要安装。
|
||||
|
||||
## 资源
|
||||
|
||||
你可以在这里找到一些如何使用 `vue-chartjs` 的资源。
|
||||
|
||||
- [Using vue-chartjs with WordPress](https://medium.com/@apertureless/wordpress-vue-and-chart-js-6b61493e289f)
|
||||
- [Create stunning Charts with Vue and Chart.js](https://hackernoon.com/creating-stunning-charts-with-vue-js-and-chart-js-28af584adc0a)
|
||||
- [Let’s Build a Web App with Vue, Chart.js and an API Part I](https://hackernoon.com/lets-build-a-web-app-with-vue-chart-js-and-an-api-544eb81c4b44)
|
||||
- [Let’s Build a Web App with Vue, Chart.js and an API Part II](https://hackernoon.com/lets-build-a-web-app-with-vue-chart-js-and-an-api-part-ii-39781b1d5acf)
|
||||
- [Build a realtime chart with VueJS and Pusher](https://blog.pusher.com/build-realtime-chart-with-vuejs-pusher/)
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-chartjs",
|
||||
"version": "2.7.0",
|
||||
"version": "2.8.0",
|
||||
"description": "vue.js wrapper for chart.js",
|
||||
"author": "Jakub Juszczak <jakub@posteo.de>",
|
||||
"homepage": "http://vue-chartjs.org",
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"chart.js": "^2.6.0",
|
||||
"vue": "^2.3.4"
|
||||
"vue": "^2.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.24.1",
|
||||
@@ -117,12 +117,12 @@
|
||||
"sinon": "^2.1.0",
|
||||
"sinon-chai": "^2.9.0",
|
||||
"url-loader": "^0.5.8",
|
||||
"vue": "^2.3.4",
|
||||
"vue": "^2.4.2",
|
||||
"vue-hot-reload-api": "^2.1.0",
|
||||
"vue-html-loader": "^1.2.4",
|
||||
"vue-loader": "^12.2.1",
|
||||
"vue-loader": "^12.2.2",
|
||||
"vue-style-loader": "^3.0.1",
|
||||
"vue-template-compiler": "^2.3.4",
|
||||
"vue-template-compiler": "^2.4.2",
|
||||
"webpack": "^1.13.2",
|
||||
"webpack-dev-middleware": "^1.10.1",
|
||||
"webpack-hot-middleware": "^2.17.1",
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -20,7 +23,6 @@ export default Vue.extend({
|
||||
]
|
||||
)
|
||||
},
|
||||
|
||||
props: {
|
||||
chartId: {
|
||||
default: 'bar-chart',
|
||||
@@ -33,9 +35,22 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
defaultOptions: {
|
||||
@@ -75,7 +90,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -76,7 +93,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,7 +76,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -75,7 +92,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -74,7 +91,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,7 +76,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,7 +76,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,7 +76,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { mergeOptions } from '../helpers/options'
|
||||
export default Vue.extend({
|
||||
render: function (createElement) {
|
||||
return createElement(
|
||||
'div',
|
||||
'div', {
|
||||
style: this.styles,
|
||||
class: this.cssClasses
|
||||
},
|
||||
[
|
||||
createElement(
|
||||
'canvas', {
|
||||
@@ -33,6 +36,20 @@ export default Vue.extend({
|
||||
height: {
|
||||
default: 400,
|
||||
type: Number
|
||||
},
|
||||
cssClasses: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
styles: {
|
||||
type: Object,
|
||||
default () {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '200%',
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -65,7 +82,6 @@ export default Vue.extend({
|
||||
plugins: this.plugins
|
||||
}
|
||||
)
|
||||
this._chart.generateLegend()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
||||
@@ -79,7 +79,8 @@
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
dataPoints: null
|
||||
dataPoints: null,
|
||||
height: 20
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@@ -88,6 +89,9 @@
|
||||
}, 2000)
|
||||
},
|
||||
methods: {
|
||||
increaseHeight () {
|
||||
this.height += 10
|
||||
},
|
||||
getRandomInt () {
|
||||
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
|
||||
},
|
||||
@@ -103,6 +107,14 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
myStyles () {
|
||||
return {
|
||||
height: `${this.height}px`,
|
||||
position: 'relative'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -3,7 +3,6 @@ import Scatter from '../BaseCharts/Scatter'
|
||||
export default Scatter.extend({
|
||||
mounted () {
|
||||
this.renderChart({
|
||||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
||||
datasets: [{
|
||||
label: 'Scatter Dataset 1',
|
||||
fill: false,
|
||||
|
||||
@@ -6,6 +6,7 @@ import Pie from './BaseCharts/Pie'
|
||||
import PolarArea from './BaseCharts/PolarArea'
|
||||
import Radar from './BaseCharts/Radar'
|
||||
import Bubble from './BaseCharts/Bubble'
|
||||
import Scatter from './BaseCharts/Scatter'
|
||||
import mixins from './mixins/index.js'
|
||||
import npmCfg from '../package.json'
|
||||
|
||||
@@ -19,6 +20,7 @@ const VueCharts = {
|
||||
PolarArea,
|
||||
Radar,
|
||||
Bubble,
|
||||
Scatter,
|
||||
mixins
|
||||
}
|
||||
|
||||
@@ -34,5 +36,6 @@ export {
|
||||
PolarArea,
|
||||
Radar,
|
||||
Bubble,
|
||||
Scatter,
|
||||
mixins
|
||||
}
|
||||
|
||||
18
yarn.lock
18
yarn.lock
@@ -5707,9 +5707,9 @@ vue-html-loader@^1.2.4:
|
||||
loader-utils "^1.0.2"
|
||||
object-assign "^4.1.0"
|
||||
|
||||
vue-loader@^12.2.1:
|
||||
version "12.2.1"
|
||||
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-12.2.1.tgz#53f27c0973d386768f5a75156f4129b5efc6ba55"
|
||||
vue-loader@^12.2.2:
|
||||
version "12.2.2"
|
||||
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-12.2.2.tgz#2b3a764f27018f975bc78cb8b1f55137548ee2d7"
|
||||
dependencies:
|
||||
consolidate "^0.14.0"
|
||||
hash-sum "^1.0.2"
|
||||
@@ -5732,9 +5732,9 @@ vue-style-loader@^3.0.0, vue-style-loader@^3.0.1:
|
||||
hash-sum "^1.0.2"
|
||||
loader-utils "^1.0.2"
|
||||
|
||||
vue-template-compiler@^2.3.4:
|
||||
version "2.3.4"
|
||||
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.3.4.tgz#5a88ac2c5e4d5d6218e6aa80e7e221fb7e67894c"
|
||||
vue-template-compiler@^2.4.2:
|
||||
version "2.4.2"
|
||||
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.4.2.tgz#5a45d843f148b098f6c1d1e35ac20c4956d30ad1"
|
||||
dependencies:
|
||||
de-indent "^1.0.2"
|
||||
he "^1.1.0"
|
||||
@@ -5743,9 +5743,9 @@ vue-template-es2015-compiler@^1.2.2:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.4.0.tgz#7b88853ca4bf8d84ae54ab9e56771de271e60198"
|
||||
|
||||
vue@^2.3.4:
|
||||
version "2.3.4"
|
||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.3.4.tgz#5ec3b87a191da8090bbef56b7cfabd4158038171"
|
||||
vue@^2.4.2:
|
||||
version "2.4.2"
|
||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.2.tgz#a9855261f191c978cc0dc1150531b8d08149b58c"
|
||||
|
||||
watchpack@^0.2.1:
|
||||
version "0.2.9"
|
||||
|
||||
Reference in New Issue
Block a user