mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd3b0c4cad | ||
|
|
413bbdf91a | ||
|
|
92ca2f7295 | ||
|
|
1e046e828e | ||
|
|
256eec9518 | ||
|
|
d08666f2ad | ||
|
|
6433a0a4a5 | ||
|
|
081b97028b | ||
|
|
eb42bd78ea | ||
|
|
9f9aa23a69 | ||
|
|
ef52d98fdd | ||
|
|
4cec21ed2d | ||
|
|
33da30021b | ||
|
|
1c2be6a83e | ||
|
|
274717a237 | ||
|
|
bdeac75422 | ||
|
|
ebcab9f2f8 |
@@ -15,5 +15,8 @@ module.exports = {
|
|||||||
'arrow-parens': 0,
|
'arrow-parens': 0,
|
||||||
// allow debugger during development
|
// allow debugger during development
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
|
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"LIB_VERSION": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -10,6 +10,9 @@
|
|||||||
[](https://gitter.im/vue-chartjs/Lobby)
|
[](https://gitter.im/vue-chartjs/Lobby)
|
||||||
[](https://github.com/apertureless/vue-chartjs/blob/master/LICENSE.txt)
|
[](https://github.com/apertureless/vue-chartjs/blob/master/LICENSE.txt)
|
||||||
[](https://cdnjs.com/libraries/vue-chartjs)
|
[](https://cdnjs.com/libraries/vue-chartjs)
|
||||||
|
[](https://snyk.io/test/github/apertureless/vue-chartjs)
|
||||||
|
[](https://codeclimate.com/github/apertureless/vue-chartjs/maintainability)
|
||||||
|
[](paypal)
|
||||||
|
|
||||||
# vue-chartjs
|
# vue-chartjs
|
||||||
|
|
||||||
@@ -73,11 +76,11 @@ Vue.component('line-chart', {
|
|||||||
|
|
||||||
If you're using Gulp, Browserify or Webpack 1 the entry is `vue-chartjs.js` which is __transpiled__ and __bundled__ UMD Module.
|
If you're using Gulp, Browserify or Webpack 1 the entry is `vue-chartjs.js` which is __transpiled__ and __bundled__ UMD Module.
|
||||||
|
|
||||||
However Chart.js is a `peerDependencies` so you have to install it separately. In most projects This way, you can have different versions of Chart.js then in this package.
|
However, Chart.js is a `peerDependencies` so you have to install it separately. In most projects This way, you can have different versions of Chart.js then in this package.
|
||||||
|
|
||||||
### Webpack 2
|
### Webpack 2
|
||||||
If you're using Webpack 2 it will automatically use the `jsnext:main` / `module` entry point. Which is `es/index.js`
|
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 you tree shaking will work. Like in the bundled version, `Chart.js` is a `peerDependencies` and need to be installed.
|
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, `Chart.js` is a `peerDependencies` and need to be installed.
|
||||||
|
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
@@ -123,7 +126,7 @@ import CommitChart from 'path/to/component/CommitChart'
|
|||||||
|
|
||||||
## Another Example with options
|
## Another Example with options
|
||||||
|
|
||||||
You can overwrite the default chart options. Just pass the options object as a second paramenter to the render method
|
You can overwrite the default chart options. Just pass the options object as a second parameter to the render method
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// MonthlyIncome.vue
|
// MonthlyIncome.vue
|
||||||
@@ -158,7 +161,7 @@ export default {
|
|||||||
## Reactivity
|
## Reactivity
|
||||||
|
|
||||||
Chart.js does not update or re-render the chart if new data is passed.
|
Chart.js does not update or re-render the chart if new data is passed.
|
||||||
However you can simply implement this on your own or use one of the two mixins which are included.
|
However, you can simply implement this on your own or use one of the two mixins which are included.
|
||||||
|
|
||||||
- `reactiveProp`
|
- `reactiveProp`
|
||||||
- `reactiveData`
|
- `reactiveData`
|
||||||
@@ -166,7 +169,7 @@ However you can simply implement this on your own or use one of the two mixins w
|
|||||||
Both are included in the `mixins` module.
|
Both are included in the `mixins` module.
|
||||||
|
|
||||||
The mixins automatically create `chartData` as a prop or data. And add a watcher. If data has changed, the chart will update.
|
The mixins automatically create `chartData` as a prop or data. And add a watcher. If data has changed, the chart will update.
|
||||||
However keep in mind the limitations of vue and javascript for mutations on arrays and objects.
|
However, keep in mind the limitations of vue and javascript for mutations on arrays and objects.
|
||||||
**It is important that you pass your options in a local variable named `options`!**
|
**It is important that you pass your options in a local variable named `options`!**
|
||||||
The reason is that if the mixin re-renders the chart it calls `this.renderChart(this.chartData, this.options`)` so don't pass in the options object directly or it will be ignored.
|
The reason is that if the mixin re-renders the chart it calls `this.renderChart(this.chartData, this.options`)` so don't pass in the options object directly or it will be ignored.
|
||||||
|
|
||||||
@@ -188,7 +191,7 @@ export default {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Mixins module
|
### Mixins module
|
||||||
The `mixins` module is included in the `VueCharts` module and as a seperate module.
|
The `mixins` module is included in the `VueCharts` module and as a separate module.
|
||||||
Some ways to import them:
|
Some ways to import them:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@@ -294,7 +297,7 @@ npm run e2e
|
|||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
|
For a detailed explanation of how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
@@ -307,3 +310,5 @@ For a detailed explanation on how things work, check out the [guide](http://vuej
|
|||||||
## License
|
## License
|
||||||
|
|
||||||
This software is distributed under [MIT license](LICENSE.txt).
|
This software is distributed under [MIT license](LICENSE.txt).
|
||||||
|
|
||||||
|
[paypal]: https://www.paypal.me/apertureless/50eur
|
||||||
|
|||||||
2
assets/donate.svg
Normal file
2
assets/donate.svg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="74" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="74" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h25v20H0z"/><path fill="#179BD7" d="M25 0h49v20H25z"/><path fill="url(#b)" d="M0 0h74v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><image x="5" y="3" width="14" height="14" xlink:href="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IuWbvuWxgl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgd2lkdGg9IjUwMHB4IiBoZWlnaHQ9IjUwMHB4IiB2aWV3Qm94PSIwIDAgNTAwIDUwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNTAwIDUwMCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8cGF0aCBmaWxsPSIjMTc5QkQ3IiBkPSJNNDExLjg5OSwxMzQuMzI4TDQxMS44OTksMTM0LjMyOEw0MTEuODk5LDEzNC4zMjhjLTAuNDM1LDIuNzgyLTAuOTMzLDUuNjI2LTEuNDkyLDguNTQ4DQoJCWMtMTkuMjI2LDk4LjcwOS04NS4wMDEsMTMyLjgwOS0xNjkuMDA3LDEzMi44MDloLTQyLjc3MmMtMTAuMjczLDAtMTguOTMxLDcuNDYtMjAuNTMxLDE3LjU5NGwwLDBsMCwwbC0yMS44OTksMTM4Ljg4Ng0KCQlsLTYuMjAxLDM5LjM2OWMtMS4wNDEsNi42NTIsNC4wODgsMTIuNjUxLDEwLjgwMiwxMi42NTFoNzUuODYyYzguOTgzLDAsMTYuNjE1LTYuNTI4LDE4LjAyOS0xNS4zODdsMC43NDYtMy44NTRsMTQuMjgzLTkwLjY0Mw0KCQlsMC45MTctNC45NzRjMS4zOTktOC44OSw5LjA0Ni0xNS40MTgsMTguMDI5LTE1LjQxOGgxMS4zNDZjNzMuNSwwLDEzMS4wMzctMjkuODQxLDE0Ny44NTQtMTE2LjE5NA0KCQljNy4wMjUtMzYuMDc0LDMuMzg4LTY2LjE5NS0xNS4yLTg3LjM3OUM0MjcuMDM3LDE0My45NDksNDIwLjA1OSwxMzguNjQ5LDQxMS44OTksMTM0LjMyOHoiLz4NCgk8cGF0aCBmaWxsPSIjMjIyRDY1IiBkPSJNMzkxLjc4NywxMjYuMzA4Yy0yLjkzOC0wLjg1NS01Ljk2OC0xLjYzMi05LjA3Ny0yLjMzMWMtMy4xMjQtMC42ODQtNi4zMjYtMS4yOS05LjYyMS0xLjgxOA0KCQljLTExLjUzMi0xLjg2NS0yNC4xNjgtMi43NTEtMzcuNzA2LTIuNzUxSDIyMS4xMTdjLTIuODEzLDAtNS40ODYsMC42MzctNy44OCwxLjc4N2MtNS4yNjksMi41MzMtOS4xODUsNy41MjItMTAuMTM0LDEzLjYzMQ0KCQlsLTI0LjMwOCwxNTMuOTYybC0wLjY5OSw0LjQ5MmMxLjYwMS0xMC4xMzQsMTAuMjU4LTE3LjU5NCwyMC41MzEtMTcuNTk0SDI0MS40Yzg0LjAwNiwwLDE0OS43ODEtMzQuMTE1LDE2OS4wMDctMTMyLjgwOQ0KCQljMC41NzUtMi45MjIsMS4wNTctNS43NjYsMS40OTItOC41NDhjLTQuODY1LTIuNTgtMTAuMTM0LTQuNzg3LTE1LjgwNy02LjY2OEMzOTQuNjk0LDEyNy4xOTQsMzkzLjI0OCwxMjYuNzQzLDM5MS43ODcsMTI2LjMwOHoiLz4NCgk8cGF0aCBmaWxsPSIjMjUzQjgwIiBkPSJNMjAzLjEwNCwxMzQuODI1YzAuOTQ4LTYuMTA4LDQuODY1LTExLjA5NywxMC4xMzQtMTMuNjE1YzIuNDA5LTEuMTUsNS4wNjctMS43ODcsNy44OC0xLjc4N2gxMTQuMjY3DQoJCWMxMy41MzcsMCwyNi4xNzMsMC44ODYsMzcuNzA2LDIuNzUxYzMuMjk1LDAuNTI4LDYuNDk3LDEuMTM1LDkuNjIxLDEuODE4YzMuMTA4LDAuNjk5LDYuMTM5LDEuNDc3LDkuMDc3LDIuMzMxDQoJCWMxLjQ2MSwwLjQzNSwyLjkwNiwwLjg4Niw0LjMyMSwxLjMzN2M1LjY3MywxLjg4MSwxMC45NDIsNC4xMDMsMTUuODA3LDYuNjY4YzUuNzItMzYuNDc4LTAuMDQ3LTYxLjMxNC0xOS43Ny04My44MDQNCgkJYy0yMS43NDQtMjQuNzU5LTYwLjk4OC0zNS4zNTktMTExLjIwNS0zNS4zNTlIMTM1LjE1M2MtMTAuMjU4LDAtMTkuMDA4LDcuNDYtMjAuNTk0LDE3LjYwOUw1My44MzYsNDE3LjY4DQoJCWMtMS4xOTcsNy42MTYsNC42NzgsMTQuNDg1LDEyLjM1NiwxNC40ODVoOTAuMDA1bDIyLjU5OC0xNDMuMzc4TDIwMy4xMDQsMTM0LjgyNXoiLz4NCjwvZz4NCjwvc3ZnPg0K"/><text x="19.5" y="15" fill="#010101" fill-opacity=".3"></text><text x="19.5" y="14"></text><text x="48.5" y="15" fill="#010101" fill-opacity=".3">Donate</text><text x="48.5" y="14">Donate</text></g></svg>
|
||||||
|
After Width: | Height: | Size: 3.6 KiB |
@@ -1,8 +1,10 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
const webpack = require('webpack')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const utils = require('./utils')
|
const utils = require('./utils')
|
||||||
const config = require('../config')
|
const config = require('../config')
|
||||||
const vueLoaderConfig = require('./vue-loader.conf')
|
const vueLoaderConfig = require('./vue-loader.conf')
|
||||||
|
const npmCfg = require('../package.json')
|
||||||
|
|
||||||
function resolve (dir) {
|
function resolve (dir) {
|
||||||
return path.join(__dirname, '..', dir)
|
return path.join(__dirname, '..', dir)
|
||||||
@@ -72,5 +74,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
LIB_VERSION: JSON.stringify(npmCfg.version)
|
||||||
|
})
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ module.exports = {
|
|||||||
entry: {
|
entry: {
|
||||||
'vue-chartjs': './src/index.js'
|
'vue-chartjs': './src/index.js'
|
||||||
},
|
},
|
||||||
|
devtool: 'source-map',
|
||||||
output: {
|
output: {
|
||||||
filename: './dist/[name].js',
|
filename: './dist/[name].js',
|
||||||
library: 'VueChartJs',
|
library: 'VueChartJs',
|
||||||
@@ -82,17 +83,12 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
delete module.exports.devtool
|
// delete module.exports.devtool
|
||||||
module.exports.plugins = [
|
module.exports.plugins = [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
NODE_ENV: '"production"'
|
NODE_ENV: '"production"'
|
||||||
}
|
}
|
||||||
}),
|
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
|
||||||
compress: {
|
|
||||||
warnings: false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
4
build/webpack.release.min.js
vendored
4
build/webpack.release.min.js
vendored
@@ -3,12 +3,10 @@ var webpack = require('webpack')
|
|||||||
|
|
||||||
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
|
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
|
||||||
|
|
||||||
delete config.devtool
|
|
||||||
|
|
||||||
config.plugins = [
|
config.plugins = [
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
sourceMap: false,
|
sourceMap: true,
|
||||||
compress: {
|
compress: {
|
||||||
warnings: false
|
warnings: false
|
||||||
}
|
}
|
||||||
|
|||||||
341
dist/vue-chartjs.js
vendored
341
dist/vue-chartjs.js
vendored
@@ -1,8 +1,3 @@
|
|||||||
/*!
|
|
||||||
* vue-chartjs v3.1.1
|
|
||||||
* (c) 2018 Jakub Juszczak <jakub@posteo.de>
|
|
||||||
* http://vue-chartjs.org
|
|
||||||
*/
|
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
module.exports = factory(require("chart.js"));
|
module.exports = factory(require("chart.js"));
|
||||||
@@ -12,7 +7,7 @@
|
|||||||
exports["VueChartJs"] = factory(require("chart.js"));
|
exports["VueChartJs"] = factory(require("chart.js"));
|
||||||
else
|
else
|
||||||
root["VueChartJs"] = factory(root["Chart"]);
|
root["VueChartJs"] = factory(root["Chart"]);
|
||||||
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_4__) {
|
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_3__) {
|
||||||
return /******/ (function(modules) { // webpackBootstrap
|
return /******/ (function(modules) { // webpackBootstrap
|
||||||
/******/ // The module cache
|
/******/ // The module cache
|
||||||
/******/ var installedModules = {};
|
/******/ var installedModules = {};
|
||||||
@@ -84,31 +79,140 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VueCharts", function() { return VueCharts; });
|
||||||
// EXTERNAL MODULE: ./src/mixins/reactiveData.js
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mixins_index_js__ = __webpack_require__(1);
|
||||||
var reactiveData = __webpack_require__(1);
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BaseCharts__ = __webpack_require__(2);
|
||||||
var reactiveData_default = /*#__PURE__*/__webpack_require__.n(reactiveData);
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Bar", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["a"]; });
|
||||||
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "HorizontalBar", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["d"]; });
|
||||||
// EXTERNAL MODULE: ./src/mixins/reactiveProp.js
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Doughnut", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["c"]; });
|
||||||
var reactiveProp = __webpack_require__(2);
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["e"]; });
|
||||||
var reactiveProp_default = /*#__PURE__*/__webpack_require__.n(reactiveProp);
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Pie", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["f"]; });
|
||||||
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "PolarArea", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["g"]; });
|
||||||
// CONCATENATED MODULE: ./src/mixins/index.js
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Radar", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["h"]; });
|
||||||
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Bubble", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["b"]; });
|
||||||
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Scatter", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["i"]; });
|
||||||
|
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mixins", function() { return __WEBPACK_IMPORTED_MODULE_0__mixins_index_js__["a"]; });
|
||||||
|
|
||||||
|
|
||||||
/* harmony default export */ var mixins = ({
|
var VueCharts = {
|
||||||
reactiveData: reactiveData_default.a,
|
Bar: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["a" /* Bar */],
|
||||||
reactiveProp: reactiveProp_default.a
|
HorizontalBar: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["d" /* HorizontalBar */],
|
||||||
|
Doughnut: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["c" /* Doughnut */],
|
||||||
|
Line: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["e" /* Line */],
|
||||||
|
Pie: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["f" /* Pie */],
|
||||||
|
PolarArea: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["g" /* PolarArea */],
|
||||||
|
Radar: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["h" /* Radar */],
|
||||||
|
Bubble: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["b" /* Bubble */],
|
||||||
|
Scatter: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["i" /* Scatter */],
|
||||||
|
mixins: __WEBPACK_IMPORTED_MODULE_0__mixins_index_js__["a" /* default */]
|
||||||
|
};
|
||||||
|
/* harmony default export */ __webpack_exports__["default"] = (VueCharts);
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
/* 1 */
|
||||||
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
/* unused harmony export reactiveData */
|
||||||
|
/* unused harmony export reactiveProp */
|
||||||
|
function dataHandler(newData, oldData) {
|
||||||
|
if (oldData) {
|
||||||
|
var chart = this.$data._chart;
|
||||||
|
var newDatasetLabels = newData.datasets.map(function (dataset) {
|
||||||
|
return dataset.label;
|
||||||
|
});
|
||||||
|
var oldDatasetLabels = oldData.datasets.map(function (dataset) {
|
||||||
|
return dataset.label;
|
||||||
|
});
|
||||||
|
var oldLabels = JSON.stringify(oldDatasetLabels);
|
||||||
|
var newLabels = JSON.stringify(newDatasetLabels);
|
||||||
|
|
||||||
|
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
|
||||||
|
newData.datasets.forEach(function (dataset, i) {
|
||||||
|
var oldDatasetKeys = Object.keys(oldData.datasets[i]);
|
||||||
|
var newDatasetKeys = Object.keys(dataset);
|
||||||
|
var deletionKeys = oldDatasetKeys.filter(function (key) {
|
||||||
|
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1;
|
||||||
|
});
|
||||||
|
deletionKeys.forEach(function (deletionKey) {
|
||||||
|
delete chart.data.datasets[i][deletionKey];
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var attribute in dataset) {
|
||||||
|
if (dataset.hasOwnProperty(attribute)) {
|
||||||
|
chart.data.datasets[i][attribute] = dataset[attribute];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (newData.hasOwnProperty('labels')) {
|
||||||
|
chart.data.labels = newData.labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newData.hasOwnProperty('xLabels')) {
|
||||||
|
chart.data.xLabels = newData.xLabels;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newData.hasOwnProperty('yLabels')) {
|
||||||
|
chart.data.yLabels = newData.yLabels;
|
||||||
|
}
|
||||||
|
|
||||||
|
chart.update();
|
||||||
|
} else {
|
||||||
|
chart.destroy();
|
||||||
|
this.renderChart(this.chartData, this.options);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.$data._chart) {
|
||||||
|
this.$data._chart.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.renderChart(this.chartData, this.options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var reactiveData = {
|
||||||
|
data: function data() {
|
||||||
|
return {
|
||||||
|
chartData: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'chartData': dataHandler
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var reactiveProp = {
|
||||||
|
props: {
|
||||||
|
chartData: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'chartData': dataHandler
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/* harmony default export */ __webpack_exports__["a"] = ({
|
||||||
|
reactiveData: reactiveData,
|
||||||
|
reactiveProp: reactiveProp
|
||||||
});
|
});
|
||||||
// EXTERNAL MODULE: ./package.json
|
|
||||||
var package_0 = __webpack_require__(3);
|
|
||||||
var package_default = /*#__PURE__*/__webpack_require__.n(package_0);
|
|
||||||
|
|
||||||
// EXTERNAL MODULE: external {"root":"Chart","commonjs":"chart.js","commonjs2":"chart.js","amd":"chart.js"}
|
/***/ }),
|
||||||
var external___root___Chart___commonjs___chart_js___commonjs2___chart_js___amd___chart_js__ = __webpack_require__(4);
|
/* 2 */
|
||||||
var external___root___Chart___commonjs___chart_js___commonjs2___chart_js___amd___chart_js___default = /*#__PURE__*/__webpack_require__.n(external___root___Chart___commonjs___chart_js___commonjs2___chart_js___amd___chart_js__);
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
// CONCATENATED MODULE: ./src/BaseCharts.js
|
"use strict";
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Bar; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return HorizontalBar; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Doughnut; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Line; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return Pie; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return PolarArea; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return Radar; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Bubble; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return Scatter; });
|
||||||
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_chart_js__ = __webpack_require__(3);
|
||||||
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_chart_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_chart_js__);
|
||||||
|
|
||||||
|
|
||||||
function generateChart(chartId, chartType) {
|
function generateChart(chartId, chartType) {
|
||||||
@@ -164,7 +268,7 @@ function generateChart(chartId, chartType) {
|
|||||||
this.$data._plugins.push(plugin);
|
this.$data._plugins.push(plugin);
|
||||||
},
|
},
|
||||||
renderChart: function renderChart(data, options) {
|
renderChart: function renderChart(data, options) {
|
||||||
this.$data._chart = new external___root___Chart___commonjs___chart_js___commonjs2___chart_js___amd___chart_js___default.a(this.$refs.canvas.getContext('2d'), {
|
this.$data._chart = new __WEBPACK_IMPORTED_MODULE_0_chart_js___default.a(this.$refs.canvas.getContext('2d'), {
|
||||||
type: chartType,
|
type: chartType,
|
||||||
data: data,
|
data: data,
|
||||||
options: options,
|
options: options,
|
||||||
@@ -189,7 +293,7 @@ var PolarArea = generateChart('polar-chart', 'polarArea');
|
|||||||
var Radar = generateChart('radar-chart', 'radar');
|
var Radar = generateChart('radar-chart', 'radar');
|
||||||
var Bubble = generateChart('bubble-chart', 'bubble');
|
var Bubble = generateChart('bubble-chart', 'bubble');
|
||||||
var Scatter = generateChart('scatter-chart', 'scatter');
|
var Scatter = generateChart('scatter-chart', 'scatter');
|
||||||
/* harmony default export */ var BaseCharts = ({
|
/* unused harmony default export */ var _unused_webpack_default_export = ({
|
||||||
Bar: Bar,
|
Bar: Bar,
|
||||||
HorizontalBar: HorizontalBar,
|
HorizontalBar: HorizontalBar,
|
||||||
Doughnut: Doughnut,
|
Doughnut: Doughnut,
|
||||||
@@ -200,191 +304,14 @@ var Scatter = generateChart('scatter-chart', 'scatter');
|
|||||||
Bubble: Bubble,
|
Bubble: Bubble,
|
||||||
Scatter: Scatter
|
Scatter: Scatter
|
||||||
});
|
});
|
||||||
// CONCATENATED MODULE: ./src/index.js
|
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VueCharts", function() { return VueCharts; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Bar", function() { return Bar; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "HorizontalBar", function() { return HorizontalBar; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Doughnut", function() { return Doughnut; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Pie", function() { return Pie; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "PolarArea", function() { return PolarArea; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Radar", function() { return Radar; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Bubble", function() { return Bubble; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "Scatter", function() { return Scatter; });
|
|
||||||
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "mixins", function() { return mixins; });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var VueCharts = {
|
|
||||||
version: package_default.a.version,
|
|
||||||
Bar: Bar,
|
|
||||||
HorizontalBar: HorizontalBar,
|
|
||||||
Doughnut: Doughnut,
|
|
||||||
Line: Line,
|
|
||||||
Pie: Pie,
|
|
||||||
PolarArea: PolarArea,
|
|
||||||
Radar: Radar,
|
|
||||||
Bubble: Bubble,
|
|
||||||
Scatter: Scatter,
|
|
||||||
mixins: mixins
|
|
||||||
};
|
|
||||||
/* harmony default export */ var src = __webpack_exports__["default"] = (VueCharts);
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
/* 1 */
|
|
||||||
/***/ (function(module, exports) {
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: function data() {
|
|
||||||
return {
|
|
||||||
chartData: null
|
|
||||||
};
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'chartData': {
|
|
||||||
handler: function handler(newData, oldData) {
|
|
||||||
if (oldData) {
|
|
||||||
var chart = this.$data._chart;
|
|
||||||
var newDatasetLabels = newData.datasets.map(function (dataset) {
|
|
||||||
return dataset.label;
|
|
||||||
});
|
|
||||||
var oldDatasetLabels = oldData.datasets.map(function (dataset) {
|
|
||||||
return dataset.label;
|
|
||||||
});
|
|
||||||
var oldLabels = JSON.stringify(oldDatasetLabels);
|
|
||||||
var newLabels = JSON.stringify(newDatasetLabels);
|
|
||||||
|
|
||||||
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
|
|
||||||
newData.datasets.forEach(function (dataset, i) {
|
|
||||||
var oldDatasetKeys = Object.keys(oldData.datasets[i]);
|
|
||||||
var newDatasetKeys = Object.keys(dataset);
|
|
||||||
var deletionKeys = oldDatasetKeys.filter(function (key) {
|
|
||||||
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1;
|
|
||||||
});
|
|
||||||
deletionKeys.forEach(function (deletionKey) {
|
|
||||||
delete chart.data.datasets[i][deletionKey];
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var attribute in dataset) {
|
|
||||||
if (dataset.hasOwnProperty(attribute)) {
|
|
||||||
chart.data.datasets[i][attribute] = dataset[attribute];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('labels')) {
|
|
||||||
chart.data.labels = newData.labels;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('xLabels')) {
|
|
||||||
chart.data.xLabels = newData.xLabels;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('yLabels')) {
|
|
||||||
chart.data.yLabels = newData.yLabels;
|
|
||||||
}
|
|
||||||
|
|
||||||
chart.update();
|
|
||||||
} else {
|
|
||||||
chart.destroy();
|
|
||||||
this.renderChart(this.chartData, this.options);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.$data._chart) {
|
|
||||||
this.$data._chart.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.renderChart(this.chartData, this.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
/* 2 */
|
|
||||||
/***/ (function(module, exports) {
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
props: {
|
|
||||||
chartData: {
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'chartData': {
|
|
||||||
handler: function handler(newData, oldData) {
|
|
||||||
if (oldData) {
|
|
||||||
var chart = this.$data._chart;
|
|
||||||
var newDatasetLabels = newData.datasets.map(function (dataset) {
|
|
||||||
return dataset.label;
|
|
||||||
});
|
|
||||||
var oldDatasetLabels = oldData.datasets.map(function (dataset) {
|
|
||||||
return dataset.label;
|
|
||||||
});
|
|
||||||
var oldLabels = JSON.stringify(oldDatasetLabels);
|
|
||||||
var newLabels = JSON.stringify(newDatasetLabels);
|
|
||||||
|
|
||||||
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
|
|
||||||
newData.datasets.forEach(function (dataset, i) {
|
|
||||||
var oldDatasetKeys = Object.keys(oldData.datasets[i]);
|
|
||||||
var newDatasetKeys = Object.keys(dataset);
|
|
||||||
var deletionKeys = oldDatasetKeys.filter(function (key) {
|
|
||||||
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1;
|
|
||||||
});
|
|
||||||
deletionKeys.forEach(function (deletionKey) {
|
|
||||||
delete chart.data.datasets[i][deletionKey];
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var attribute in dataset) {
|
|
||||||
if (dataset.hasOwnProperty(attribute)) {
|
|
||||||
chart.data.datasets[i][attribute] = dataset[attribute];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('labels')) {
|
|
||||||
chart.data.labels = newData.labels;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('xLabels')) {
|
|
||||||
chart.data.xLabels = newData.xLabels;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('yLabels')) {
|
|
||||||
chart.data.yLabels = newData.yLabels;
|
|
||||||
}
|
|
||||||
|
|
||||||
chart.update();
|
|
||||||
} else {
|
|
||||||
chart.destroy();
|
|
||||||
this.renderChart(this.chartData, this.options);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.$data._chart) {
|
|
||||||
this.$data._chart.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.renderChart(this.chartData, this.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 3 */
|
/* 3 */
|
||||||
/***/ (function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
module.exports = {"name":"vue-chartjs","version":"3.1.1","description":"Vue.js wrapper for chart.js for creating beautiful charts.","author":"Jakub Juszczak <jakub@posteo.de>","homepage":"http://vue-chartjs.org","license":"MIT","contributors":[{"name":"Thorsten Lünborg","web":"https://github.com/LinusBorg"},{"name":"Juan Carlos Alonso","web":"https://github.com/jcalonso"}],"maintainers":[{"name":"Jakub Juszczak","email":"jakub@posteo.de","web":"http://www.jakubjuszczak.de"}],"repository":{"type":"git","url":"git+ssh://git@github.com:apertureless/vue-chartjs.git"},"bugs":{"url":"https://github.com/apertureless/vue-chartjs/issues"},"keywords":["ChartJs","Vue","Visualisation","Wrapper","Charts"],"main":"dist/vue-chartjs.js","unpkg":"dist/vue-chartjs.min.js","module":"es/index.js","jsnext:main":"es/index.js","files":["src","dist","es"],"scripts":{"dev":"node build/dev-server.js","build":"yarn run release && yarn run build:es","build:es":"cross-env BABEL_ENV=es babel src --out-dir es","unit":"karma start test/unit/karma.conf.js --single-run","e2e":"node test/e2e/runner.js","test":"npm run unit","lint":"eslint --ext .js,.vue src test/unit/specs test/e2e/specs","release":"webpack --progress --hide-modules --config ./build/webpack.release.js && cross-env NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js","prepublishOnly":"yarn run lint && yarn run test && yarn run build"},"dependencies":{},"peerDependencies":{"chart.js":"2.7.x"},"devDependencies":{"@babel/cli":"^7.0.0-beta.31","@babel/core":"^7.0.0-beta.31","@babel/preset-env":"^7.0.0-beta.31","@babel/preset-stage-2":"^7.0.0-beta.31","babel-loader":"8.0.0-beta.0","chai":"^3.5.0","chart.js":"2.7.0","chromedriver":"^2.28.0","connect-history-api-fallback":"^1.1.0","cross-env":"^5.1.1","cross-spawn":"^5.1.0","css-loader":"^0.28.0","eslint":"^3.19.0","eslint-config-standard":"^10.2.1","eslint-friendly-formatter":"^2.0.7","eslint-loader":"^1.7.1","eslint-plugin-html":"^2.0.1","eslint-plugin-import":"^2.2.0","eslint-plugin-node":"^4.2.2","eslint-plugin-promise":"^3.5.0","eslint-plugin-standard":"^3.0.1","eventsource-polyfill":"^0.9.6","express":"^4.15.2","extract-text-webpack-plugin":"^3.0.1","file-loader":"^0.10.1","friendly-errors-webpack-plugin":"^1.6.1","function-bind":"^1.0.2","html-webpack-plugin":"^2.28.0","http-proxy-middleware":"^0.17.4","inject-loader":"^3.0.0","isparta":"^4.0.0","jasmine-core":"^2.5.2","json-loader":"^0.5.4","karma":"^1.5.0","karma-coverage":"^1.1.1","karma-jasmine":"^1.0.2","karma-mocha":"^1.2.0","karma-phantomjs-launcher":"^1.0.4","karma-phantomjs-shim":"^1.4.0","karma-sinon-chai":"^1.2.0","karma-sourcemap-loader":"^0.3.7","karma-spec-reporter":"0.0.30","karma-webpack":"2","lolex":"^1.6.0","mocha":"^3.1.0","opn":"^5.1.0","ora":"^1.2.0","phantomjs-prebuilt":"^2.1.13","portfinder":"^1.0.13","selenium-server":"^3.3.1","shelljs":"^0.7.7","sinon":"^2.1.0","sinon-chai":"^2.9.0","url-loader":"^0.5.8","vue":"2.5.2","vue-hot-reload-api":"2.1.0","vue-html-loader":"^1.2.4","vue-loader":"^13.3.0","vue-style-loader":"3.0.1","vue-template-compiler":"2.5.2","webpack":"^3.7.1","webpack-dev-middleware":"^1.10.1","webpack-hot-middleware":"^2.17.1","webpack-merge":"^4.1.0"},"engines":{"node":">=6.9.0","npm":">= 3.0.0"},"browserify":{"transform":["babelify"]},"greenkeeper":{"ignore":["extract-text-webpack-plugin","karma-webpack","webpack","webpack-merge"]}}
|
module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
/* 4 */
|
|
||||||
/***/ (function(module, exports) {
|
|
||||||
|
|
||||||
module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
|
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
/******/ ]);
|
/******/ ]);
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=vue-chartjs.js.map
|
||||||
2
dist/vue-chartjs.js.map
vendored
2
dist/vue-chartjs.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/vue-chartjs.min.js
vendored
3
dist/vue-chartjs.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/vue-chartjs.min.js.map
vendored
Normal file
1
dist/vue-chartjs.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -11,6 +11,11 @@ const langs = [
|
|||||||
|
|
||||||
docute.init({
|
docute.init({
|
||||||
title: 'vue-chartjs docs',
|
title: 'vue-chartjs docs',
|
||||||
|
announcement(route) {
|
||||||
|
const info = { type: 'success' }
|
||||||
|
info.html = '<a style="margin-right:10px;" class="docute-button docute-button-mini docute-button-success" href="https://www.paypal.me/apertureless/50eur" target="_blank">Donate!</a> Support vue-chartjs development by a one-time donation.'
|
||||||
|
return info
|
||||||
|
},
|
||||||
landing: true,
|
landing: true,
|
||||||
landing: '_landing.html',
|
landing: '_landing.html',
|
||||||
repo: 'apertureless/vue-chartjs',
|
repo: 'apertureless/vue-chartjs',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
||||||
<title>vue-chartjs doc</title>
|
<title>vue-chartjs doc</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/docute@2/dist/docute.css">
|
<link rel="stylesheet" href="https://unpkg.com/docute/dist/docute.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- don't remove this part start -->
|
<!-- don't remove this part start -->
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ search: ja
|
|||||||
**vue-chartjs** は [Chart.js](https://github.com/chartjs/Chart.js) をvueで使用するためのラッパーです。 再利用可能なチャートコンポーネントを簡単に作成できます。
|
**vue-chartjs** は [Chart.js](https://github.com/chartjs/Chart.js) をvueで使用するためのラッパーです。 再利用可能なチャートコンポーネントを簡単に作成できます。
|
||||||
|
|
||||||
## イントロ
|
## イントロ
|
||||||
`vue-chartjs` vueの中であまり面倒なくchart.jsを使うことができます。 シンプルなチャートをできるだけ早く実行したいという人に最適です。
|
`vue-chartjs` vueの中であまり面倒ことがなくchart.jsを使うことができます。 シンプルなチャートをできるだけ早く実行したいという人に最適です。
|
||||||
|
|
||||||
chart.jsの基本ロジックを抽象化していますが、公開されたchart.jsのオブジェクト使用して柔軟にカスタマイズできます。
|
chart.jsの基本ロジックを抽象化していますが、公開されたchart.jsのオブジェクト使用して柔軟にカスタマイズできます。
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ export default {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
renderChart()メソッドに2つの引数を渡すことができます:
|
`renderChart()`メソッドに2つの引数を渡すことができます:
|
||||||
|
|
||||||
- Data object
|
- Data object
|
||||||
- Options object
|
- Options object
|
||||||
@@ -64,16 +64,18 @@ renderChart()メソッドに2つの引数を渡すことができます:
|
|||||||
```
|
```
|
||||||
|
|
||||||
詳細については、[Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) のドキュメントをご覧ください。
|
詳細については、[Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) のドキュメントをご覧ください。
|
||||||
|
|
||||||
## プロパティ
|
## プロパティ
|
||||||
|
|
||||||
BaseChartsには基本プロパティがいくつか定義されています。 extendされたときにそれらは明示的に表示されていませんが、使用するときに上書きして設定することができます。
|
BaseChartsには基本プロパティがいくつか定義されています。 `extend()`したときにそれらは *表示されていません* が、使用するときに上書きして設定することができます。
|
||||||
|
|
||||||
| プロパティ | 説明 |
|
| プロパティ | 説明 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| width | chartの表示幅 |
|
| width | chartの表示幅 |
|
||||||
| height | chartの表示高さ |
|
| height | chartの表示高さ |
|
||||||
| chart-id | canvas要素のid |
|
| chart-id | canvas要素のid |
|
||||||
|
| css-classes | 周囲のdivのCSSクラスの文字列 |
|
||||||
|
| styles | 周囲のdivコンテナのCSSスタイルを持つオブジェクト |
|
||||||
|
|
||||||
## 実装例
|
## 実装例
|
||||||
|
|
||||||
@@ -115,7 +117,7 @@ export default {
|
|||||||
```
|
```
|
||||||
|
|
||||||
<p class="warning">
|
<p class="warning">
|
||||||
`width` と `height` を反映させるためには、 `responsive:false` を設定しなければならないことに注意してください。
|
固定値の`width` と `height` を反映させるためには、 `responsive:false` を設定しなければならないことに注意してください。
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
### コンポーネント内のローカルデータを使用する場合
|
### コンポーネント内のローカルデータを使用する場合
|
||||||
@@ -147,8 +149,7 @@ export default {
|
|||||||
|
|
||||||
### コンポーネントの再利用
|
### コンポーネントの再利用
|
||||||
|
|
||||||
チャートコンポーネントを再利用可能にしたい場合は、ラッパーを使用することをお勧めします。このようにすると、チャートコンポーネントはデータ表示とロジックを含むラッパーコンポーネントに対してのみ応答可能です。単一ページアプリケーションを実行している場合や、laravelで統合されている場合は、異なった方法があります。
|
チャートコンポーネントを再利用可能にしたい場合は、ラッパーを使用することがベストです。このようにしてチャートコンポーネントは純粋なデータ表示と、背後にあるロジックのラッパーとしてのみ責務を負います。単一ページアプリケーションを実行している場合や、たとえば laravel などで統合されている場合は、異なった方法があります。
|
||||||
|
|
||||||
|
|
||||||
## リアクティブデータ
|
## リアクティブデータ
|
||||||
|
|
||||||
@@ -182,7 +183,8 @@ export default {
|
|||||||
mixins: [reactiveProp],
|
mixins: [reactiveProp],
|
||||||
props: ['options'],
|
props: ['options'],
|
||||||
mounted () {
|
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)
|
this.renderChart(this.chartData, this.options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +261,24 @@ export default {
|
|||||||
|
|
||||||
## Chart.js オブジェクト
|
## Chart.js オブジェクト
|
||||||
|
|
||||||
場合によっては、chart.jsをより詳細に制御する必要があります。Chart.jsインスタンスには `this.$data._chart` を使ってアクセスします。
|
時にはchart.jsをより詳細に制御する必要があります。そのためには `this.$data._chart` を使ってChart.jsインスタンスにアクセスすることができます。
|
||||||
|
|
||||||
|
## インライン プラグイン
|
||||||
|
|
||||||
|
Chart.jsでは、グローバルプラグインとインラインプラグインを定義できます。[Chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html)で記載されているのようなグローバルプラグインは、 `vue-chartjs ` で問題なく動作しています。
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
mounted () {
|
||||||
|
this.addPlugin({
|
||||||
|
id: 'my-plugin',
|
||||||
|
beforeInit: function (chart) {
|
||||||
|
....
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 利用可能なグラフ
|
## 利用可能なグラフ
|
||||||
|
|
||||||
@@ -293,6 +312,11 @@ export default {
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### 散布図
|
||||||
|
|
||||||
|
このチャートは、他のものとは異なるデータ構造を持っています。現在のところ、reactive mixins はこのチャートタイプでは機能していません。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## ビルド方法の違い
|
## ビルド方法の違い
|
||||||
あなたが使用するビルドツールに依存した3つの異なるエントリーポイントがあります。 依存するライブラリは一緒にバンドルされているか、または peerDependency として指定します。
|
あなたが使用するビルドツールに依存した3つの異なるエントリーポイントがあります。 依存するライブラリは一緒にバンドルされているか、または peerDependency として指定します。
|
||||||
@@ -320,3 +344,13 @@ Vue.jsとChart.jsは `peerDependencies` なので別にインストールする
|
|||||||
|
|
||||||
### Webpack 2
|
### Webpack 2
|
||||||
Webpack 2を使用している場合、 `jsnext:main` または `module` に`es/index.js` を指定します。 ソースファイルは __トランスパイル__ されます。またmoduleには __バンドル__ されません。このようにすると `tree shaking` が動作します。バンドル版のように、`peerDependencies` で指定された `Vue.js` と `Chart.js` はインストールする必要があります。
|
Webpack 2を使用している場合、 `jsnext:main` または `module` に`es/index.js` を指定します。 ソースファイルは __トランスパイル__ されます。またmoduleには __バンドル__ されません。このようにすると `tree shaking` が動作します。バンドル版のように、`peerDependencies` で指定された `Vue.js` と `Chart.js` はインストールする必要があります。
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
以下に `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/)
|
||||||
10646
package-lock.json
generated
10646
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-chartjs",
|
"name": "vue-chartjs",
|
||||||
"version": "3.1.1",
|
"version": "3.2.1",
|
||||||
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
|
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
|
||||||
"author": "Jakub Juszczak <jakub@posteo.de>",
|
"author": "Jakub Juszczak <jakub@posteo.de>",
|
||||||
"homepage": "http://vue-chartjs.org",
|
"homepage": "http://vue-chartjs.org",
|
||||||
@@ -53,21 +53,20 @@
|
|||||||
"e2e": "node test/e2e/runner.js",
|
"e2e": "node test/e2e/runner.js",
|
||||||
"test": "npm run unit",
|
"test": "npm run unit",
|
||||||
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
|
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
|
||||||
"release": "webpack --progress --hide-modules --config ./build/webpack.release.js && cross-env NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js",
|
"release": "cross-env NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.js && cross-env NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js",
|
||||||
"prepublishOnly": "yarn run lint && yarn run test && yarn run build"
|
"prepublishOnly": "yarn run lint && yarn run test && yarn run build"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"chart.js": "2.7.x"
|
"chart.js": "2.7.x"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.0.0-beta.31",
|
"@babel/cli": "^7.0.0-beta.42",
|
||||||
"@babel/core": "^7.0.0-beta.31",
|
"@babel/core": "^7.0.0-beta.42",
|
||||||
"@babel/preset-env": "^7.0.0-beta.31",
|
"@babel/preset-env": "^7.0.0-beta.42",
|
||||||
"@babel/preset-stage-2": "^7.0.0-beta.31",
|
"@babel/preset-stage-2": "^7.0.0-beta.42",
|
||||||
"babel-loader": "8.0.0-beta.0",
|
"babel-loader": "8.0.0-beta.0",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"chart.js": "2.7.0",
|
"chart.js": "2.7.2",
|
||||||
"chromedriver": "^2.28.0",
|
"chromedriver": "^2.28.0",
|
||||||
"connect-history-api-fallback": "^1.1.0",
|
"connect-history-api-fallback": "^1.1.0",
|
||||||
"cross-env": "^5.1.1",
|
"cross-env": "^5.1.1",
|
||||||
@@ -115,12 +114,12 @@
|
|||||||
"sinon": "^2.1.0",
|
"sinon": "^2.1.0",
|
||||||
"sinon-chai": "^2.9.0",
|
"sinon-chai": "^2.9.0",
|
||||||
"url-loader": "^0.5.8",
|
"url-loader": "^0.5.8",
|
||||||
"vue": "2.5.2",
|
"vue": "2.5.16",
|
||||||
"vue-hot-reload-api": "2.1.0",
|
"vue-hot-reload-api": "2.3.0",
|
||||||
"vue-html-loader": "^1.2.4",
|
"vue-html-loader": "^1.2.4",
|
||||||
"vue-loader": "^13.3.0",
|
"vue-loader": "^14.2.1",
|
||||||
"vue-style-loader": "3.0.1",
|
"vue-style-loader": "4.0.2",
|
||||||
"vue-template-compiler": "2.5.2",
|
"vue-template-compiler": "2.5.16",
|
||||||
"webpack": "^3.7.1",
|
"webpack": "^3.7.1",
|
||||||
"webpack-dev-middleware": "^1.10.1",
|
"webpack-dev-middleware": "^1.10.1",
|
||||||
"webpack-hot-middleware": "^2.17.1",
|
"webpack-hot-middleware": "^2.17.1",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Bar } from '../BaseCharts'
|
import { Bar } from '../BaseCharts'
|
||||||
import reactiveData from '../mixins/reactiveData'
|
import { reactiveData } from '../mixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: Bar,
|
extends: Bar,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Bar } from '../BaseCharts'
|
import { Bar } from '../BaseCharts'
|
||||||
import reactiveProp from '../mixins/reactiveProp'
|
import { reactiveProp } from '../mixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: Bar,
|
extends: Bar,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import mixins from './mixins/index.js'
|
import mixins from './mixins/index.js'
|
||||||
import npmCfg from '../package.json'
|
|
||||||
import {
|
import {
|
||||||
Bar,
|
Bar,
|
||||||
HorizontalBar,
|
HorizontalBar,
|
||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
} from './BaseCharts'
|
} from './BaseCharts'
|
||||||
|
|
||||||
const VueCharts = {
|
const VueCharts = {
|
||||||
version: npmCfg.version,
|
|
||||||
Bar,
|
Bar,
|
||||||
HorizontalBar,
|
HorizontalBar,
|
||||||
Doughnut,
|
Doughnut,
|
||||||
|
|||||||
@@ -1,5 +1,89 @@
|
|||||||
import reactiveData from './reactiveData.js'
|
function dataHandler (newData, oldData) {
|
||||||
import reactiveProp from './reactiveProp.js'
|
if (oldData) {
|
||||||
|
let chart = this.$data._chart
|
||||||
|
|
||||||
|
// Get new and old DataSet Labels
|
||||||
|
let newDatasetLabels = newData.datasets.map((dataset) => {
|
||||||
|
return dataset.label
|
||||||
|
})
|
||||||
|
|
||||||
|
let oldDatasetLabels = oldData.datasets.map((dataset) => {
|
||||||
|
return dataset.label
|
||||||
|
})
|
||||||
|
|
||||||
|
// Stringify 'em for easier compare
|
||||||
|
const oldLabels = JSON.stringify(oldDatasetLabels)
|
||||||
|
const newLabels = JSON.stringify(newDatasetLabels)
|
||||||
|
|
||||||
|
// Check if Labels are equal and if dataset length is equal
|
||||||
|
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
|
||||||
|
newData.datasets.forEach((dataset, i) => {
|
||||||
|
// Get new and old dataset keys
|
||||||
|
const oldDatasetKeys = Object.keys(oldData.datasets[i])
|
||||||
|
const newDatasetKeys = Object.keys(dataset)
|
||||||
|
|
||||||
|
// Get keys that aren't present in the new data
|
||||||
|
const deletionKeys = oldDatasetKeys.filter((key) => {
|
||||||
|
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1
|
||||||
|
})
|
||||||
|
|
||||||
|
// Remove outdated key-value pairs
|
||||||
|
deletionKeys.forEach((deletionKey) => {
|
||||||
|
delete chart.data.datasets[i][deletionKey]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Update attributes individually to avoid re-rendering the entire chart
|
||||||
|
for (const attribute in dataset) {
|
||||||
|
if (dataset.hasOwnProperty(attribute)) {
|
||||||
|
chart.data.datasets[i][attribute] = dataset[attribute]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (newData.hasOwnProperty('labels')) {
|
||||||
|
chart.data.labels = newData.labels
|
||||||
|
}
|
||||||
|
if (newData.hasOwnProperty('xLabels')) {
|
||||||
|
chart.data.xLabels = newData.xLabels
|
||||||
|
}
|
||||||
|
if (newData.hasOwnProperty('yLabels')) {
|
||||||
|
chart.data.yLabels = newData.yLabels
|
||||||
|
}
|
||||||
|
chart.update()
|
||||||
|
} else {
|
||||||
|
chart.destroy()
|
||||||
|
this.renderChart(this.chartData, this.options)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.$data._chart) {
|
||||||
|
this.$data._chart.destroy()
|
||||||
|
}
|
||||||
|
this.renderChart(this.chartData, this.options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const reactiveData = {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
chartData: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
'chartData': dataHandler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const reactiveProp = {
|
||||||
|
props: {
|
||||||
|
chartData: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'chartData': dataHandler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
reactiveData,
|
reactiveData,
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
chartData: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'chartData': {
|
|
||||||
handler (newData, oldData) {
|
|
||||||
if (oldData) {
|
|
||||||
let chart = this.$data._chart
|
|
||||||
|
|
||||||
// Get new and old DataSet Labels
|
|
||||||
let newDatasetLabels = newData.datasets.map((dataset) => {
|
|
||||||
return dataset.label
|
|
||||||
})
|
|
||||||
|
|
||||||
let oldDatasetLabels = oldData.datasets.map((dataset) => {
|
|
||||||
return dataset.label
|
|
||||||
})
|
|
||||||
|
|
||||||
// Stringify 'em for easier compare
|
|
||||||
const oldLabels = JSON.stringify(oldDatasetLabels)
|
|
||||||
const newLabels = JSON.stringify(newDatasetLabels)
|
|
||||||
|
|
||||||
// Check if Labels are equal and if dataset length is equal
|
|
||||||
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
|
|
||||||
newData.datasets.forEach((dataset, i) => {
|
|
||||||
// Get new and old dataset keys
|
|
||||||
const oldDatasetKeys = Object.keys(oldData.datasets[i])
|
|
||||||
const newDatasetKeys = Object.keys(dataset)
|
|
||||||
|
|
||||||
// Get keys that aren't present in the new data
|
|
||||||
const deletionKeys = oldDatasetKeys.filter((key) => {
|
|
||||||
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1
|
|
||||||
})
|
|
||||||
|
|
||||||
// Remove outdated key-value pairs
|
|
||||||
deletionKeys.forEach((deletionKey) => {
|
|
||||||
delete chart.data.datasets[i][deletionKey]
|
|
||||||
})
|
|
||||||
|
|
||||||
// Update attributes individually to avoid re-rendering the entire chart
|
|
||||||
for (const attribute in dataset) {
|
|
||||||
if (dataset.hasOwnProperty(attribute)) {
|
|
||||||
chart.data.datasets[i][attribute] = dataset[attribute]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('labels')) {
|
|
||||||
chart.data.labels = newData.labels
|
|
||||||
}
|
|
||||||
if (newData.hasOwnProperty('xLabels')) {
|
|
||||||
chart.data.xLabels = newData.xLabels
|
|
||||||
}
|
|
||||||
if (newData.hasOwnProperty('yLabels')) {
|
|
||||||
chart.data.yLabels = newData.yLabels
|
|
||||||
}
|
|
||||||
chart.update()
|
|
||||||
} else {
|
|
||||||
chart.destroy()
|
|
||||||
this.renderChart(this.chartData, this.options)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.$data._chart) {
|
|
||||||
this.$data._chart.destroy()
|
|
||||||
}
|
|
||||||
this.renderChart(this.chartData, this.options)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
props: {
|
|
||||||
chartData: {
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'chartData': {
|
|
||||||
handler (newData, oldData) {
|
|
||||||
if (oldData) {
|
|
||||||
let chart = this.$data._chart
|
|
||||||
|
|
||||||
// Get new and old DataSet Labels
|
|
||||||
let newDatasetLabels = newData.datasets.map((dataset) => {
|
|
||||||
return dataset.label
|
|
||||||
})
|
|
||||||
|
|
||||||
let oldDatasetLabels = oldData.datasets.map((dataset) => {
|
|
||||||
return dataset.label
|
|
||||||
})
|
|
||||||
|
|
||||||
// Stringify 'em for easier compare
|
|
||||||
const oldLabels = JSON.stringify(oldDatasetLabels)
|
|
||||||
const newLabels = JSON.stringify(newDatasetLabels)
|
|
||||||
|
|
||||||
// Check if Labels are equal and if dataset length is equal
|
|
||||||
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
|
|
||||||
newData.datasets.forEach((dataset, i) => {
|
|
||||||
// Get new and old dataset keys
|
|
||||||
const oldDatasetKeys = Object.keys(oldData.datasets[i])
|
|
||||||
const newDatasetKeys = Object.keys(dataset)
|
|
||||||
|
|
||||||
// Get keys that aren't present in the new data
|
|
||||||
const deletionKeys = oldDatasetKeys.filter((key) => {
|
|
||||||
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1
|
|
||||||
})
|
|
||||||
|
|
||||||
// Remove outdated key-value pairs
|
|
||||||
deletionKeys.forEach((deletionKey) => {
|
|
||||||
delete chart.data.datasets[i][deletionKey]
|
|
||||||
})
|
|
||||||
|
|
||||||
// Update attributes individually to avoid re-rendering the entire chart
|
|
||||||
for (const attribute in dataset) {
|
|
||||||
if (dataset.hasOwnProperty(attribute)) {
|
|
||||||
chart.data.datasets[i][attribute] = dataset[attribute]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (newData.hasOwnProperty('labels')) {
|
|
||||||
chart.data.labels = newData.labels
|
|
||||||
}
|
|
||||||
if (newData.hasOwnProperty('xLabels')) {
|
|
||||||
chart.data.xLabels = newData.xLabels
|
|
||||||
}
|
|
||||||
if (newData.hasOwnProperty('yLabels')) {
|
|
||||||
chart.data.yLabels = newData.yLabels
|
|
||||||
}
|
|
||||||
chart.update()
|
|
||||||
} else {
|
|
||||||
chart.destroy()
|
|
||||||
this.renderChart(this.chartData, this.options)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.$data._chart) {
|
|
||||||
this.$data._chart.destroy()
|
|
||||||
}
|
|
||||||
this.renderChart(this.chartData, this.options)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user