Compare commits

..

85 Commits

Author SHA1 Message Date
Jakub Juszczak
d980e32116 💎 Release new version 2.2.1
Updated dependencies

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-12-07 08:23:50 +01:00
Jakub Juszczak
6732907fc5 Merged branch master into develop 2016-12-07 08:16:55 +01:00
Jakub
d2f23156cc Merge pull request #16 from Ag47/master
Update README.md
2016-11-07 10:05:21 +01:00
SILVER PANG
4d02df581f Update README.md
fix the syntax error of the example
2016-11-07 15:37:07 +08:00
Jakub Juszczak
1d6e375e05 🐛 📝 Update CHANGELOG 2016-10-24 11:36:18 +02:00
Jakub Juszczak
c827562839 📝 Update CHANGELOG 2016-10-24 11:34:15 +02:00
Jakub Juszczak
720d75b56b 💎 Release new version 2.2.0 2016-10-24 11:33:36 +02:00
Jakub
75925f0d5c Merge pull request #14 from wahaha2012/feature-horizontal-bar
add horizontal bar parameter
2016-10-23 19:20:17 +02:00
wxwdesign
ddb47ff63a add horizontal bar parameter 2016-10-22 21:17:21 +08:00
Jakub
2df29e1cf1 Merge pull request #11 from apertureless/feature/reactive_chart_data
WIP Feature/reactive chart data #11
2016-10-15 13:37:58 +02:00
Jakub Juszczak
6f77de832e 🐛 Fix missing export 2016-10-15 13:00:24 +02:00
Jakub Juszczak
f94b320dfa Change reactiveDataMixin 2016-10-15 12:58:51 +02:00
Jakub Juszczak
4ec6fa4cae Add codecov yml 2016-10-09 17:17:06 +02:00
Jakub Juszczak
ecdb98c4c8 🐛 Fix paths 2016-10-02 18:30:48 +02:00
Jakub Juszczak
c21cf2f3ac Add export for mixins 2016-10-02 18:26:38 +02:00
Jakub Juszczak
ef9fbe472a 📝 Update README with reactive Data and props example 2016-10-02 18:26:06 +02:00
Jakub Juszczak
06c3148897 ⬆️ Update examples 2016-10-02 18:25:02 +02:00
Jakub Juszczak
e716482154 Add reactiveProperty mixin 2016-10-02 18:10:44 +02:00
Jakub Juszczak
59cc74a00d Add reactiveData Example 2016-10-02 10:34:06 +02:00
Jakub Juszczak
a7194b990f Add reactive Data example 2016-10-02 10:32:30 +02:00
Jakub Juszczak
45e543b636 Add reactiveData mixin 2016-10-02 10:31:14 +02:00
Jakub Juszczak
ae93b96b9c ⬆️ Update dependencies 2016-10-02 09:40:12 +02:00
Jakub Juszczak
b3faeb4f2b 📝 Update Changelog 2016-10-02 09:34:45 +02:00
Jakub Juszczak
42f552a1f2 📝 Update README 2016-10-02 09:29:28 +02:00
Jakub Juszczak
b847becdc7 💎 Release new version 2.1.1 2016-10-02 09:26:08 +02:00
Jakub Juszczak
64e0a60dbf ⬆️ Update Readme 2016-10-02 09:19:05 +02:00
Jakub Juszczak
1be5149bde Merge branch 'next' into develop
* next:
  📝 Update CHANGELOG
  💎 Release new version 2.1.0
   Add travis config
  🐛 Fix tests
   Add chartId as prop and fix width and height props
   Add bubble-chart example
   Add tests
   Add chart type Bubble
  Move examples into src for better testing
  📝 Update README
  💎 Release new version 2.0.0-alpha
  Add vue 2.0 build files
  📝 Update README
  ⬆️ Update dependency chartjs to 2.2.1
  Update examples
  ⬆️ Update dependency vue 2.0
  Change deprecated v-el to ref
  Change render() method name to renderChart

