mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 18:00:20 +00:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b847becdc7 | ||
|
|
64e0a60dbf | ||
|
|
1be5149bde | ||
|
|
7d256e6492 | ||
|
|
0a04114eb0 | ||
|
|
b14b107890 | ||
|
|
13ff782ec8 | ||
|
|
975a804570 | ||
|
|
3c252ce904 | ||
|
|
74cedd4ec4 | ||
|
|
d6c3f50ba8 | ||
|
|
d7003306d1 | ||
|
|
b8e7ce11de | ||
|
|
98961547f3 | ||
|
|
c11127e64f | ||
|
|
0f98800b92 | ||
|
|
8eefeeef86 | ||
|
|
d913e9c515 | ||
|
|
377ae5e27a | ||
|
|
9bcffae429 | ||
|
|
086fb1d4e9 | ||
|
|
f241613107 | ||
|
|
af373cf09d | ||
|
|
a7776f8407 | ||
|
|
776f3976ec | ||
|
|
3785e73b43 | ||
|
|
9bf6e6078d | ||
|
|
e62e8c81fb | ||
|
|
9f79fb581d | ||
|
|
45d500d401 | ||
|
|
9f02e95355 | ||
|
|
c0e93cd824 | ||
|
|
d80eace435 | ||
|
|
d9f95fd737 | ||
|
|
5d34181e8e | ||
|
|
1323791c52 | ||
|
|
5248534991 | ||
|
|
d3cb01b76c | ||
|
|
b374370706 | ||
|
|
60627650a3 | ||
|
|
92982ef2ac | ||
|
|
012b9a82bf | ||
|
|
e3f9936049 | ||
|
|
2f66dd9a44 |
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@@ -3,7 +3,7 @@ Thank you for contributing vue-chartjs!
|
|||||||
|
|
||||||
Please follow this steps:
|
Please follow this steps:
|
||||||
|
|
||||||
1. Fork it ( https://github.com/aapertureless/vue-chartjs/fork )
|
1. Fork it ( https://github.com/apertureless/vue-chartjs/fork )
|
||||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||||
4. Push to the branch (`git push origin my-new-feature`)
|
4. Push to the branch (`git push origin my-new-feature`)
|
||||||
|
|||||||
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)
|
||||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,8 +1,41 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [Unreleased](https://github.com/apertureless/vue-chartjs/tree/HEAD)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.0.3...HEAD)
|
## [v.2.1.0](https://github.com/apertureless/vue-chartjs/tree/v.2.1.0) (2016-09-23)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v1.1.3...v.2.1.0)
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.0.3...1.1.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Use Vue.util.mergeOptions to merge default options with user's options [\#5](https://github.com/apertureless/vue-chartjs/issues/5)
|
||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
@@ -19,4 +52,4 @@
|
|||||||
## [1.0.2](https://github.com/apertureless/vue-chartjs/tree/1.0.2) (2016-07-27)
|
## [1.0.2](https://github.com/apertureless/vue-chartjs/tree/1.0.2) (2016-07-27)
|
||||||
|
|
||||||
|
|
||||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -1,9 +1,18 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
### Compatibility
|
||||||
|
|
||||||
|
- v1 later
|
||||||
|
-- Vue.js 1.x
|
||||||
|
- v2 later
|
||||||
|
-- Vue.js 2.x
|
||||||
|
|
||||||
|
If you're looking for v1 check this [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.1.3)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Simply run `npm install vue-chartjs`
|
Simply run `npm install vue-chartjs`
|
||||||
@@ -26,9 +35,9 @@ Just create your own component.
|
|||||||
import { Bar } from 'vue-chartjs'
|
import { Bar } from 'vue-chartjs'
|
||||||
|
|
||||||
export default BarChart.extend({
|
export default BarChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
// Overwriting base render method with actual data.
|
// Overwriting base render method with actual data.
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -58,8 +67,8 @@ import { Line } from 'vue-chartjs'
|
|||||||
|
|
||||||
export default LineChart.extend({
|
export default LineChart.extend({
|
||||||
props: [data, options],
|
props: [data, options],
|
||||||
ready () {
|
mounted () {
|
||||||
this.render(this.data, this.options)
|
this.renderChart(this.data, this.options)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -107,17 +116,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
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ For detailed explanation on how things work, checkout the [guide](http://vuejs-t
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork it ( https://github.com/aapertureless/vue-chartjs/fork )
|
1. Fork it ( https://github.com/apertureless/vue-chartjs/fork )
|
||||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||||
4. Push to the branch (`git push origin my-new-feature`)
|
4. Push to the branch (`git push origin my-new-feature`)
|
||||||
|
|||||||
BIN
assets/bubble.png
Normal file
BIN
assets/bubble.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
@@ -16,6 +16,7 @@ module.exports = {
|
|||||||
extensions: ['', '.js', '.vue'],
|
extensions: ['', '.js', '.vue'],
|
||||||
fallback: [path.join(__dirname, '../node_modules')],
|
fallback: [path.join(__dirname, '../node_modules')],
|
||||||
alias: {
|
alias: {
|
||||||
|
'vue': 'vue/dist/vue.js',
|
||||||
'src': path.resolve(__dirname, '../src'),
|
'src': path.resolve(__dirname, '../src'),
|
||||||
'BaseCharts': path.resolve(__dirname, '../src/BaseCharts')
|
'BaseCharts': path.resolve(__dirname, '../src/BaseCharts')
|
||||||
}
|
}
|
||||||
|
|||||||
37
dist/vue-chartjs.js
vendored
37
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
@@ -5,7 +5,9 @@
|
|||||||
<title>Vue-ChartJs</title>
|
<title>Vue-ChartJs</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="app">
|
||||||
<app></app>
|
<app></app>
|
||||||
|
</div>
|
||||||
<!-- built files will be auto injected -->
|
<!-- built files will be auto injected -->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
25
package.json
25
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-chartjs",
|
"name": "vue-chartjs",
|
||||||
"version": "1.1.0",
|
"version": "2.1.1",
|
||||||
"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,18 +20,19 @@
|
|||||||
"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 test/e2e/specs",
|
||||||
|
"prepublish": "node build/build.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-runtime": "^6.0.0",
|
"babel-runtime": "^6.11.6",
|
||||||
"chart.js": "^2.1.6",
|
"chart.js": "^2.2.1",
|
||||||
"vue": "^1.0.21"
|
"vue": "^2.0.0-rc.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^6.0.0",
|
"babel-core": "^6.10.4",
|
||||||
"babel-loader": "^6.0.0",
|
"babel-loader": "^6.0.0",
|
||||||
"babel-plugin-transform-runtime": "^6.0.0",
|
"babel-plugin-transform-runtime": "^6.12.0",
|
||||||
"babel-preset-es2015": "^6.0.0",
|
"babel-preset-es2015": "^6.0.0",
|
||||||
"babel-preset-stage-2": "^6.0.0",
|
"babel-preset-stage-2": "^6.0.0",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
@@ -75,11 +76,11 @@
|
|||||||
"sinon": "^1.17.3",
|
"sinon": "^1.17.3",
|
||||||
"sinon-chai": "^2.8.0",
|
"sinon-chai": "^2.8.0",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
"vue-hot-reload-api": "^1.2.0",
|
"vue-hot-reload-api": "^2.0.6",
|
||||||
"vue-html-loader": "^1.0.0",
|
"vue-html-loader": "^1.2.3",
|
||||||
"vue-loader": "^8.3.0",
|
"vue-loader": "^9.3.0",
|
||||||
"vue-style-loader": "^1.0.0",
|
"vue-style-loader": "^1.0.0",
|
||||||
"webpack": "^1.12.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",
|
||||||
"webpack-merge": "^0.8.3"
|
"webpack-merge": "^0.8.3"
|
||||||
|
|||||||
@@ -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" ref="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'bar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
@@ -45,11 +49,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
render (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$els.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
68
src/BaseCharts/Bubble.js
Normal file
68
src/BaseCharts/Bubble.js
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
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" ref="canvas"></canvas>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'bubble-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) {
|
||||||
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
|
this._chart = new Chart(
|
||||||
|
this.$refs.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" ref="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'doughnut-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
@@ -28,11 +32,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
render (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$els.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
@@ -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" ref="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'line-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
@@ -43,11 +47,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
render (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$els.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
@@ -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" ref="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'pie-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
@@ -28,11 +32,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
render (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$els.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
@@ -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" ref="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'polar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
@@ -28,11 +32,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
render (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$els.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'polarArea',
|
type: 'polarArea',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
@@ -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" ref="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
chartId: {
|
||||||
|
default: 'radar-chart',
|
||||||
|
type: String
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
default: 400,
|
default: 400,
|
||||||
type: Number
|
type: Number
|
||||||
@@ -28,11 +32,11 @@ export default Vue.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
render (data, options) {
|
renderChart (data, options) {
|
||||||
let chartOptions = mergeOptions(this.defaultOptions, options)
|
let chartOptions = mergeOptions(this.defaultOptions, options)
|
||||||
|
|
||||||
this._chart = new Chart(
|
this._chart = new Chart(
|
||||||
this.$els.canvas.getContext('2d'), {
|
this.$refs.canvas.getContext('2d'), {
|
||||||
type: 'radar',
|
type: 'radar',
|
||||||
data: data,
|
data: data,
|
||||||
options: chartOptions
|
options: chartOptions
|
||||||
|
|||||||
@@ -6,19 +6,21 @@
|
|||||||
<pie-example></pie-example>
|
<pie-example></pie-example>
|
||||||
<radar-example></radar-example>
|
<radar-example></radar-example>
|
||||||
<polar-area-example></polar-area-example>
|
<polar-area-example></polar-area-example>
|
||||||
|
<bubble-example></bubble-example>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import BarExample from './examples/BarExample'
|
import BarExample from './BarExample'
|
||||||
import LineExample from './examples/LineExample'
|
import LineExample from './LineExample'
|
||||||
import DoughnutExample from './examples/DoughnutExample'
|
import DoughnutExample from './DoughnutExample'
|
||||||
import PieExample from './examples/PieExample'
|
import PieExample from './PieExample'
|
||||||
import RadarExample from './examples/RadarExample'
|
import RadarExample from './RadarExample'
|
||||||
import PolarAreaExample from './examples/PolarAreaExample'
|
import PolarAreaExample from './PolarAreaExample'
|
||||||
|
import BubbleExample from './BubbleExample'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { BarExample, LineExample, DoughnutExample, PieExample, RadarExample, PolarAreaExample }
|
components: { BarExample, LineExample, DoughnutExample, PieExample, RadarExample, PolarAreaExample, BubbleExample }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import BarChart from '../BaseCharts/Bar'
|
import BarChart from '../BaseCharts/Bar'
|
||||||
|
|
||||||
export default BarChart.extend({
|
export default BarChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -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({
|
||||||
|
mounted () {
|
||||||
|
this.renderChart({
|
||||||
|
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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import DoughnutChart from '../BaseCharts/Doughnut'
|
import DoughnutChart from '../BaseCharts/Doughnut'
|
||||||
|
|
||||||
export default DoughnutChart.extend({
|
export default DoughnutChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
|
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import LineChart from '../BaseCharts/Line'
|
import LineChart from '../BaseCharts/Line'
|
||||||
|
|
||||||
export default LineChart.extend({
|
export default LineChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import PieChart from '../BaseCharts/Pie'
|
import PieChart from '../BaseCharts/Pie'
|
||||||
|
|
||||||
export default PieChart.extend({
|
export default PieChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
|
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import PolarAreaChart from '../BaseCharts/PolarArea'
|
import PolarAreaChart from '../BaseCharts/PolarArea'
|
||||||
|
|
||||||
export default PolarAreaChart.extend({
|
export default PolarAreaChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
|
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import RadarChart from '../BaseCharts/Radar'
|
import RadarChart from '../BaseCharts/Radar'
|
||||||
|
|
||||||
export default RadarChart.extend({
|
export default RadarChart.extend({
|
||||||
ready () {
|
mounted () {
|
||||||
this.render({
|
this.renderChart({
|
||||||
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
|
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
@@ -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
|
||||||
|
|||||||
31
test/unit/specs/Bar.spec.js
Normal file
31
test/unit/specs/Bar.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import BarChart from 'src/examples/BarExample'
|
||||||
|
|
||||||
|
describe('BarChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<bar-chart></bar-chart>',
|
||||||
|
components: { BarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<bar-chart chartId="barchartprop"></bar-chart>',
|
||||||
|
components: { BarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#barchartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
31
test/unit/specs/Bubble.spec.js
Normal file
31
test/unit/specs/Bubble.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import BubbleChart from 'src/examples/BubbleExample'
|
||||||
|
|
||||||
|
describe('BubbleChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<bubble-chart></bubble-chart>',
|
||||||
|
components: { BubbleChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<bubble-chart chartId="bubblechartprop"></bubble-chart>',
|
||||||
|
components: { BubbleChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#bubblechartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
31
test/unit/specs/Doughnut.spec.js
Normal file
31
test/unit/specs/Doughnut.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import DoughnutChart from 'src/examples/DoughnutExample'
|
||||||
|
|
||||||
|
describe('DoughnutChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<doughnut-chart></doughnut-chart>',
|
||||||
|
components: { DoughnutChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<doughnut-chart chartId="doughnutchartprop"></doughnut-chart>',
|
||||||
|
components: { DoughnutChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#doughnutchartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -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!')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
31
test/unit/specs/Line.spec.js
Normal file
31
test/unit/specs/Line.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import LineChart from 'src/examples/LineExample'
|
||||||
|
|
||||||
|
describe('LineChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<line-chart></line-chart>',
|
||||||
|
components: { LineChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<line-chart chartId="linechartprop"></line-chart>',
|
||||||
|
components: { LineChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#linechartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
31
test/unit/specs/Pie.spec.js
Normal file
31
test/unit/specs/Pie.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import PieChart from 'src/examples/PieExample'
|
||||||
|
|
||||||
|
describe('PieChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<pie-chart></pie-chart>',
|
||||||
|
components: { PieChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<pie-chart chartId="piechartprop"></pie-chart>',
|
||||||
|
components: { PieChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#piechartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
31
test/unit/specs/PolarArea.spec.js
Normal file
31
test/unit/specs/PolarArea.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import PolarChart from 'src/examples/PolarAreaExample'
|
||||||
|
|
||||||
|
describe('PolarChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<polar-chart></polar-chart>',
|
||||||
|
components: { PolarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<polar-chart chartId="polarchartprop"></polar-chart>',
|
||||||
|
components: { PolarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#polarchartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
31
test/unit/specs/Radar.spec.js
Normal file
31
test/unit/specs/Radar.spec.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import RadarChart from 'src/examples/RadarExample'
|
||||||
|
|
||||||
|
describe('RadarChart', () => {
|
||||||
|
let el
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
el = document.createElement('div')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render a canvas', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<radar-chart></radar-chart>',
|
||||||
|
components: { RadarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should change id based on prop', () => {
|
||||||
|
const vm = new Vue({
|
||||||
|
template: '<radar-chart chartId="rodarchartprop"></radar-chart>',
|
||||||
|
components: { RadarChart }
|
||||||
|
}).$mount(el)
|
||||||
|
|
||||||
|
expect(vm.$el.querySelector('#rodarchartprop')).not.to.be.an('undefined')
|
||||||
|
})
|
||||||
|
})
|
||||||
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