mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fc76050f6 | ||
|
|
e2a8f3ca3c | ||
|
|
6913312be9 | ||
|
|
2a5512ab9a | ||
|
|
818559f829 | ||
|
|
374d978577 | ||
|
|
fe85d47b61 | ||
|
|
447223cbef | ||
|
|
504c0b1d91 | ||
|
|
8795e456f1 | ||
|
|
a71429e146 | ||
|
|
90f2ffd63c | ||
|
|
ea1f943933 | ||
|
|
7367ea115d | ||
|
|
eec2c402b6 | ||
|
|
9bd7712f3e | ||
|
|
fcaa3dee91 | ||
|
|
1bb567e074 | ||
|
|
e38e208532 |
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,5 +1,44 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [v2.5.2](https://github.com/apertureless/vue-chartjs/tree/v2.5.2) (2017-03-14)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.1...v2.5.2)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- TypeError: child.\_updateFromParent is not a function [\#62](https://github.com/apertureless/vue-chartjs/issues/62)
|
||||||
|
- child.\_updateFromParent is not a function [\#59](https://github.com/apertureless/vue-chartjs/issues/59)
|
||||||
|
- dependency was not found [\#58](https://github.com/apertureless/vue-chartjs/issues/58)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Develop [\#63](https://github.com/apertureless/vue-chartjs/pull/63) ([apertureless](https://github.com/apertureless))
|
||||||
|
- Fix typo for legacy tag [\#61](https://github.com/apertureless/vue-chartjs/pull/61) ([kylestev](https://github.com/kylestev))
|
||||||
|
|
||||||
|
## [v2.5.1](https://github.com/apertureless/vue-chartjs/tree/v2.5.1) (2017-03-11)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.0...v2.5.1)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- Lines are looking weird. [\#57](https://github.com/apertureless/vue-chartjs/issues/57)
|
||||||
|
- Working with objects [\#48](https://github.com/apertureless/vue-chartjs/issues/48)
|
||||||
|
- Mixins don't seem to trigger a refresh of the chart [\#44](https://github.com/apertureless/vue-chartjs/issues/44)
|
||||||
|
|
||||||
|
## [v2.5.0](https://github.com/apertureless/vue-chartjs/tree/v2.5.0) (2017-03-08)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.4.1...v2.5.0)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- UglifyJs is not happy with versions after 2.3.8 [\#54](https://github.com/apertureless/vue-chartjs/issues/54)
|
||||||
|
- Why "main" in Package.json is "src/index.js" and not "dist/vue-chartjs.js" [\#53](https://github.com/apertureless/vue-chartjs/issues/53)
|
||||||
|
- Adding static data and dynamic data at the same time. [\#52](https://github.com/apertureless/vue-chartjs/issues/52)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- separate HorizontalBar component added [\#56](https://github.com/apertureless/vue-chartjs/pull/56) ([imbashamba](https://github.com/imbashamba))
|
||||||
|
|
||||||
|
## [v2.4.1](https://github.com/apertureless/vue-chartjs/tree/v2.4.1) (2017-03-04)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.4.0...v2.4.1)
|
||||||
|
|
||||||
## [v2.4.0](https://github.com/apertureless/vue-chartjs/tree/v2.4.0) (2017-03-03)
|
## [v2.4.0](https://github.com/apertureless/vue-chartjs/tree/v2.4.0) (2017-03-03)
|
||||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.9...v2.4.0)
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.9...v2.4.0)
|
||||||
|
|
||||||
|
|||||||
26
README.md
26
README.md
@@ -118,6 +118,7 @@ However you can simply implement this by 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. More info [here](http://vue-chartjs.org/#/home?id=reactive-data)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// MonthlyIncome.js
|
// MonthlyIncome.js
|
||||||
@@ -177,29 +178,20 @@ export default Line.extend({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Webpack & Bundling tools
|
## Webpack, Browserify and dist files.
|
||||||
There are now two version the main entry point is `src/index.js` which is the ES6 source, unbundled.
|
|
||||||
If you're using webpack it is recommended to use this one. Because the bundled umd version has vue.js and chart.js bundled into it.
|
|
||||||
|
|
||||||
However if you have problems o you can import the dist file
|
If you use `import VueCharts from 'vue-chartjs'` you will mostly import the UMD build of vue-chart.js
|
||||||
|
This is because of compatibility reasons. This approach however has a downside: vue.js and chart.js are bundled into the file.
|
||||||
|
And you end up with two vue instances.
|
||||||
|
|
||||||
|
If you're using webpack 2 however, it will automatically import the transpiled ES sources.
|
||||||
|
If you know what you're doing you can import directly from the transpiled es sources:
|
||||||
|
|
||||||
```
|
```
|
||||||
import VueCharts from 'vue-chartjs/dist/vue-chartjs'
|
import { Line } from 'vue-chartjs/es'
|
||||||
// or
|
|
||||||
import { Line } from 'vue-chartjs/dist/vue-chartjs'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can set an alias.
|
|
||||||
|
|
||||||
### Browserify
|
|
||||||
|
|
||||||
In order for a browserify user to transpile the code, they would need to install `babelify` and `babel-preset-es2015` and add a .babelrc file in the root of their project with the following code:
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"presets": ["es2015"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
## Available Charts
|
## Available Charts
|
||||||
|
|
||||||
### Bar Chart
|
### Bar Chart
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ module.exports = {
|
|||||||
output: {
|
output: {
|
||||||
filename: './dist/[name].js',
|
filename: './dist/[name].js',
|
||||||
library: 'VueChartJs',
|
library: 'VueChartJs',
|
||||||
libraryTarget: 'umd'
|
libraryTarget: 'umd',
|
||||||
|
umdNamedDefine: true
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
preLoaders: [
|
preLoaders: [
|
||||||
|
|||||||
18
build/webpack.release.min.js
vendored
Normal file
18
build/webpack.release.min.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
var config = require('./webpack.release.js')
|
||||||
|
var webpack = require('webpack')
|
||||||
|
|
||||||
|
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
|
||||||
|
|
||||||
|
delete config.devtool
|
||||||
|
|
||||||
|
config.plugins = [
|
||||||
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
|
sourceMap: false,
|
||||||
|
compress: {
|
||||||
|
warnings: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
new webpack.optimize.OccurenceOrderPlugin()
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports = config
|
||||||
43586
dist/vue-chartjs.js
vendored
43586
dist/vue-chartjs.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ If you are working with Vue.js 2+ simple run:
|
|||||||
|
|
||||||
`yarn add vue-chartjs -S`
|
`yarn add vue-chartjs -S`
|
||||||
|
|
||||||
If you are using vue 1.x please use the `legancy` tag. However the vue 1 version is not maintained anymore.
|
If you are using vue 1.x please use the `legacy` tag. However the vue 1 version is not maintained anymore.
|
||||||
|
|
||||||
`yarn add vue-chartjs@legacy -S`
|
`yarn add vue-chartjs@legacy -S`
|
||||||
|
|
||||||
@@ -239,6 +239,18 @@ export default Line.extend({
|
|||||||
</style>
|
</style>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p class="warning">
|
||||||
|
⚠ Attention: If you mutate your data in a parent component and pass it to your child chart component keep in mind the javascript limitiations.
|
||||||
|
More info in this [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
|
||||||
|
</p>
|
||||||
|
|
||||||
|
### Limitations
|
||||||
|
<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 object
|
## Chart.js object
|
||||||
|
|
||||||
Sometimes you need more control over chart.js. Thats why you can access the chart.js instance over `this._chart`
|
Sometimes you need more control over chart.js. Thats why you can access the chart.js instance over `this._chart`
|
||||||
@@ -247,11 +259,7 @@ Sometimes you need more control over chart.js. Thats why you can access the char
|
|||||||
|
|
||||||
### Bar Chart
|
### Bar Chart
|
||||||
<p class="tip">
|
<p class="tip">
|
||||||
The bar chart has an **optional** third parameter, which is the type.
|
There are two versions of the Bar chart. `{Bar}` and `{HorizontalBar}`
|
||||||
The default type is `bar` but you can pass `horizontalBar` if you want horizontal bars.
|
|
||||||
|
|
||||||
`renderChart (data, options, type) {}`
|
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||

|

|
||||||
@@ -279,20 +287,19 @@ Sometimes you need more control over chart.js. Thats why you can access the char
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Webpack & Bundling tools
|
## Webpack, Browserify and dist files.
|
||||||
There are now two version the main entry point is `src/index.js` which is the ES6 source, unbundled.
|
|
||||||
If you're using webpack it is recommended to use this one. Because the bundled umd version has vue.js and chart.js bundled into it.
|
|
||||||
|
|
||||||
However if you have problems o you can import the dist file
|
If you use `import VueCharts from 'vue-chartjs'` you will mostly import the UMD build of vue-chart.js
|
||||||
|
This is because of compatibility reasons. This approach however has a downside: vue.js and chart.js are bundled into the file.
|
||||||
|
And you end up with two vue instances.
|
||||||
|
|
||||||
|
If you're using webpack 2 or rollup however, it will automatically import the transpiled ES sources.
|
||||||
|
If you know what you're doing you can import directly from the transpiled es sources:
|
||||||
|
|
||||||
```
|
```
|
||||||
import VueCharts from 'vue-chartjs/dist/vue-chartjs'
|
import { Line } from 'vue-chartjs/es'
|
||||||
// or
|
|
||||||
import { Line } from 'vue-chartjs/dist/vue-chartjs'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can set an alias.
|
|
||||||
|
|
||||||
### Browserify
|
### Browserify
|
||||||
|
|
||||||
In order for a browserify user to transpile the code, they would need to install `babelify` and `babel-preset-es2015` and add a .babelrc file in the root of their project with the following code:
|
In order for a browserify user to transpile the code, they would need to install `babelify` and `babel-preset-es2015` and add a .babelrc file in the root of their project with the following code:
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-chartjs",
|
"name": "vue-chartjs",
|
||||||
"version": "2.4.1",
|
"version": "2.5.3",
|
||||||
"description": "vue.js wrapper for chart.js",
|
"description": "vue.js wrapper for chart.js",
|
||||||
"author": "Jakub Juszczak <jakub@posteo.de>",
|
"author": "Jakub Juszczak <jakub@posteo.de>",
|
||||||
"homepage": "http://vue-chartjs.org",
|
"homepage": "http://vue-chartjs.org",
|
||||||
@@ -37,7 +37,8 @@
|
|||||||
"Charts"
|
"Charts"
|
||||||
],
|
],
|
||||||
"main": "dist/vue-chartjs.js",
|
"main": "dist/vue-chartjs.js",
|
||||||
"unpkg": "dist/vue-chartjs.js",
|
"unpkg": "dist/vue-chartjs.min.js",
|
||||||
|
"browser": "dist/vue-chartjs.min.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
"jsnext:main": "es/index.js",
|
"jsnext:main": "es/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -53,12 +54,13 @@
|
|||||||
"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",
|
"release": "webpack --progress --hide-modules --config ./build/webpack.release.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js",
|
||||||
"prepublish": "yarn run lint && yarn run test && yarn run build"
|
"prepublish": "yarn run lint && yarn run test && yarn run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chart.js": "^2.5.0",
|
"chart.js": "^2.5.0",
|
||||||
"vue": "^2.2.1"
|
"lodash": "^4.17.4",
|
||||||
|
"vue": "^2.2.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.23.0",
|
"babel-cli": "^6.23.0",
|
||||||
@@ -101,7 +103,6 @@
|
|||||||
"karma-sourcemap-loader": "^0.3.7",
|
"karma-sourcemap-loader": "^0.3.7",
|
||||||
"karma-spec-reporter": "0.0.26",
|
"karma-spec-reporter": "0.0.26",
|
||||||
"karma-webpack": "^1.7.0",
|
"karma-webpack": "^1.7.0",
|
||||||
"lodash": "^4.17.4",
|
|
||||||
"lolex": "^1.4.0",
|
"lolex": "^1.4.0",
|
||||||
"mocha": "^3.1.0",
|
"mocha": "^3.1.0",
|
||||||
"nightwatch": "^0.9.8",
|
"nightwatch": "^0.9.8",
|
||||||
@@ -116,7 +117,7 @@
|
|||||||
"vue-html-loader": "^1.2.4",
|
"vue-html-loader": "^1.2.4",
|
||||||
"vue-loader": "^11.1.4",
|
"vue-loader": "^11.1.4",
|
||||||
"vue-style-loader": "^2.0.3",
|
"vue-style-loader": "^2.0.3",
|
||||||
"vue-template-compiler": "^2.2.1",
|
"vue-template-compiler": "^2.2.4",
|
||||||
"webpack": "^1.13.2",
|
"webpack": "^1.13.2",
|
||||||
"webpack-dev-middleware": "^1.4.0",
|
"webpack-dev-middleware": "^1.4.0",
|
||||||
"webpack-hot-middleware": "^2.6.0",
|
"webpack-hot-middleware": "^2.6.0",
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export default Vue.extend({
|
|||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$refs.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: type || 'bar',
|
type: 'bar',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
}
|
}
|
||||||
|
|||||||
79
src/BaseCharts/HorizontalBar.js
Normal file
79
src/BaseCharts/HorizontalBar.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import Chart from 'chart.js'
|
||||||
|
import { mergeOptions } from '../helpers/options'
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
|
render: function (createElement) {
|
||||||
|
return createElement(
|
||||||
|
'div',
|
||||||
|
[
|
||||||
|
createElement(
|
||||||
|
'canvas', {
|
||||||
|
attrs: {
|
||||||
|
id: this.chartId,
|
||||||
|
width: this.width,
|
||||||
|
height: this.height
|
||||||
|
},
|
||||||
|
ref: 'canvas'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'horizontalbar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
default: 400,
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
default: 400,
|
||||||
|
type: Number
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
defaultOptions: {
|
||||||
|
scales: {
|
||||||
|
yAxes: [{
|
||||||
|
ticks: {
|
||||||
|
beginAtZero: true
|
||||||
|
},
|
||||||
|
gridLines: {
|
||||||
|
display: false
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
xAxes: [ {
|
||||||
|
gridLines: {
|
||||||
|
display: false
|
||||||
|
},
|
||||||
|
categoryPercentage: 0.5,
|
||||||
|
barPercentage: 0.2
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
renderChart (data, options, type) {
|
||||||
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
this._chart = new Chart(
|
||||||
|
this.$refs.canvas.getContext('2d'), {
|
||||||
|
type: 'horizontalBar',
|
||||||
|
data: data,
|
||||||
|
options: chartOptions
|
||||||
|
}
|
||||||
|
)
|
||||||
|
this._chart.generateLegend()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this._chart.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
16
src/examples/HorizontalBarExample.js
Normal file
16
src/examples/HorizontalBarExample.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import HorizontalBarChart from '../BaseCharts/HorizontalBar'
|
||||||
|
|
||||||
|
export default HorizontalBarChart.extend({
|
||||||
|
mounted () {
|
||||||
|
this.renderChart({
|
||||||
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: 'Data One',
|
||||||
|
backgroundColor: '#f87979',
|
||||||
|
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, {responsive: true, maintainAspectRatio: false})
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import Bar from './BaseCharts/Bar'
|
import Bar from './BaseCharts/Bar'
|
||||||
|
import HorizontalBar from './BaseCharts/HorizontalBar'
|
||||||
import Doughnut from './BaseCharts/Doughnut'
|
import Doughnut from './BaseCharts/Doughnut'
|
||||||
import Line from './BaseCharts/Line'
|
import Line from './BaseCharts/Line'
|
||||||
import Pie from './BaseCharts/Pie'
|
import Pie from './BaseCharts/Pie'
|
||||||
@@ -9,6 +10,7 @@ import mixins from './mixins/index.js'
|
|||||||
|
|
||||||
const VueCharts = {
|
const VueCharts = {
|
||||||
Bar,
|
Bar,
|
||||||
|
HorizontalBar,
|
||||||
Doughnut,
|
Doughnut,
|
||||||
Line,
|
Line,
|
||||||
Pie,
|
Pie,
|
||||||
@@ -23,6 +25,7 @@ export default VueCharts
|
|||||||
export {
|
export {
|
||||||
VueCharts,
|
VueCharts,
|
||||||
Bar,
|
Bar,
|
||||||
|
HorizontalBar,
|
||||||
Doughnut,
|
Doughnut,
|
||||||
Line,
|
Line,
|
||||||
Pie,
|
Pie,
|
||||||
|
|||||||
64
test/unit/specs/HorizontalBar.spec.js
Normal file
64
test/unit/specs/HorizontalBar.spec.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import HorizontalBarChart from 'src/examples/HorizontalBarExample'
|
||||||
|
|
||||||
|
describe('HorizontalBarChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
render: function (createElement) {
|
||||||
|
return createElement(
|
||||||
|
HorizontalBarChart
|
||||||
|
)
|
||||||
|
},
|
||||||
|
components: { HorizontalBarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#horizontalbar-chart')).not.to.be.an('undefined')
|
||||||
|
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
|
||||||
|
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
|
||||||
|
expect(vm.$el.querySelector('canvas')).to.exist
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
render: function (createElement) {
|
||||||
|
return createElement(
|
||||||
|
HorizontalBarChart, {
|
||||||
|
props: {
|
||||||
|
chartId: 'horizontalbarchartprop'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
components: { HorizontalBarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#horizontalbarchartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should destroy chart instance', (done) => {
|
||||||
|
const vm = new Vue({
|
||||||
|
render: function (createElement) {
|
||||||
|
return createElement(
|
||||||
|
HorizontalBarChart
|
||||||
|
)
|
||||||
|
},
|
||||||
|
components: { HorizontalBarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
|
||||||
|
|
||||||
|
vm.$destroy()
|
||||||
|
|
||||||
|
vm.$nextTick(() => {
|
||||||
|
vm.$forceUpdate()
|
||||||
|
expect(vm.$children[0]._chart.chart.ctx).to.be.null
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
12
yarn.lock
12
yarn.lock
@@ -5638,9 +5638,9 @@ vue-style-loader@^2.0.0, vue-style-loader@^2.0.3:
|
|||||||
hash-sum "^1.0.2"
|
hash-sum "^1.0.2"
|
||||||
loader-utils "^1.0.2"
|
loader-utils "^1.0.2"
|
||||||
|
|
||||||
vue-template-compiler@^2.2.1:
|
vue-template-compiler@^2.2.4:
|
||||||
version "2.2.1"
|
version "2.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.2.1.tgz#ca5e43db50dc6e761e3c1296313de33091783511"
|
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.2.4.tgz#2856fb09f1571e9098872bf3c512d670eeeafba9"
|
||||||
dependencies:
|
dependencies:
|
||||||
de-indent "^1.0.2"
|
de-indent "^1.0.2"
|
||||||
he "^1.1.0"
|
he "^1.1.0"
|
||||||
@@ -5649,9 +5649,9 @@ vue-template-es2015-compiler@^1.2.2:
|
|||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.4.0.tgz#7b88853ca4bf8d84ae54ab9e56771de271e60198"
|
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.4.0.tgz#7b88853ca4bf8d84ae54ab9e56771de271e60198"
|
||||||
|
|
||||||
vue@^2.2.1:
|
vue@^2.2.4:
|
||||||
version "2.2.1"
|
version "2.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.2.1.tgz#ddbfd2f0caf38f374f5a36eea2e1edf25225b68e"
|
resolved "https://registry.yarnpkg.com/vue/-/vue-2.2.4.tgz#d0a3a050a80a12356d7950ae5a7b3131048209cc"
|
||||||
|
|
||||||
watchpack@^0.2.1:
|
watchpack@^0.2.1:
|
||||||
version "0.2.9"
|
version "0.2.9"
|
||||||
|
|||||||
Reference in New Issue
Block a user