# Conflicts:
#	CHANGELOG.md
#	dist/vue-chartjs.js
#	dist/vue-chartjs.js.map
#	package.json
#	src/BaseCharts/Bar.js
#	src/BaseCharts/Bubble.js
#	src/BaseCharts/Doughnut.js
#	src/BaseCharts/Line.js
#	src/BaseCharts/Pie.js
#	src/BaseCharts/PolarArea.js
#	src/BaseCharts/Radar.js
#	src/examples/App.vue
#	src/examples/BubbleExample.js
#	test/unit/specs/Bar.spec.js
#	test/unit/specs/Bubble.spec.js
#	test/unit/specs/Doughnut.spec.js
#	test/unit/specs/Line.spec.js
#	test/unit/specs/Pie.spec.js
#	test/unit/specs/PolarArea.spec.js
#	test/unit/specs/Radar.spec.js
2016-10-02 09:16:45 +02:00
Jakub Juszczak
7d256e6492 📝 Update CHANGELOG
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-23 15:14:56 +02:00
Jakub Juszczak
0a04114eb0 💎 Release new version 2.1.0
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-23 15:03:59 +02:00
Jakub Juszczak
b14b107890 Add travis config
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-23 14:55:16 +02:00
Jakub Juszczak
13ff782ec8 🐛 Fix tests
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-23 14:52:37 +02:00
Jakub Juszczak
975a804570 Add chartId as prop and fix width and height props
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-23 13:29:03 +02:00
Jakub Juszczak
3c252ce904 Add bubble-chart example
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-23 13:28:38 +02:00
Jakub Juszczak
74cedd4ec4 Add tests 2016-09-23 12:59:17 +02:00
Jakub Juszczak
d6c3f50ba8 Add chart type Bubble 2016-09-23 12:59:00 +02:00
Jakub Juszczak
d7003306d1 Move examples into src for better testing 2016-09-23 12:49:09 +02:00
Jakub Juszczak
b8e7ce11de 📝 Update CHANGELOG 2016-09-08 13:40:05 +02:00
Jakub Juszczak
98961547f3 💎 Release new version 1.1.3 2016-09-08 13:39:30 +02:00
Jakub Juszczak
c11127e64f 1.1.3 2016-09-08 13:38:52 +02:00
Jakub Juszczak
0f98800b92 Add prepublish command to package.json for np 2016-09-08 13:34:05 +02:00
Jakub Juszczak
8eefeeef86 📝 Update README with badges 2016-09-08 13:30:19 +02:00
Jakub Juszczak
d913e9c515 Add unit tests and travis.yml 2016-09-08 13:21:20 +02:00
Jakub Juszczak
377ae5e27a Change example location to src folder for easier testing 2016-09-08 13:06:36 +02:00
Jakub Juszczak
9bcffae429 Add missing image for readme 2016-09-08 12:12:25 +02:00
Jakub Juszczak
086fb1d4e9 Add BubbleExample to app.vue 2016-09-08 12:12:15 +02:00
Jakub Juszczak
f241613107 Add canvas id as prop 2016-09-08 12:08:19 +02:00
Jakub Juszczak
af373cf09d 📝 Add BubbleChart Preview to README 2016-09-08 12:04:36 +02:00
Jakub Juszczak
a7776f8407 Add bubbleChart example 2016-09-08 12:03:15 +02:00
Jakub
776f3976ec Merge pull request #9 from jcalonso/feature/bubble-chart
Add bubble chart type
2016-09-08 11:49:31 +02:00
Juan Carlos Alonso
3785e73b43 Added bubble chart type 2016-09-07 22:50:18 +01:00
Jakub Juszczak
9bf6e6078d 📝 Update CHANGELOG
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:38:43 +02:00
Jakub Juszczak
e62e8c81fb Update npm version
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:30:07 +02:00
Jakub Juszczak
9f79fb581d 🔥 Remove placeholder test
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:29:56 +02:00
Jakub Juszczak
45d500d401 💎 Release new version 1.1.2
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-09-07 10:24:07 +02:00
Jakub Juszczak
9f02e95355 🐛 Fix props 2016-09-07 10:19:05 +02:00
Jakub Juszczak
c0e93cd824 📝 Update README 2016-08-23 21:11:24 +02:00
Jakub Juszczak
d80eace435 📝 Update CHANGELOG 2016-08-23 20:59:21 +02:00
Jakub Juszczak
d9f95fd737 💎 Release new version 1.1.1
Updated ChartJs
2016-08-23 20:55:04 +02:00
Jakub Juszczak
5d34181e8e 💎 Release new version 2.0.0-alpha 2016-08-23 20:43:36 +02:00
Jakub Juszczak
1323791c52 Add vue 2.0 build files 2016-08-23 20:34:41 +02:00
Jakub Juszczak
5248534991 📝 Update README
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-23 20:32:47 +02:00
Jakub Juszczak
d3cb01b76c ⬆️ Update dependency chartjs to 2.2.1
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-23 20:31:19 +02:00
Jakub Juszczak
b374370706 Update examples
Change deprecated ready() method to mounted()
Change render() method to renderChart() method

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-23 20:28:24 +02:00
Jakub Juszczak
60627650a3 ⬆️ Update dependency vue 2.0
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-23 20:26:32 +02:00
Jakub Juszczak
92982ef2ac Change deprecated v-el to ref
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-23 20:06:50 +02:00
Jakub Juszczak
012b9a82bf Change render() method name to renderChart
This way it does not conflict with the vue 2.0 render function.

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-23 20:01:38 +02:00
Jakub Juszczak
e3f9936049 📝 Update CHANGELOG to 1.1.0
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:42:16 +02:00
Jakub Juszczak
2f66dd9a44 📝 📖 🐛 Fix README and Template
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:41:59 +02:00
Jakub Juszczak
a3bed8b8b6 💎 Release new version 1.1.0
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:38:34 +02:00
Jakub Juszczak
e48f4eaeec 📝 📖 Add Github issue and contribution templates
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:38:15 +02:00
Jakub Juszczak
57f3c651ed 📝 Update README with contribution and license section
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:26:38 +02:00
Jakub Juszczak
3c5c572a86 📝 📖 Add CODE OF CONDUCT
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:24:28 +02:00
Jakub Juszczak
c677dcb55a 📝 📖 Add LICENSE
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-21 14:24:17 +02:00
Jakub Juszczak
f5005fbd67 📝 Update CHANGELOG.md 2016-08-21 14:07:40 +02:00
Jakub
5258ab1a0f Feature/merge options #5 (#6)
*  Add dependency lodash

