mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
Compare commits
21 Commits
1.1.1
...
release/1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88d2771175 | ||
|
|
b8e7ce11de | ||
|
|
98961547f3 | ||
|
|
c11127e64f | ||
|
|
0f98800b92 | ||
|
|
8eefeeef86 | ||
|
|
d913e9c515 | ||
|
|
377ae5e27a | ||
|
|
9bcffae429 | ||
|
|
086fb1d4e9 | ||
|
|
f241613107 | ||
|
|
af373cf09d | ||
|
|
a7776f8407 | ||
|
|
776f3976ec | ||
|
|
3785e73b43 | ||
|
|
9bf6e6078d | ||
|
|
e62e8c81fb | ||
|
|
9f79fb581d | ||
|
|
45d500d401 | ||
|
|
9f02e95355 | ||
|
|
d80eace435 |
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "6"
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,5 +1,30 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [v1.1.3](https://github.com/apertureless/vue-chartjs/tree/v1.1.3) (2016-09-08)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.1.2...v1.1.3)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Add test [\#1](https://github.com/apertureless/vue-chartjs/issues/1)
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- Passing chart size \(width / height\) as prop doesnt resize the chart [\#8](https://github.com/apertureless/vue-chartjs/issues/8)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Added bubble chart type [\#9](https://github.com/apertureless/vue-chartjs/pull/9) ([jcalonso](https://github.com/jcalonso))
|
||||||
|
|
||||||
|
## [1.1.2](https://github.com/apertureless/vue-chartjs/tree/1.1.2) (2016-09-07)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.1.1...1.1.2)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Change name of the render method to ensure compatiblity with Vue 2.0 [\#4](https://github.com/apertureless/vue-chartjs/issues/4)
|
||||||
|
|
||||||
|
## [1.1.1](https://github.com/apertureless/vue-chartjs/tree/1.1.1) (2016-08-23)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.1.0...1.1.1)
|
||||||
|
|
||||||
## [1.1.0](https://github.com/apertureless/vue-chartjs/tree/1.1.0) (2016-08-21)
|
## [1.1.0](https://github.com/apertureless/vue-chartjs/tree/1.1.0) (2016-08-21)
|
||||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.0.3...1.1.0)
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.0.3...1.1.0)
|
||||||
|
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -1,12 +1,12 @@
|
|||||||
# Vue-ChartJs
|
# Vue-ChartJs
|
||||||
|
|
||||||
[](https://badge.fury.io/js/vue-chartjs) 
|
[](https://badge.fury.io/js/vue-chartjs)  [](https://codecov.io/gh/apertureless/vue-chartjs) [](https://travis-ci.org/apertureless/vue-chartjs)
|
||||||
|
|
||||||
> VueJS wrapper for ChartJs
|
> VueJS wrapper for ChartJs
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Simply run `npm install vue-chartjs`
|
Simply run `npm install vue-chartjs@1.1.3`
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
@@ -107,17 +107,9 @@ export default {
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Todo
|
### Bubble
|
||||||
|
|
||||||
- [x] ~~Implement Bar Chart~~
|
|
||||||
- [x] ~~Implement Line Chart~~
|
|
||||||
- [x] ~~Implement Radar Chart~~
|
|
||||||
- [x] ~~Implement Polar Area Chart~~
|
|
||||||
- [x] ~~Implement Pie Chart~~
|
|
||||||
- [x] ~~Implement Doughnut Chart~~
|
|
||||||
- [x] ~~Make npm module~~
|
|
||||||
- [ ] Add tests
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Build Setup
|
## Build Setup
|
||||||
|
|
||||||
|
|||||||
BIN
assets/bubble.png
Normal file
BIN
assets/bubble.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
32
dist/vue-chartjs.js
vendored
32
dist/vue-chartjs.js
vendored
File diff suppressed because one or more lines are too long
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
@@ -1,30 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<bar-example></bar-example>
|
|
||||||
<line-example></line-example>
|
|
||||||
<doughnut-example></doughnut-example>
|
|
||||||
<pie-example></pie-example>
|
|
||||||
<radar-example></radar-example>
|
|
||||||
<polar-area-example></polar-area-example>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import BarExample from './examples/BarExample'
|
|
||||||
import LineExample from './examples/LineExample'
|
|
||||||
import DoughnutExample from './examples/DoughnutExample'
|
|
||||||
import PieExample from './examples/PieExample'
|
|
||||||
import RadarExample from './examples/RadarExample'
|
|
||||||
import PolarAreaExample from './examples/PolarAreaExample'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: { BarExample, LineExample, DoughnutExample, PieExample, RadarExample, PolarAreaExample }
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.container {
|
|
||||||
max-width: 800px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-chartjs",
|
"name": "vue-chartjs",
|
||||||
"version": "1.1.1",
|
"version": "1.1.3",
|
||||||
"description": "Vue wrapper for chart.js",
|
"description": "Vue wrapper for chart.js",
|
||||||
"author": "Jakub Juszczak <jakub@nextindex.de>",
|
"author": "Jakub Juszczak <jakub@nextindex.de>",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -20,8 +20,9 @@
|
|||||||
"build": "node build/build.js",
|
"build": "node build/build.js",
|
||||||
"unit": "karma start test/unit/karma.conf.js --single-run",
|
"unit": "karma start test/unit/karma.conf.js --single-run",
|
||||||
"e2e": "node test/e2e/runner.js",
|
"e2e": "node test/e2e/runner.js",
|
||||||
"test": "npm run unit && npm run e2e",
|
"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",
|
||||||
|
"prepublish": "node build/build.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-runtime": "^6.0.0",
|
"babel-runtime": "^6.0.0",
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<canvas id="bar-chart" width=width height=height v-el:canvas></canvas>
|
<canvas id="{{chartId}}" width="{{width}}" height="{{height}}" v-el:canvas></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'bar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
|
|||||||
51
src/BaseCharts/Bubble.js
Normal file
51
src/BaseCharts/Bubble.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import Chart from 'chart.js'
|
||||||
|
import { mergeOptions } from '../helpers/options'
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
|
template: `
|
||||||
|
<div>
|
||||||
|
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'bubble-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
default: 400,
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
default: 400,
|
||||||
|
type: Number
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
defaultOptions: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
render (data, options) {
|
||||||
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
|
this._chart = new Chart(
|
||||||
|
this.$els.canvas.getContext('2d'), {
|
||||||
|
type: 'bubble',
|
||||||
|
data: data,
|
||||||
|
options: chartOptions
|
||||||
|
}
|
||||||
|
)
|
||||||
|
this._chart.generateLegend()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
this._chart.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<canvas id="doughnut-chart" width=width height=height v-el:canvas></canvas>
|
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'doughnut-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<canvas id="line-chart" width=width height=height v-el:canvas></canvas>
|
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'line-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<canvas id="pie-chart" width=width height=height v-el:canvas></canvas>
|
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'pie-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<canvas id="polar-chart" width=width height=height v-el:canvas></canvas>
|
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'polar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
|
|||||||
@@ -5,11 +5,15 @@ import { mergeOptions } from '../helpers/options'
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<canvas id="radar-chart" width=width height=height v-el:canvas></canvas>
|
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'radar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
|
|||||||
40
src/examples/App.vue
Normal file
40
src/examples/App.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
<bar-example></bar-example>
|
||||||
|
<line-example></line-example>
|
||||||
|
<doughnut-example></doughnut-example>
|
||||||
|
<pie-example></pie-example>
|
||||||
|
<radar-example></radar-example>
|
||||||
|
<polar-area-example></polar-area-example>
|
||||||
|
<bubble-example></bubble-example>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import BarExample from './BarExample'
|
||||||
|
import LineExample from './LineExample'
|
||||||
|
import DoughnutExample from './DoughnutExample'
|
||||||
|
import PieExample from './PieExample'
|
||||||
|
import RadarExample from './RadarExample'
|
||||||
|
import PolarAreaExample from './PolarAreaExample'
|
||||||
|
import BubbleExample from './BubbleExample'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
BarExample,
|
||||||
|
LineExample,
|
||||||
|
DoughnutExample,
|
||||||
|
PieExample,
|
||||||
|
RadarExample,
|
||||||
|
PolarAreaExample,
|
||||||
|
BubbleExample
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -11,6 +11,6 @@ export default BarChart.extend({
|
|||||||
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
|
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
}, {responsive: true, maintainAspectRatio: false})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
52
src/examples/BubbleExample.js
Normal file
52
src/examples/BubbleExample.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import BubbleChart from '../BaseCharts/Bubble'
|
||||||
|
|
||||||
|
export default BubbleChart.extend({
|
||||||
|
ready () {
|
||||||
|
this.render({
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: 'Data One',
|
||||||
|
backgroundColor: '#f87979',
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
x: 20,
|
||||||
|
y: 25,
|
||||||
|
r: 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: 40,
|
||||||
|
y: 10,
|
||||||
|
r: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: 30,
|
||||||
|
y: 22,
|
||||||
|
r: 30
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Data Two',
|
||||||
|
backgroundColor: '#7C8CF8',
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
x: 10,
|
||||||
|
y: 30,
|
||||||
|
r: 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: 20,
|
||||||
|
y: 20,
|
||||||
|
r: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: 15,
|
||||||
|
y: 8,
|
||||||
|
r: 30
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -4,6 +4,7 @@ import Line from './BaseCharts/Line'
|
|||||||
import Pie from './BaseCharts/Pie'
|
import Pie from './BaseCharts/Pie'
|
||||||
import PolarArea from './BaseCharts/PolarArea'
|
import PolarArea from './BaseCharts/PolarArea'
|
||||||
import Radar from './BaseCharts/Radar'
|
import Radar from './BaseCharts/Radar'
|
||||||
|
import Bubble from './BaseCharts/Bubble'
|
||||||
|
|
||||||
const VueCharts = {
|
const VueCharts = {
|
||||||
Bar,
|
Bar,
|
||||||
@@ -11,7 +12,8 @@ const VueCharts = {
|
|||||||
Line,
|
Line,
|
||||||
Pie,
|
Pie,
|
||||||
PolarArea,
|
PolarArea,
|
||||||
Radar
|
Radar,
|
||||||
|
Bubble
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = VueCharts
|
module.exports = VueCharts
|
||||||
|
|||||||
17
test/unit/specs/Bar.spec.js
Normal file
17
test/unit/specs/Bar.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import BarChart from 'src/examples/BarExample'
|
||||||
|
|
||||||
|
describe('BarChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<bar-chart></bar-chart>',
|
||||||
|
components: { BarChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#bar-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
|
||||||
|
})
|
||||||
|
})
|
||||||
17
test/unit/specs/Bubble.spec.js
Normal file
17
test/unit/specs/Bubble.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import BubbleChart from 'src/examples/BubbleExample'
|
||||||
|
|
||||||
|
describe('BubbleChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<bubble-chart></bubble-chart>',
|
||||||
|
components: { BubbleChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#bubble-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
|
||||||
|
})
|
||||||
|
})
|
||||||
17
test/unit/specs/Doughnut.spec.js
Normal file
17
test/unit/specs/Doughnut.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import DoughnutChart from 'src/examples/DoughnutExample'
|
||||||
|
|
||||||
|
describe('DoughnutChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<doughnut-chart></doughnut-chart>',
|
||||||
|
components: { DoughnutChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#doughnut-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
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import Vue from 'vue'
|
|
||||||
import Hello from 'src/components/Hello'
|
|
||||||
|
|
||||||
describe('Hello.vue', () => {
|
|
||||||
it('should render correct contents', () => {
|
|
||||||
const vm = new Vue({
|
|
||||||
template: '<div><hello></hello></div>',
|
|
||||||
components: { Hello }
|
|
||||||
}).$mount()
|
|
||||||
expect(vm.$el.querySelector('.hello h1').textContent).to.contain('Hello World!')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
17
test/unit/specs/Line.spec.js
Normal file
17
test/unit/specs/Line.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import LineChart from 'src/examples/LineExample'
|
||||||
|
|
||||||
|
describe('LineChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<line-chart></line-chart>',
|
||||||
|
components: { LineChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#line-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
|
||||||
|
})
|
||||||
|
})
|
||||||
17
test/unit/specs/Pie.spec.js
Normal file
17
test/unit/specs/Pie.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import PieChart from 'src/examples/PieExample'
|
||||||
|
|
||||||
|
describe('PieChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<pie-chart></pie-chart>',
|
||||||
|
components: { PieChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#pie-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
|
||||||
|
})
|
||||||
|
})
|
||||||
17
test/unit/specs/PolarArea.spec.js
Normal file
17
test/unit/specs/PolarArea.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import PolarChart from 'src/examples/PolarAreaExample'
|
||||||
|
|
||||||
|
describe('PolarChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<polar-chart></polar-chart>',
|
||||||
|
components: { PolarChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#polar-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
|
||||||
|
})
|
||||||
|
})
|
||||||
17
test/unit/specs/Radar.spec.js
Normal file
17
test/unit/specs/Radar.spec.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import RadarChart from 'src/examples/RadarExample'
|
||||||
|
|
||||||
|
describe('RadarChart', () => {
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
el: 'body',
|
||||||
|
replace: false,
|
||||||
|
template: '<radar-chart></radar-chart>',
|
||||||
|
components: { RadarChart }
|
||||||
|
})
|
||||||
|
expect(vm.$el.querySelector('#radar-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
|
||||||
|
})
|
||||||
|
})
|
||||||
30
test/unit/specs/helpers/options.spec.js
Normal file
30
test/unit/specs/helpers/options.spec.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { mergeOptions } from 'src/helpers/options'
|
||||||
|
|
||||||
|
describe('mergeOptions.js', () => {
|
||||||
|
const a = {
|
||||||
|
a: 'a',
|
||||||
|
b: 'a'
|
||||||
|
}
|
||||||
|
|
||||||
|
const b = {
|
||||||
|
a: 'b',
|
||||||
|
b: 'b'
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = {
|
||||||
|
c: 'c'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should replace old a and b if a and b are new', () => {
|
||||||
|
let ab = mergeOptions(a, b)
|
||||||
|
expect(ab).to.have.property('a').and.to.equal('b')
|
||||||
|
expect(ab).to.have.property('b').and.to.equal('b')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should add c if c is new', () => {
|
||||||
|
let ac = mergeOptions(a, c)
|
||||||
|
expect(ac).to.have.property('a').and.to.equal('a')
|
||||||
|
expect(ac).to.have.property('b').and.to.equal('a')
|
||||||
|
expect(ac).to.have.property('c').and.to.equal('c')
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user