*  Add helper function to merge chartOptions

* Change Charts to merge options

* And renamed options data to defaultOptions
2016-08-21 14:04:34 +02:00
Jakub Juszczak
df7b6ec93e 🐛 Fix npm badge
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-20 12:40:59 +02:00
Jakub Juszczak
9a8e8d6e1e 📝 Update CHANGELOG.md
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-20 12:25:02 +02:00
Jakub Juszczak
8138969058 💎 Release new version 1.0.3
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-20 12:18:48 +02:00
Jakub Juszczak
e128ee27c7 Add changelog
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-08-19 23:57:04 +02:00
Jakub
ad7cabe809 Merge pull request #3 from LinusBorg/properly_destroy_chartsjs_objects
Properly destroy chartjs objects
2016-08-19 23:27:03 +02:00
Jakub Juszczak
d1bd9ef5ee Merge branch 'master' into develop
* master:
  Update README.md
2016-08-19 23:20:55 +02:00
Thorsten
90d9d87523 correct hook name. 2016-08-19 21:35:10 +02:00
Thorsten
998b190007 save chart instance on vm instance and add destroy() hooks to properly destroy chart when component is destroyed. 2016-08-19 21:30:39 +02:00
Jakub
44eb15a89a Update README.md
Add dependency badge
2016-08-01 20:04:03 +02:00
Jakub Juszczak
4c84718f7c Add npm badge
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2016-07-27 22:07:55 +02:00
50 changed files with 6772 additions and 170 deletions

10
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,10 @@
Thank you for contributing vue-chartjs!
=========================================
Please follow this steps:
1. Fork it ( https://github.com/apertureless/vue-chartjs/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

14
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,14 @@
### Expected Behavior
### Actual Behavior
### Environment
- OS: Write here
- NPM Version: Write here

12
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,12 @@
### Fix or Enhancement?
- [ ] All tests passed
### Environment
- OS: Write here
- NPM Version: Write here

5
.travis.yml Normal file
View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "6"
after_success:
- bash <(curl -s https://codecov.io/bash)

69
CHANGELOG.md Normal file
View File

@@ -0,0 +1,69 @@
# Change Log
## [v2.2.0](https://github.com/apertureless/vue-chartjs/tree/v2.2.0) (2016-10-24)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.1.1...v2.2.0)
**Closed issues:**
- question:syntax with vue-loader [\#12](https://github.com/apertureless/vue-chartjs/issues/12)
- Rerender when data has changed [\#10](https://github.com/apertureless/vue-chartjs/issues/10)
**Merged pull requests:**
- add horizontal bar parameter [\#14](https://github.com/apertureless/vue-chartjs/pull/14) ([wahaha2012](https://github.com/wahaha2012))
- WIP Feature/reactive chart data \#11 [\#11](https://github.com/apertureless/vue-chartjs/pull/11) ([apertureless](https://github.com/apertureless))
## [v2.1.1](https://github.com/apertureless/vue-chartjs/tree/v2.1.1) (2016-10-02)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v.2.1.0...v2.1.1)
## [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:**
- Feature/merge options \#5 [\#6](https://github.com/apertureless/vue-chartjs/pull/6) ([apertureless](https://github.com/apertureless))
## [1.0.3](https://github.com/apertureless/vue-chartjs/tree/1.0.3) (2016-08-20)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/1.0.2...1.0.3)
**Implemented enhancements:**
- Publish on NPM [\#2](https://github.com/apertureless/vue-chartjs/issues/2)
- Properly destroy chartjs objects [\#3](https://github.com/apertureless/vue-chartjs/pull/3) ([LinusBorg](https://github.com/LinusBorg))
## [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)*

13
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,13 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)

21
LICENSE.txt Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Jakub Juszczak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,7 +1,20 @@
# Vue-ChartJs
[![npm version](https://badge.fury.io/js/vue-chartjs.svg)](https://badge.fury.io/js/vue-chartjs) ![npm dependencies](https://david-dm.org/apertureless/vue-chartjs.svg) [![codecov](https://codecov.io/gh/apertureless/vue-chartjs/branch/master/graph/badge.svg)](https://codecov.io/gh/apertureless/vue-chartjs) [![Build Status](https://travis-ci.org/apertureless/vue-chartjs.svg?branch=master)](https://travis-ci.org/apertureless/vue-chartjs)
> VueJS wrapper for ChartJs
### Compatibility
- v1 later
- Vue.js 1.x
- v2 later
- Vue.js 2.x
After the final release of vue.js 2, you also get the v2 per default if you install vue-chartjs over npm.
No need for the @next tag anymore. If you want the v1 you need to define the version.
If you're looking for v1 check this [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.1.3)
## Install
Simply run `npm install vue-chartjs`
@@ -23,10 +36,10 @@ Just create your own component.
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default BarChart.extend({
ready () {
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.render({
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
@@ -54,10 +67,10 @@ You can overwrite the default chart options. Just pass the options object as a s
// MonthlyIncome.js
import { Line } from 'vue-chartjs'
export default LineChart.extend({
props: [data, options],
ready () {
this.render(this.data, this.options)
export default Line.extend({
props: ["data", "options"],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
@@ -79,6 +92,30 @@ export default {
</script>
```
## Reactivity
Chart.js does not update or re-render the chart if new data is passed.
However you can simply implement this by your own or use one of the two mixins which are included.
- `reactiveProp`
- `reactiveData`
The mixins automatically create `chartData` as a prop or data. And add a watcher. If data has changed, the chart will update.
```javascript
// MonthlyIncome.js
import { Line, reactiveProp } from 'vue-chartjs'
export default Line.extend({
mixins: [reactiveProp],
props: ["chartData", "options"],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
## Available Charts
### Bar Chart
@@ -105,17 +142,9 @@ export default {
![Pie](assets/polar.png)
## Todo
- [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
### Bubble
![Bubble](assets/bubble.png)
## Build Setup
@@ -140,3 +169,15 @@ npm test
```
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
## Contributing
1. Fork it ( https://github.com/apertureless/vue-chartjs/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## License
This software is distributed under [MIT license](LICENSE.txt).

BIN
assets/bubble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@@ -16,6 +16,7 @@ module.exports = {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'vue': 'vue/dist/vue.js',
'src': path.resolve(__dirname, '../src'),
'BaseCharts': path.resolve(__dirname, '../src/BaseCharts')
}

34
codecov.yml Normal file
View File

@@ -0,0 +1,34 @@
codecov:
branch: master
coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
target: auto
threshold: null
branches: null
patch:
default:
target: auto
branches: null
changes:
default:
branches: null
ignore:
- "tests/*"
- "src/examples/*"
- "src/mixins/*"
comment:
layout: "header, diff, changes, sunburst, uncovered, tree"
branches: null
behavior: default

35
dist/vue-chartjs.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -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>

View File

@@ -5,7 +5,9 @@
<title>Vue-ChartJs</title>
</head>
<body>
<div id="app">
<app></app>
</div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@@ -1,6 +1,6 @@
{
"name": "vue-chartjs",
"version": "1.0.2",
"version": "2.2.0",
"description": "Vue wrapper for chart.js",
"author": "Jakub Juszczak <jakub@nextindex.de>",
"repository": {
@@ -20,67 +20,71 @@
"build": "node build/build.js",
"unit": "karma start test/unit/karma.conf.js --single-run",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
"test": "npm run unit",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
"prepublish": "node build/build.js"
},
"dependencies": {
"babel-runtime": "^6.0.0",
"chart.js": "^2.1.6",
"vue": "^1.0.21"
"babel-runtime": "^6.11.6",
"chart.js": "^2.2.1",
"vue": "^2.0.1"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-core": "^6.10.4",
"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-stage-2": "^6.0.0",
"chai": "^3.5.0",
"chromedriver": "^2.21.2",
"connect-history-api-fallback": "^1.1.0",
"css-loader": "^0.23.0",
"eslint": "^2.10.2",
"cross-spawn": "^4.0.2",
"css-loader": "^0.25.0",
"eslint": "^3.7.1",
"eslint-config-standard": "^6.2.0",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.3.0",
"eslint-plugin-html": "^1.3.0",
"eslint-config-standard": "^5.1.0",
"eslint-plugin-promise": "^1.0.8",
"eslint-plugin-standard": "^1.3.2",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-standard": "^2.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.4",
"file-loader": "^0.9.0",
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.12.0",
"http-proxy-middleware": "^0.17.2",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"jasmine-core": "^2.5.2",
"json-loader": "^0.5.4",
"karma": "^0.13.15",
"karma-coverage": "^0.5.5",
"karma-mocha": "^0.2.2",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon-chai": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.24",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^1.7.0",
"lodash": "^4.16.3",
"lolex": "^1.4.0",
"mocha": "^2.4.5",
"chai": "^3.5.0",
"mocha": "^3.1.0",
"nightwatch": "^0.9.8",
"ora": "^0.3.0",
"phantomjs-prebuilt": "^2.1.13",
"selenium-server": "^2.53.1",
"shelljs": "^0.7.4",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"phantomjs-prebuilt": "^2.1.3",
"chromedriver": "^2.21.2",
"cross-spawn": "^2.1.5",
"nightwatch": "^0.8.18",
"selenium-server": "2.53.0",
"ora": "^0.2.0",
"shelljs": "^0.6.0",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.2.0",
"vue-html-loader": "^1.0.0",
"vue-loader": "^8.3.0",
"vue-hot-reload-api": "^2.0.6",
"vue-html-loader": "^1.2.3",
"vue-loader": "^9.3.0",
"vue-style-loader": "^1.0.0",
"webpack": "^1.12.2",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0",
"webpack-merge": "^0.8.3"
"webpack-merge": "^0.14.1"
}
}

View File

@@ -1,14 +1,19 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="bar-chart" width=width height=height v-el:canvas></canvas>
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
</div>
`,
props: {
chartId: {
default: 'bar-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -21,7 +26,7 @@ export default Vue.extend({
data () {
return {
options: {
defaultOptions: {
scales: {
yAxes: [{
ticks: {
@@ -44,15 +49,20 @@ export default Vue.extend({
},
methods: {
render (data, options = this.options) {
const chart = new Chart(
this.$els.canvas.getContext('2d'), {
type: 'bar',
renderChart (data, options, type) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: type || 'bar',
data: data,
options: options
options: chartOptions
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

68
src/BaseCharts/Bubble.js Normal file
View 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()
}
})

View File

@@ -1,14 +1,19 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="doughnut-chart" width=width height=height v-el:canvas></canvas>
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
</div>
`,
props: {
chartId: {
default: 'doughnut-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -21,21 +26,26 @@ export default Vue.extend({
data () {
return {
options: {
defaultOptions: {
}
}
},
methods: {
render (data, options = this.options) {
const chart = new Chart(
this.$els.canvas.getContext('2d'), {
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'doughnut',
data: data,
options: options
options: chartOptions
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

View File

@@ -1,14 +1,19 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="line-chart" width=width height=height v-el:canvas></canvas>
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
</div>
`,
props: {
chartId: {
default: 'line-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -21,7 +26,7 @@ export default Vue.extend({
data () {
return {
options: {
defaultOptions: {
scales: {
yAxes: [{
ticks: {
@@ -42,15 +47,20 @@ export default Vue.extend({
},
methods: {
render (data, options = this.options) {
const chart = new Chart(
this.$els.canvas.getContext('2d'), {
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'line',
data: data,
options: options
options: chartOptions
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

View File

@@ -1,14 +1,19 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="pie-chart" width=width height=height v-el:canvas></canvas>
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
</div>
`,
props: {
chartId: {
default: 'pie-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -21,21 +26,26 @@ export default Vue.extend({
data () {
return {
options: {
defaultOptions: {
}
}
},
methods: {
render (data, options = this.options) {
const chart = new Chart(
this.$els.canvas.getContext('2d'), {
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'pie',
data: data,
options: options
options: chartOptions
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

View File

@@ -1,14 +1,19 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="polar-chart" width=width height=height v-el:canvas></canvas>
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
</div>
`,
props: {
chartId: {
default: 'polar-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -21,21 +26,26 @@ export default Vue.extend({
data () {
return {
options: {
defaultOptions: {
}
}
},
methods: {
render (data, options = this.options) {
const chart = new Chart(
this.$els.canvas.getContext('2d'), {
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'polarArea',
data: data,
options: options
options: chartOptions
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

View File

@@ -1,14 +1,19 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
template: `
<div>
<canvas id="radar-chart" width=width height=height v-el:canvas></canvas>
<canvas :id="chartId" :width="width" :height="height" ref="canvas"></canvas>
</div>
`,
props: {
chartId: {
default: 'radar-chart',
type: String
},
width: {
default: 400,
type: Number
@@ -21,21 +26,26 @@ export default Vue.extend({
data () {
return {
options: {
defaultOptions: {
}
}
},
methods: {
render (data, options = this.options) {
const chart = new Chart(
this.$els.canvas.getContext('2d'), {
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'radar',
data: data,
options: options
options: chartOptions
}
)
chart.generateLegend()
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
}
})

45
src/examples/App.vue Normal file
View File

@@ -0,0 +1,45 @@
<template>
<div class="container">
<bar-example></bar-example>
<reactive-example></reactive-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'
import ReactiveExample from './ReactiveExample'
import ReactivePropExample from './ReactivePropExample'
export default {
components: {
BarExample,
LineExample,
DoughnutExample,
PieExample,
RadarExample,
PolarAreaExample,
BubbleExample,
ReactiveExample,
ReactivePropExample
}
}
</script>
<style>
.container {
max-width: 800px;
margin: 0 auto;
}
</style>

View File

@@ -1,8 +1,8 @@
import BarChart from '../BaseCharts/Bar'
export default BarChart.extend({
ready () {
this.render({
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
@@ -11,6 +11,6 @@ export default BarChart.extend({
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
})
}, {responsive: true, maintainAspectRatio: false})
}
})

View 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
}
]
}
]
})
}
})

View File

@@ -1,8 +1,8 @@
import DoughnutChart from '../BaseCharts/Doughnut'
export default DoughnutChart.extend({
ready () {
this.render({
mounted () {
this.renderChart({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
datasets: [
{

View File

@@ -1,8 +1,8 @@
import LineChart from '../BaseCharts/Line'
export default LineChart.extend({
ready () {
this.render({
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{

View File

@@ -1,8 +1,8 @@
import PieChart from '../BaseCharts/Pie'
export default PieChart.extend({
ready () {
this.render({
mounted () {
this.renderChart({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
datasets: [
{

View File

@@ -1,8 +1,8 @@
import PolarAreaChart from '../BaseCharts/PolarArea'
export default PolarAreaChart.extend({
ready () {
this.render({
mounted () {
this.renderChart({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
datasets: [
{

View File

@@ -1,8 +1,8 @@
import RadarChart from '../BaseCharts/Radar'
export default RadarChart.extend({
ready () {
this.render({
mounted () {
this.renderChart({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
datasets: [
{

View File

@@ -0,0 +1,41 @@
import BarChart from '../BaseCharts/Bar'
import reactiveData from '../mixins/reactiveData'
export default BarChart.extend({
mixins: [reactiveData],
data () {
return {
chartData: ''
}
},
created () {
this.fillData()
},
mounted () {
this.renderChart(this.chartData)
setInterval(() => {
this.fillData()
}, 5000)
},
methods: {
fillData () {
this.chartData = {
labels: ['January' + this.getRandomInt(), 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt()]
}
]
}
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
})

View File

@@ -0,0 +1,10 @@
import BarChart from '../BaseCharts/Bar'
import reactiveData from '../mixins/reactiveProp'
export default BarChart.extend({
mixins: [reactiveData],
mounted () {
this.renderChart(this.chartData)
}
})

5
src/helpers/options.js Normal file
View File

@@ -0,0 +1,5 @@
import merge from 'lodash/fp/merge'
export function mergeOptions (obj, src) {
return merge(obj, src)
}

View File

@@ -4,6 +4,9 @@ import Line from './BaseCharts/Line'
import Pie from './BaseCharts/Pie'
import PolarArea from './BaseCharts/PolarArea'
import Radar from './BaseCharts/Radar'
import Bubble from './BaseCharts/Bubble'
import reactiveProp from './mixins/reactiveProp'
import reactiveData from './mixins/reactiveData'
const VueCharts = {
Bar,
@@ -11,7 +14,10 @@ const VueCharts = {
Line,
Pie,
PolarArea,
Radar
Radar,
Bubble,
reactiveProp,
reactiveData
}
module.exports = VueCharts

View File

@@ -0,0 +1,44 @@
module.exports = {
data () {
return {
chartData: null
}
},
watch: {
'chartData': {
handler (newData, oldData) {
if (oldData) {
let chart = this._chart
let newDataLabels = newData.datasets.map((dataset) => {
return dataset.label
})
let oldDataLabels = oldData.datasets.map((dataset) => {
return dataset.label
})
if (JSON.stringify(newDataLabels) === JSON.stringify(oldDataLabels)) {
this.forceUpdate(newData, chart)
} else {
this.forceRender()
}
}
}
}
},
methods: {
forceUpdate (newData, chart) {
newData.datasets.forEach((dataset, i) => {
chart.data.datasets[i].data = dataset.data
})
chart.data.labels = newData.labels
chart.update()
},
forceRender () {
this.renderChart(this.chartData, this.options)
}
}
}

View File

@@ -0,0 +1,35 @@
module.exports = {
props: {
chartData: {
required: true
}
},
watch: {
'chartData': {
handler (newData, oldData) {
if (oldData) {
let chart = this._chart
let newDataLabels = newData.datasets.map((dataset) => {
return dataset.label
})
let oldDataLabels = oldData.datasets.map((dataset) => {
return dataset.label
})
if (JSON.stringify(newDataLabels) === JSON.stringify(oldDataLabels)) {
newData.datasets.forEach((dataset, i) => {
chart.data.datasets[i].data = dataset.data
})
chart.data.labels = newData.labels
chart.update()
} else {
this.renderChart(this.chartData, this.options)
}
}
}
}
}
}

View File

@@ -4,6 +4,7 @@
},
"globals": {
"expect": true,
"jasmine": true,
"sinon": true
}
}

View File

@@ -54,7 +54,7 @@ module.exports = function (config) {
// http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below.
browsers: ['PhantomJS'],
frameworks: ['mocha', 'sinon-chai'],
frameworks: ['mocha', 'sinon-chai', 'jasmine'],
reporters: ['spec', 'coverage'],
files: ['./index.js'],
preprocessors: {

View 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')
})
})

View 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')
})
})

View 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')
})
})

View File

@@ -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!')
})
})

View 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')
})
})

View 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')
})
})

View 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')
})
})

View 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')
})
})

View 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')
})
})

View File

5803
yarn.lock Normal file

File diff suppressed because it is too large Load Diff