Compare commits

..

11 Commits

Author SHA1 Message Date
Jakub Juszczak
4f5aa1811d 💎 Release new version 1.2.0 2017-07-25 12:56:13 +02:00
Jakub Juszczak
098c90edf1 Add scatter chart 2017-07-25 12:53:17 +02:00
Jakub Juszczak
3f15eb9abc Add dist files to ignire 2017-07-25 12:52:12 +02:00
Jakub Juszczak
68e94b7fe3 Merge branch 'release/1.x' into pr/152
* release/1.x:
  ⬆️ Update dependency chart.js to 2.6.0
  🐛 Fix dependency
  💎 Release new version 1.1.4

# Conflicts:
#	dist/vue-chartjs.js
#	dist/vue-chartjs.js.map
2017-07-25 12:49:06 +02:00
Denis Lapi
0d24270bf2 Delete vue-chartjs.js 2017-07-22 19:25:48 +02:00
Denis Lapi
e034467e5b Delete vue-chartjs.js.map 2017-07-22 19:25:39 +02:00
Jakub Juszczak
c7cb8e24e9 ⬆️ Update dependency chart.js to 2.6.0 2017-07-22 17:28:36 +02:00
DenisLapi
4c9f4fc5e5 #149 - Fix error on beforeDestroy - VueJS v1 2017-07-22 10:01:29 +02:00
Jakub Juszczak
a25d327b13 🐛 Fix dependency 2017-02-23 08:46:21 +01:00
Jakub Juszczak
f57e555d94 💎 Release new version 1.1.4
Updated chart.js dependency
2017-02-22 13:01:59 +01:00
Jakub Juszczak
88d2771175 📝 Update README 2016-10-02 09:19:41 +02:00
84 changed files with 1306 additions and 5814 deletions

View File

@@ -9,6 +9,6 @@
### Environment
- vue.js version: <version here>
- vue-chart.js version: <version here>
- npm version: <version here>
- OS: Write here
- NPM Version: Write here

View File

@@ -1,386 +1,15 @@
# Change Log
## [v2.7.2](https://github.com/apertureless/vue-chartjs/tree/v2.7.2) (2017-07-22)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.7.1...v2.7.2)
**Closed issues:**
- Accessibility - Add unique titles to frames [\#150](https://github.com/apertureless/vue-chartjs/issues/150)
- update\(\) not refreshing chart [\#148](https://github.com/apertureless/vue-chartjs/issues/148)
- Custome label y axis [\#147](https://github.com/apertureless/vue-chartjs/issues/147)
- Access specific points on the canvas and labels for styling [\#146](https://github.com/apertureless/vue-chartjs/issues/146)
- legendCallback\(\) doesn't render a custom legend [\#144](https://github.com/apertureless/vue-chartjs/issues/144)
- where can i get the demo sources code? thanks [\#143](https://github.com/apertureless/vue-chartjs/issues/143)
- Props not works as expected, updating of value doesn't work [\#138](https://github.com/apertureless/vue-chartjs/issues/138)
**Merged pull requests:**
- ⬆️ Update dependency vue to 2.4.2 [\#154](https://github.com/apertureless/vue-chartjs/pull/154) ([apertureless](https://github.com/apertureless))
- Remove useless labels [\#153](https://github.com/apertureless/vue-chartjs/pull/153) ([clarkdo](https://github.com/clarkdo))
- :pencil2: Remove generateLegend\(\) from initialization codes [\#145](https://github.com/apertureless/vue-chartjs/pull/145) ([k-rumi](https://github.com/k-rumi))
## [v2.7.1](https://github.com/apertureless/vue-chartjs/tree/v2.7.1) (2017-07-05)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.7.0...v2.7.1)
**Closed issues:**
- Default backgroundColor needed [\#142](https://github.com/apertureless/vue-chartjs/issues/142)
**Merged pull requests:**
- Fix links to images in translated documents [\#141](https://github.com/apertureless/vue-chartjs/pull/141) ([k-rumi](https://github.com/k-rumi))
## [v2.7.0](https://github.com/apertureless/vue-chartjs/tree/v2.7.0) (2017-07-04)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.5...v2.7.0)
**Closed issues:**
- Reactive Data Tutorial [\#132](https://github.com/apertureless/vue-chartjs/issues/132)
- Using inline plugins [\#130](https://github.com/apertureless/vue-chartjs/issues/130)
- Scatter Chart [\#129](https://github.com/apertureless/vue-chartjs/issues/129)
- Generating Chart after clicking submit button [\#128](https://github.com/apertureless/vue-chartjs/issues/128)
- Ticks not working with reactive props [\#127](https://github.com/apertureless/vue-chartjs/issues/127)
- Error in callback for watcher "chartData": "TypeError: Cannot read property 'data' of undefined" [\#126](https://github.com/apertureless/vue-chartjs/issues/126)
- Passing the data from vue to chartjs [\#125](https://github.com/apertureless/vue-chartjs/issues/125)
- Combination of Bar and Line Chart [\#123](https://github.com/apertureless/vue-chartjs/issues/123)
- Reactive data example not working [\#122](https://github.com/apertureless/vue-chartjs/issues/122)
- vue-chartjs height was 0 when i set v-show [\#120](https://github.com/apertureless/vue-chartjs/issues/120)
- Bar chart, barPercentage in X axis [\#119](https://github.com/apertureless/vue-chartjs/issues/119)
- update event not firing on data change [\#118](https://github.com/apertureless/vue-chartjs/issues/118)
**Merged pull requests:**
- ✅ Update tests for addPlugin method [\#140](https://github.com/apertureless/vue-chartjs/pull/140) ([apertureless](https://github.com/apertureless))
- Fix beforeDestory when renderChart was not called [\#139](https://github.com/apertureless/vue-chartjs/pull/139) ([ZhangYiJiang](https://github.com/ZhangYiJiang))
- Add support for inline plugins [\#137](https://github.com/apertureless/vue-chartjs/pull/137) ([kurbar](https://github.com/kurbar))
- Feature/scatter chart [\#136](https://github.com/apertureless/vue-chartjs/pull/136) ([apertureless](https://github.com/apertureless))
- 🐛 Fix \#122 reactive mixin [\#135](https://github.com/apertureless/vue-chartjs/pull/135) ([apertureless](https://github.com/apertureless))
- 📝 Add resources & tutorials to docs [\#133](https://github.com/apertureless/vue-chartjs/pull/133) ([apertureless](https://github.com/apertureless))
- fix a typo in an example [\#131](https://github.com/apertureless/vue-chartjs/pull/131) ([JobV](https://github.com/JobV))
- Update README [\#121](https://github.com/apertureless/vue-chartjs/pull/121) ([stoykostanchev](https://github.com/stoykostanchev))
## [v2.6.5](https://github.com/apertureless/vue-chartjs/tree/v2.6.5) (2017-06-10)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.4...v2.6.5)
## [v2.6.4](https://github.com/apertureless/vue-chartjs/tree/v2.6.4) (2017-06-04)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.3...v2.6.4)
**Closed issues:**
- Transition leave-active-class not working [\#117](https://github.com/apertureless/vue-chartjs/issues/117)
- chartOptions reactivity [\#116](https://github.com/apertureless/vue-chartjs/issues/116)
- Cannot switch off legend [\#114](https://github.com/apertureless/vue-chartjs/issues/114)
- run error on my mac pro [\#113](https://github.com/apertureless/vue-chartjs/issues/113)
- Update install instructions in docs [\#112](https://github.com/apertureless/vue-chartjs/issues/112)
- Typo in docs [\#111](https://github.com/apertureless/vue-chartjs/issues/111)
- Charts are given a fixed width, even when they are set to be responsive [\#108](https://github.com/apertureless/vue-chartjs/issues/108)
- Use Reactive Data with \<script\> version of vue-chartjs [\#107](https://github.com/apertureless/vue-chartjs/issues/107)
**Merged pull requests:**
- Fix typo in docs [\#115](https://github.com/apertureless/vue-chartjs/pull/115) ([euledge](https://github.com/euledge))
- :memo: Add pt-br readme support [\#110](https://github.com/apertureless/vue-chartjs/pull/110) ([kimuraz](https://github.com/kimuraz))
- Fix reactive mixins animation re-rendering issue. [\#109](https://github.com/apertureless/vue-chartjs/pull/109) ([MuseofMoose](https://github.com/MuseofMoose))
## [v2.6.3](https://github.com/apertureless/vue-chartjs/tree/v2.6.3) (2017-05-14)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.2...v2.6.3)
**Closed issues:**
- Reactivity of Options [\#106](https://github.com/apertureless/vue-chartjs/issues/106)
- Do not use built-in or reserved HTML elements as component id: MenuItem [\#104](https://github.com/apertureless/vue-chartjs/issues/104)
- Is it possible to use with axios? [\#103](https://github.com/apertureless/vue-chartjs/issues/103)
- How to change momentjs locale for time scale? [\#101](https://github.com/apertureless/vue-chartjs/issues/101)
- It seems that the reactiveProp couldn't let the chart update itself [\#99](https://github.com/apertureless/vue-chartjs/issues/99)
- vue-chartjs not working with lodash-webpack-plugin installed [\#97](https://github.com/apertureless/vue-chartjs/issues/97)
- multi lines with same options [\#95](https://github.com/apertureless/vue-chartjs/issues/95)
- Zoom And Pan Options in Vue Charts [\#94](https://github.com/apertureless/vue-chartjs/issues/94)
**Merged pull requests:**
- Update README.md [\#105](https://github.com/apertureless/vue-chartjs/pull/105) ([guilherfp](https://github.com/guilherfp))
- translated README.md into Japanese [\#102](https://github.com/apertureless/vue-chartjs/pull/102) ([euledge](https://github.com/euledge))
- add CDNJS version badge in README.md [\#100](https://github.com/apertureless/vue-chartjs/pull/100) ([extend1994](https://github.com/extend1994))
## [v2.6.2](https://github.com/apertureless/vue-chartjs/tree/v2.6.2) (2017-04-29)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.1...v2.6.2)
**Merged pull requests:**
- ⬆️ Update dev dependencies [\#96](https://github.com/apertureless/vue-chartjs/pull/96) ([apertureless](https://github.com/apertureless))
## [v2.6.1](https://github.com/apertureless/vue-chartjs/tree/v2.6.1) (2017-04-21)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.0...v2.6.1)
**Closed issues:**
- Not understanding options [\#93](https://github.com/apertureless/vue-chartjs/issues/93)
- A Gotcha on component creation. [\#92](https://github.com/apertureless/vue-chartjs/issues/92)
- Error when building: 'This dependency was not found: chartjs' [\#91](https://github.com/apertureless/vue-chartjs/issues/91)
- Chart does not render inside conditional [\#90](https://github.com/apertureless/vue-chartjs/issues/90)
- Unable to add to material-vue layout [\#87](https://github.com/apertureless/vue-chartjs/issues/87)
## [v2.6.0](https://github.com/apertureless/vue-chartjs/tree/v2.6.0) (2017-04-09)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.6.0-rc1...v2.6.0)
**Closed issues:**
- how to export to image or pdf [\#89](https://github.com/apertureless/vue-chartjs/issues/89)
- 🙏🏻 Testing 2.6.0-rc1 [\#88](https://github.com/apertureless/vue-chartjs/issues/88)
- Adding annotation plugin functionality [\#86](https://github.com/apertureless/vue-chartjs/issues/86)
## [v2.6.0-rc1](https://github.com/apertureless/vue-chartjs/tree/v2.6.0-rc1) (2017-04-05)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.6...v2.6.0-rc1)
**Closed issues:**
- Overwrite prop [\#85](https://github.com/apertureless/vue-chartjs/issues/85)
**Merged pull requests:**
- Update release build to not include externals. [\#84](https://github.com/apertureless/vue-chartjs/pull/84) ([gcoguiec](https://github.com/gcoguiec))
## [v2.5.6](https://github.com/apertureless/vue-chartjs/tree/v2.5.6) (2017-03-29)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.5...v2.5.6)
**Closed issues:**
- Can not render two lines at the same time [\#83](https://github.com/apertureless/vue-chartjs/issues/83)
- Suggestion: Chart not re-rendering on window resize [\#82](https://github.com/apertureless/vue-chartjs/issues/82)
- How can you change legend label colour? [\#81](https://github.com/apertureless/vue-chartjs/issues/81)
- Doughnut with text in the middle [\#80](https://github.com/apertureless/vue-chartjs/issues/80)
- Set chart width without affecting labels [\#79](https://github.com/apertureless/vue-chartjs/issues/79)
- Loading data from server and displaying [\#78](https://github.com/apertureless/vue-chartjs/issues/78)
- Why separate .js files in the examples? [\#77](https://github.com/apertureless/vue-chartjs/issues/77)
- An in-range update of vue is breaking the build 🚨 [\#76](https://github.com/apertureless/vue-chartjs/issues/76)
- An in-range update of vue-template-compiler is breaking the build 🚨 [\#75](https://github.com/apertureless/vue-chartjs/issues/75)
- Uncaught TypeError: Cannot read property 'chartId' of undefined [\#74](https://github.com/apertureless/vue-chartjs/issues/74)
- TypeError: child.\_updateFromParent is not a function [\#72](https://github.com/apertureless/vue-chartjs/issues/72)
- Styling componement's surrounding \<div\> [\#70](https://github.com/apertureless/vue-chartjs/issues/70)
## [v2.5.5](https://github.com/apertureless/vue-chartjs/tree/v2.5.5) (2017-03-24)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.4...v2.5.5)
**Closed issues:**
- Access chartjs methods [\#71](https://github.com/apertureless/vue-chartjs/issues/71)
- Pass Reactive data into Scatterplot [\#69](https://github.com/apertureless/vue-chartjs/issues/69)
**Merged pull requests:**
- Removed -s flag from yarn command in docs [\#73](https://github.com/apertureless/vue-chartjs/pull/73) ([mika76](https://github.com/mika76))
## [v2.5.4](https://github.com/apertureless/vue-chartjs/tree/v2.5.4) (2017-03-19)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.3...v2.5.4)
**Closed issues:**
- An in-range update of eslint-config-standard is breaking the build 🚨 [\#68](https://github.com/apertureless/vue-chartjs/issues/68)
- Using data from vuex to populate a line graph [\#67](https://github.com/apertureless/vue-chartjs/issues/67)
- How to use without babel/webpack? [\#66](https://github.com/apertureless/vue-chartjs/issues/66)
- The vue-chartjs/src entry point is still creating a new vue instance. [\#55](https://github.com/apertureless/vue-chartjs/issues/55)
**Merged pull requests:**
- Update dependencies to enable Greenkeeper 🌴 [\#65](https://github.com/apertureless/vue-chartjs/pull/65) ([greenkeeper[bot]](https://github.com/apps/greenkeeper))
## [v2.5.3](https://github.com/apertureless/vue-chartjs/tree/v2.5.3) (2017-03-17)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.2...v2.5.3)
**Closed issues:**
- Cannot modify styling using options [\#60](https://github.com/apertureless/vue-chartjs/issues/60)
## [v2.5.2](https://github.com/apertureless/vue-chartjs/tree/v2.5.2) (2017-03-14)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.1...v2.5.2)
**Closed issues:**
- TypeError: child.\_updateFromParent is not a function [\#62](https://github.com/apertureless/vue-chartjs/issues/62)
- child.\_updateFromParent is not a function [\#59](https://github.com/apertureless/vue-chartjs/issues/59)
- dependency was not found [\#58](https://github.com/apertureless/vue-chartjs/issues/58)
**Merged pull requests:**
- Develop [\#63](https://github.com/apertureless/vue-chartjs/pull/63) ([apertureless](https://github.com/apertureless))
- Fix typo for legacy tag [\#61](https://github.com/apertureless/vue-chartjs/pull/61) ([kylestev](https://github.com/kylestev))
## [v2.5.1](https://github.com/apertureless/vue-chartjs/tree/v2.5.1) (2017-03-11)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.5.0...v2.5.1)
**Closed issues:**
- Lines are looking weird. [\#57](https://github.com/apertureless/vue-chartjs/issues/57)
- Working with objects [\#48](https://github.com/apertureless/vue-chartjs/issues/48)
- Mixins don't seem to trigger a refresh of the chart [\#44](https://github.com/apertureless/vue-chartjs/issues/44)
## [v2.5.0](https://github.com/apertureless/vue-chartjs/tree/v2.5.0) (2017-03-08)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.4.1...v2.5.0)
**Closed issues:**
- UglifyJs is not happy with versions after 2.3.8 [\#54](https://github.com/apertureless/vue-chartjs/issues/54)
- Why "main" in Package.json is "src/index.js" and not "dist/vue-chartjs.js" [\#53](https://github.com/apertureless/vue-chartjs/issues/53)
- Adding static data and dynamic data at the same time. [\#52](https://github.com/apertureless/vue-chartjs/issues/52)
**Merged pull requests:**
- separate HorizontalBar component added [\#56](https://github.com/apertureless/vue-chartjs/pull/56) ([imbashamba](https://github.com/imbashamba))
## [v2.4.1](https://github.com/apertureless/vue-chartjs/tree/v2.4.1) (2017-03-04)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.4.0...v2.4.1)
## [v2.4.0](https://github.com/apertureless/vue-chartjs/tree/v2.4.0) (2017-03-03)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.9...v2.4.0)
**Merged pull requests:**
- Added browserify support [\#51](https://github.com/apertureless/vue-chartjs/pull/51) ([craigh411](https://github.com/craigh411))
## [v2.3.9](https://github.com/apertureless/vue-chartjs/tree/v2.3.9) (2017-03-01)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.8...v2.3.9)
**Closed issues:**
- Add src folder to package.json "files" and make main "src/index.js" [\#49](https://github.com/apertureless/vue-chartjs/issues/49)
- Unable to refresh [\#41](https://github.com/apertureless/vue-chartjs/issues/41)
**Merged pull requests:**
- 🐛 Fix \#49 [\#50](https://github.com/apertureless/vue-chartjs/pull/50) ([apertureless](https://github.com/apertureless))
## [v2.3.8](https://github.com/apertureless/vue-chartjs/tree/v2.3.8) (2017-03-01)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.6...v2.3.8)
**Closed issues:**
- Colors of dynamically added bars in bar graph are the default color instead of specified color [\#42](https://github.com/apertureless/vue-chartjs/issues/42)
**Merged pull requests:**
- Feature/documentation [\#47](https://github.com/apertureless/vue-chartjs/pull/47) ([apertureless](https://github.com/apertureless))
- ⬆️ Update dependencies [\#46](https://github.com/apertureless/vue-chartjs/pull/46) ([apertureless](https://github.com/apertureless))
- 📝 Update github issue template [\#45](https://github.com/apertureless/vue-chartjs/pull/45) ([apertureless](https://github.com/apertureless))
## [v2.3.6](https://github.com/apertureless/vue-chartjs/tree/v2.3.6) (2017-02-22)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.5...v2.3.6)
**Closed issues:**
- Please update1.1.3 chartjs to 2.5.0 [\#40](https://github.com/apertureless/vue-chartjs/issues/40)
- Vue-chartjs components creating a second Vue runtime [\#39](https://github.com/apertureless/vue-chartjs/issues/39)
- Since last update bar chart will no longer stack [\#38](https://github.com/apertureless/vue-chartjs/issues/38)
- barchart 如何横向显示条形图 [\#37](https://github.com/apertureless/vue-chartjs/issues/37)
- Animation with reactivity [\#34](https://github.com/apertureless/vue-chartjs/issues/34)
**Merged pull requests:**
- 🐛 Fix reactiveMixins issue \#42 [\#43](https://github.com/apertureless/vue-chartjs/pull/43) ([apertureless](https://github.com/apertureless))
## [v2.3.5](https://github.com/apertureless/vue-chartjs/tree/v2.3.5) (2017-02-14)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.4...v2.3.5)
**Closed issues:**
- Destory chart instance in reactiveMixins on render [\#35](https://github.com/apertureless/vue-chartjs/issues/35)
- Rerendering doughtnut chart not working [\#33](https://github.com/apertureless/vue-chartjs/issues/33)
**Merged pull requests:**
- 🔨 Change reactiveMixins to fix \#35 [\#36](https://github.com/apertureless/vue-chartjs/pull/36) ([apertureless](https://github.com/apertureless))
## [v2.3.4](https://github.com/apertureless/vue-chartjs/tree/v2.3.4) (2017-02-11)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.3...v2.3.4)
**Closed issues:**
- Update Chart.js docs to include link to vue-chartjs [\#32](https://github.com/apertureless/vue-chartjs/issues/32)
- Compatibility with Vue 2.1.10 [\#30](https://github.com/apertureless/vue-chartjs/issues/30)
## [v2.3.3](https://github.com/apertureless/vue-chartjs/tree/v2.3.3) (2017-01-19)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.2...v2.3.3)
**Closed issues:**
- How to create mixed chart types [\#29](https://github.com/apertureless/vue-chartjs/issues/29)
- hello a q about reactivity [\#28](https://github.com/apertureless/vue-chartjs/issues/28)
- chart do not render after build [\#26](https://github.com/apertureless/vue-chartjs/issues/26)
**Merged pull requests:**
- 🐛 Fix \#30 type error [\#31](https://github.com/apertureless/vue-chartjs/pull/31) ([apertureless](https://github.com/apertureless))
## [v2.3.2](https://github.com/apertureless/vue-chartjs/tree/v2.3.2) (2016-12-23)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.1...v2.3.2)
**Closed issues:**
- Content Security Policy [\#22](https://github.com/apertureless/vue-chartjs/issues/22)
**Merged pull requests:**
- ✨ Add minimal release webpack config [\#27](https://github.com/apertureless/vue-chartjs/pull/27) ([apertureless](https://github.com/apertureless))
- 📝 Update README [\#25](https://github.com/apertureless/vue-chartjs/pull/25) ([apertureless](https://github.com/apertureless))
## [v2.3.1](https://github.com/apertureless/vue-chartjs/tree/v2.3.1) (2016-12-20)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.3.0...v2.3.1)
**Closed issues:**
- Error in rendering [\#21](https://github.com/apertureless/vue-chartjs/issues/21)
- Issues after using gulp-- production [\#19](https://github.com/apertureless/vue-chartjs/issues/19)
**Merged pull requests:**
- ✅ Add tests for chart instance destroying [\#24](https://github.com/apertureless/vue-chartjs/pull/24) ([apertureless](https://github.com/apertureless))
- Feature/runtimebuild \#22 [\#23](https://github.com/apertureless/vue-chartjs/pull/23) ([apertureless](https://github.com/apertureless))
## [v2.3.0](https://github.com/apertureless/vue-chartjs/tree/v2.3.0) (2016-12-17)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.2.1...v2.3.0)
**Closed issues:**
- Uncaught TypeError: \_c is not a function [\#20](https://github.com/apertureless/vue-chartjs/issues/20)
## [v2.2.1](https://github.com/apertureless/vue-chartjs/tree/v2.2.1) (2016-12-07)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.2.0...v2.2.1)
**Closed issues:**
- Chart height definition inside the component [\#18](https://github.com/apertureless/vue-chartjs/issues/18)
- Uncaught TypeError: Cannot read property 'draw' of null [\#15](https://github.com/apertureless/vue-chartjs/issues/15)
**Merged pull requests:**
- Update README.md [\#16](https://github.com/apertureless/vue-chartjs/pull/16) ([Ag47](https://github.com/Ag47))
## [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:**
- The page is blank [\#13](https://github.com/apertureless/vue-chartjs/issues/13)
- 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)
**Closed issues:**
**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)
- Add test [\#1](https://github.com/apertureless/vue-chartjs/issues/1)
**Merged pull requests:**
@@ -389,7 +18,7 @@
## [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)
**Closed issues:**
**Implemented enhancements:**
- Change name of the render method to ensure compatiblity with Vue 2.0 [\#4](https://github.com/apertureless/vue-chartjs/issues/4)
@@ -399,7 +28,7 @@
## [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)
**Closed issues:**
**Implemented enhancements:**
- Use Vue.util.mergeOptions to merge default options with user's options [\#5](https://github.com/apertureless/vue-chartjs/issues/5)
@@ -410,12 +39,9 @@
## [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)
**Closed issues:**
**Implemented enhancements:**
- Publish on NPM [\#2](https://github.com/apertureless/vue-chartjs/issues/2)
**Merged pull requests:**
- 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)

164
README.md
View File

@@ -1,77 +1,12 @@
<div align="center">
<img width="256" heigth="256" src="/assets/vue-chartjs.png" alt="vue-chartjs logo">
</div>
# Vue-ChartJs
[![npm version](https://badge.fury.io/js/vue-chartjs.svg)](https://badge.fury.io/js/vue-chartjs)
[![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)
[![Package Quality](http://npm.packagequality.com/shield/vue-chartjs.svg)](http://packagequality.com/#?package=vue-chartjs)
[![npm](https://img.shields.io/npm/dm/vue-chartjs.svg)](https://www.npmjs.com/package/vue-chartjs)
[![Gitter chat](https://img.shields.io/gitter/room/TechnologyAdvice/Stardust.svg)](https://gitter.im/vue-chartjs/Lobby)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/apertureless/vue-chartjs/blob/master/LICENSE.txt)
[![CDNJS version](https://img.shields.io/cdnjs/v/vue-chartjs.svg)](https://cdnjs.com/libraries/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)
# vue-chartjs
**vue-chartjs** is a wrapper for [Chart.js](https://github.com/chartjs/Chart.js) in vue. You can easily create reuseable chart components.
## Demo & Docs
- 📺 [Demo](http://demo.vue-chartjs.org/)
- 📖 [Docs](http://www.vue-chartjs.org/)
### Compatibility
- v1 later `@legacy`
- Vue.js 1.x
- v2 later
- Vue.js 2.x
After the final release of vue.js 2, you also get the v2 by 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 or use the legacy tag.
If you're looking for v1 check this [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.x)
> VueJS wrapper for ChartJs
## Install
Simply run `yarn add vue-chartjs chart.js`
Or if you want to use it directly in the browser add
```html
<script src="https://unpkg.com/vue-chartjs/dist/vue-chartjs.full.min.js"></script>
```
to your scripts. See [Codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010)
## Explanation of Different Builds
There are three different entry points. It depends on which build setup do you have. The dependencies are bundled or required as a peerDependency.
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Bundled | Bundled |
| vue-chartjs.full.min.js | Bundled | Bundled |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### Browser
You can use `vue-chartjs` directly in the browser without any build setup. Like in this [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). For this case, please use the `vue-chartjs.full.min.js` which is the minified version. It has Vue.js and Chart.js bundled into it. And bundled to a UMD Module. So you only need that one file.
### Browserify / Webpack 1
If you're using Gulp, Browserify or Webpack 1 the entry is `vue-chartjs.js` which is __transpiled__ and __bundled__ UMD Module.
However Vue.js and Chart.js are `peerDependencies` so you have to install them separately. In most projects you will have `Vue.js` already installed anyways. This way, you can have different versions of Vue.js and Chart.js then in this package.
### Webpack 2
If you're using Webpack 2 it will automatically use the `jsnext:main` / `module` entry point. Which is `es/index.js`
It is a __transpiled__ es version of the source. And is not __bundled__ to a module. This way you three shaking will work. Like in the bundled version, `Vue.js` and `Chart.js` are `peerDependencies` and need to be installed.
Simply run `npm install vue-chartjs@1.1.3`
## How to use
@@ -90,10 +25,10 @@ Just create your own component.
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
export default BarChart.extend({
ready () {
// Overwriting base render method with actual data.
this.renderChart({
this.render({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
@@ -121,10 +56,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 Line.extend({
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
export default LineChart.extend({
props: [data, options],
ready () {
this.render(this.data, this.options)
}
})
```
@@ -146,77 +81,6 @@ 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 on your own or use one of the two mixins which are included.
- `reactiveProp`
- `reactiveData`
Both are included in the `mixins` module.
The mixins automatically create `chartData` as a prop or data. And add a watcher. If data has changed, the chart will update.
However keep in mind the limitations of vue and javascript for mutations on arrays and objects. More info [here](http://vue-chartjs.org/#/home?id=reactive-data)
```javascript
// MonthlyIncome.js
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
### Mixins module
The `mixins` module is included in the `VueCharts` module and as a seperate module.
Some ways to import them:
```javascript
// Load complete module with all charts
import VueCharts from 'vue-chartjs'
export default VueCharts.Line.extend({
mixins: [VueCharts.mixins.reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
```javascript
// Load speperate modules
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
```javascript
// Load speperate modules with destructure assign
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
## Available Charts
### Bar Chart
@@ -247,10 +111,6 @@ export default Line.extend({
![Bubble](assets/bubble.png)
### Scatter
![Scatter](assets/scatter.png)
## Build Setup
``` bash
@@ -273,7 +133,7 @@ npm run e2e
npm test
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
For 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

BIN
assets/bar.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 70 KiB

BIN
assets/bubble.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 82 KiB

BIN
assets/doughnut.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 78 KiB

BIN
assets/line.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 76 KiB

BIN
assets/pie.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 60 KiB

BIN
assets/polar.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 140 KiB

BIN
assets/radar.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256"><defs><linearGradient id="a" x1="100%" x2="0%" y1="4.18%" y2="65.116%"><stop stop-color="#FAFAFA" offset="0%"/><stop stop-color="#D9D9D9" offset="100%"/></linearGradient><linearGradient id="b" x1="108.208%" x2="5.433%" y1="12.265%" y2="86.92%"><stop stop-color="#FAFAFA" offset="0%"/><stop stop-color="#D9D9D9" offset="100%"/></linearGradient></defs><g fill="none"><path fill="#fff" stroke="#EBEBEB" stroke-width="8.456" d="M128.744 13l99.745 57.46v114.921l-99.745 57.46-99.744-57.46v-114.921z"/><path fill="url(#a)" d="M129 17.941l90.395 51.432-4.057 117.675-86.903 4.653z"/><path fill="url(#b)" d="M129 17.814l-90.961 51.559-3.191 113.538 93.587 8.79z"/><path fill="#41B883" d="M32.955 72.755l95.789 54.681v110.49l-95.789-54.681z"/><path fill="#35495E" d="M224.48 71.627l-95.789 55.809v110.49l95.789-54.681z"/><path fill="#596F85" d="M224.48 71.627l-95.789 55.809v-7.892l88.445-51.299z"/><path fill="#61D09F" d="M32.955 72.755l95.789 54.681v-7.892l-89.575-50.171z"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -5,7 +5,7 @@ var projectRoot = path.resolve(__dirname, '../')
module.exports = {
entry: {
app: './src/main.js'
app: './src/index.js'
},
output: {
path: config.build.assetsRoot,
@@ -17,7 +17,6 @@ module.exports = {
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'src': path.resolve(__dirname, '../src'),
'mixins': path.resolve(__dirname, '../src/mixins'),
'BaseCharts': path.resolve(__dirname, '../src/BaseCharts')
}
},

View File

@@ -1,9 +1,6 @@
const webpack = require('webpack')
const base = require('./webpack.base.conf')
const config = require('../config')
var env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
: config.build.env
base.entry = {
lib: './src/index.js'
@@ -22,7 +19,9 @@ var webpackConfig = Object.assign({}, base)
webpackConfig.devtool = '#source-map'
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
new webpack.DefinePlugin({
'process.env.NODE_ENV': env
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }

View File

@@ -1,92 +0,0 @@
var vue = require('vue-loader')
var path = require('path')
var webpack = require("webpack")
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var projectRoot = path.resolve(__dirname, '../')
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader')
const npmCfg = require('../package.json');
var banner = [
npmCfg.name + ' v' + npmCfg.version,
'(c) ' + (new Date().getFullYear()) + ' ' + npmCfg.author,
npmCfg.homepage
].join('\n')
module.exports = {
entry: {
'vue-chartjs': './src/index.js'
},
output: {
filename: './dist/[name].full.js',
library: 'VueChartJs',
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.css$/,
loader: cssLoader
},
{
test: /\.s[a|c]ss$/,
loader: ExtractTextPlugin.extract('style-loader','css-loader!sass-loader')
},
{
test: /\.json$/, loader: 'json'
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
plugins: [
new webpack.BannerPlugin(banner)
]
}
if (process.env.NODE_ENV === 'production') {
delete module.exports.devtool
module.exports.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
// new ExtractTextPlugin('build.css')
]
}

View File

@@ -1,18 +0,0 @@
var config = require('./webpack.release.full.js')
var webpack = require('webpack')
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
delete config.devtool
config.plugins = [
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
]
module.exports = config

View File

@@ -1,96 +0,0 @@
var vue = require('vue-loader')
var path = require('path')
var webpack = require("webpack")
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var projectRoot = path.resolve(__dirname, '../')
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader')
const npmCfg = require('../package.json');
var banner = [
npmCfg.name + ' v' + npmCfg.version,
'(c) ' + (new Date().getFullYear()) + ' ' + npmCfg.author,
npmCfg.homepage
].join('\n')
module.exports = {
entry: {
'vue-chartjs': './src/index.js'
},
output: {
filename: './dist/[name].js',
library: 'VueChartJs',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
'vue': 'vue',
'chart.js': 'chart.js'
},
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.css$/,
loader: cssLoader
},
{
test: /\.s[a|c]ss$/,
loader: ExtractTextPlugin.extract('style-loader','css-loader!sass-loader')
},
{
test: /\.json$/, loader: 'json'
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
plugins: [
new webpack.BannerPlugin(banner)
]
}
if (process.env.NODE_ENV === 'production') {
delete module.exports.devtool
module.exports.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
// new ExtractTextPlugin('build.css')
]
}

View File

@@ -1,18 +0,0 @@
var config = require('./webpack.release.js')
var webpack = require('webpack')
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
delete config.devtool
config.plugins = [
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
]
module.exports = config

View File

@@ -1,34 +0,0 @@
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

File diff suppressed because one or more lines are too long

View File

View File

@@ -1 +0,0 @@
vue-chartjs.org

View File

@@ -1,357 +0,0 @@
---
search: en
---
# vue-chartjs
**vue-chartjs** is a wrapper for [Chart.js](https://github.com/chartjs/Chart.js) in vue. You can easily create reuseable chart components.
## Introduction
`vue-chartjs` let you use chart.js without much hassle inside vue. It's perfect for people who need simple charts up and running as fast as possible.
It abstracts the basic logic but exposes the chart.js object to give you the most possible flexibility.
## Installation
If you are working with Vue.js 2+ simple run:
`yarn add vue-chartjs chart.js`
If you are using vue 1.x please use the `legacy` tag. However the vue 1 version is not maintained anymore.
`yarn add vue-chartjs@legacy`
## Quick Start
You need to import the base chart and extend it. This gives much more flexibility when working with different data.
You can encapsulate your components and use props to pass data or you can directly imput them inside the component. However this way, your component is not reuseable.
You can import the whole package or each module individual.
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.renderChart(data, options)
}
})
```
You can pass the `renderChart()` method, two arguments:
- Data object
- Options object
### Data object
The data object looks like this:
```javascript
{
labels: ['January', 'February'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
```
For more information take a look at the [Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) docs.
## Props
There are some basic props defined in the BaseCharts. Because you `extend()` them, they are *invisible*, but you can overwrite them:
| Prop | Description |
|---|---|
| width | chart width |
| height | chart height |
| chart-id | id of the canvas |
| css-classes | String with css classes for the surrounding div |
| styles | Object with css styles for the surrounding div container |
## Examples
Here are some exmaples
### Chart with props
You can create the data and options props to pass data to the chart.
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
After you add your component you can use it:
```html
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
```
If you want to overwrite the width and height:
```html
<line-chart
:data="{your data object}"
:options="{responsive: false, maintainAspectRatio: false}"
:width="400"
:height="200"
>
</line-chart>
```
<p class="warning">
Please keep in mind, that you have to set `responsive: false` to be able to set a fix `width` and `height`.
</p>
### Chart with local data
```javascript
import {Bar} from 'vue-chartjs'
export default Bar.extend({
data () {
return {
datacollection: {
labels: ['January', 'February'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
})
```
### Reusebale Components
If you want to keep your chart components reuseable, it's the best to add a wrapper to them. This way the chart component is only responsable for the pure data representation and the wrapper component for the logic behind it. There are many different usecases and it is different if you're running a Single Page Application or integrate it in for example laravel.
## Reactive Data
Chart.js does not provide a live update if you change the datasets. However `vue-chartjs` provides two mixins to achive this.
- `reactiveProp`
- `reactiveData`
Both mixins to actually the same. Most of the time you will use `reactiveProp`. It extends the logic of your chart component and automatically creates a prop names `chartData` and add a `vue watch` on this prop. On data change, it will either call `update()` if only the data inside the datasets has changed or `renderChart()` if new datasets were added.
`reactiveData` simply creates a local chartData variable which is not a prop! And add a watcher.
This is only usefull, if you need single purpose charts and make an API call inside your chart component.
```javascript
data () {
return {
chartData: null
}
}
```
### Example
**LineChart.js**
```javascript
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ['options'],
mounted () {
// this.chartData is created in the mixin.
// If you want to pass options please create a local options object
this.renderChart(this.chartData, this.options)
}
})
```
**RandomChart.vue**
```javascript
<template>
<div class="small">
<line-chart :chart-data="datacollection"></line-chart>
<button @click="fillData()">Randomize</button>
</div>
</template>
<script>
import LineChart from './LineChart.js'
export default {
components: {
LineChart
},
data () {
return {
datacollection: null
}
},
mounted () {
this.fillData()
},
methods: {
fillData () {
this.datacollection = {
labels: [this.getRandomInt(), this.getRandomInt()],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}, {
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}
]
}
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
}
</script>
<style>
.small {
max-width: 600px;
margin: 150px auto;
}
</style>
```
<p class="warning">
⚠ Attention: If you mutate your data in a parent component and pass it to your child chart component keep in mind the javascript limitiations.
More info in this [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
</p>
### Limitations
<ul>
<li>[Caveats](https://vuejs.org/v2/guide/list.html#Caveats)</li>
<li>[Change-Detection-Caveats](https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats)</li>
<li>[vm.$watch](https://vuejs.org/v2/api/#vm-watch)</li>
</ul>
## Chart.js object
Sometimes you need more control over chart.js. Thats why you can access the chart.js instance over `this._chart`
## Inline plugins
In Chart.js you can define global and inline plugins. Global plugins are working without problems with `vue-chartjs` like in the [chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html) described.
If you want to add inline plugins, `vue-chartjs` exposes a helper method called `addPlugin()`
You should call `addPlugin()` before the `renderChart()` method.
### Example
```javascript
mounted () {
this.addPlugin({
id: 'my-plugin',
beforeInit: function (chart) {
....
}
})
}
```
## Available Charts
### Bar Chart
<p class="tip">
There are two versions of the Bar chart. `{Bar}` and `{HorizontalBar}`
</p>
![Bar](assets/bar.png)
### Line Chart
![Line](assets/line.png)
### Doughnut
![Doughnut](assets/doughnut.png)
### Pie
![Pie](assets/pie.png)
### Radar
![Pie](assets/radar.png)
### Polar Area
![Pie](assets/polar.png)
### Bubble
![Bubble](assets/bubble.png)
### Scatter
This chart has a different data structure then the others. Right now the reactive Mixins are not working for this chart type.
![Scatter](assets/scatter.png)
## Explanation of Different Builds
There are three different entry points. It depends on which build setup do you have. The dependencies are bundled or required as a peerDependency.
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Bundled | Bundled |
| vue-chartjs.full.min.js | Bundled | Bundled |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### Browser
You can use `vue-chartjs` directly in the browser without any build setup. Like in this [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). For this case, please use the `vue-chartjs.full.min.js` which is the minified version. It has Vue.js and Chart.js bundled into it. And bundled to a UMD Module. So you only need that one file.
### Browserify / Webpack 1
If you're using Gulp, Browserify or Webpack 1 the entry is `vue-chartjs.js` which is __transpiled__ and __bundled__ UMD Module.
However Vue.js and Chart.js are `peerDependencies` so you have to install them seperately. In most projects you will have `Vue.js` already installed anyways. This way, you can have different versions of Vue.js and Chart.js then in this package.
### Webpack 2
If you're using Webpack 2 it will automatically use the `jsnext:main` / `module` entry point. Which is `es/index.js`
It is a __transpiled__ es version of the source. And is not __bundled__ to a module. This way your tree shaking will work. Like in the bundled version, `Vue.js` and `Chart.js` are `peerDependencies` and need to be installed.
## Resources
You can find here some Resources like tutorials on how to use `vue-chartjs`
- [Using vue-chartjs with WordPress](https://medium.com/@apertureless/wordpress-vue-and-chart-js-6b61493e289f)
- [Create stunning Charts with Vue and Chart.js](https://hackernoon.com/creating-stunning-charts-with-vue-js-and-chart-js-28af584adc0a)
- [Lets Build a Web App with Vue, Chart.js and an API Part I](https://hackernoon.com/lets-build-a-web-app-with-vue-chart-js-and-an-api-544eb81c4b44)
- [Lets Build a Web App with Vue, Chart.js and an API Part II](https://hackernoon.com/lets-build-a-web-app-with-vue-chart-js-and-an-api-part-ii-39781b1d5acf)
- [Build a realtime chart with VueJS and Pusher](https://blog.pusher.com/build-realtime-chart-with-vuejs-pusher/)

View File

@@ -1,78 +0,0 @@
<h1>📈 vue-chartjs</h1>
<h2>⚡ Easy and beautiful charts with Chart.js and Vue.js</h2>
<ul class="features">
<li>Easy for both beginners and pros 🙌</li>
<li>Simple to use, easy to extend 💪</li>
<li>With the full power of chart.js 💯</li>
</ul>
<div class="landing-buttons">
<a class="landing-button" target="_blank" href="https://github.com/apertureless/vue-chartjs">
GitHub
</button>
<a class="landing-button" router-link="/home">
Docs
</a>
<a class="landing-button" target="_blank" href="http://demo.vue-chartjs.org/">
Demo
</a>
</div>
<style>
h1 {
margin: 0;
margin-top: -50px;
font-weight: normal;
font-size: 40px;
letter-spacing: 1px;
}
h2 {
margin-top: 20px;
color: #999;
font-weight: normal;
letter-spacing: 1px;
}
.landing {
padding: 10px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
height: 100%;
-webkit-user-select: none;
user-select: none;
}
.features {
margin-top: 20px;
margin-bottom: 60px;
font-size: 16px;
line-height: 1.7;
}
.landing-button {
border: 1px solid #ccc;
border-radius: 33px;
padding: 10px 30px;
background-color: white;
display: inline-block;
margin-right: 20px;
color: #333;
}
.landing-button:hover {
border-color: #42b983;
color: #42b983;
text-decoration: none;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256"><defs><linearGradient id="a" x1="100%" x2="0%" y1="4.18%" y2="65.116%"><stop stop-color="#FAFAFA" offset="0%"/><stop stop-color="#D9D9D9" offset="100%"/></linearGradient><linearGradient id="b" x1="108.208%" x2="5.433%" y1="12.265%" y2="86.92%"><stop stop-color="#FAFAFA" offset="0%"/><stop stop-color="#D9D9D9" offset="100%"/></linearGradient></defs><g fill="none"><path fill="#fff" stroke="#EBEBEB" stroke-width="8.456" d="M128.744 13l99.745 57.46v114.921l-99.745 57.46-99.744-57.46v-114.921z"/><path fill="url(#a)" d="M129 17.941l90.395 51.432-4.057 117.675-86.903 4.653z"/><path fill="url(#b)" d="M129 17.814l-90.961 51.559-3.191 113.538 93.587 8.79z"/><path fill="#41B883" d="M32.955 72.755l95.789 54.681v110.49l-95.789-54.681z"/><path fill="#35495E" d="M224.48 71.627l-95.789 55.809v110.49l95.789-54.681z"/><path fill="#596F85" d="M224.48 71.627l-95.789 55.809v-7.892l88.445-51.299z"/><path fill="#61D09F" d="M32.955 72.755l95.789 54.681v-7.892l-89.575-50.171z"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1,48 +0,0 @@
const langs = [
{title: 'English', path: '/home', matchPath: /^\/(home|changelog)/},
{title: 'Deutsch', path: '/de/', matchPath: /^\/de/},
{title: '日本語', path: '/ja/', matchPath: /^\/ja/},
{title: 'Português do Brasil', path: '/pt-br/', matchPath: /^\/pt-br/},
{title: '中文(简体)', path: '/zh-cn/', matchPath: /^\/zh-cn/},
{title: 'Русский', path: '/ru/', matchPath: /^\/ru/}
]
docute.init({
title: 'vue-chartjs docs',
landing: true,
landing: '_landing.html',
repo: 'apertureless/vue-chartjs',
twitter: 'apertureless',
tocVisibleDepth: 2,
'edit-link': 'https://github.com/apertureless/vue-chartjs/blob/master/docs',
nav: {
default: [
{
title: 'Home', path: '/home'
},
{
title: 'Changelog', path: '/changelog', source: 'https://raw.githubusercontent.com/apertureless/vue-chartjs/develop/CHANGELOG.md'
},
{
title: 'Languages', type: 'dropdown', items: langs
}
],
'de': [
{
title: 'Startseite', path: '/de/'
}
]
},
plugins: [
evanyou(),
docsearch({
apiKey: 'b3544f7387612693644777553675d56a',
indexName: 'vue-chartjs',
// algolia docsearch allows you to search with tag filter
tags: ['en', 'de', 'ja', 'pt-br', 'ru'],
// this plugin does require a url too
// where docsearch fetches contents
url: 'https://vue-chartjs.org'
})
],
})

View File

@@ -1,311 +0,0 @@
---
search: de
---
# vue-chartjs
**vue-chartjs** ist ein Wrapper für [Chart.js](https://github.com/chartjs/Chart.js) in vue. Man kann einfach wiederverwendbare Chart Components erstellen.
## Einleitung
`vue-chartjs` let you use chart.js without much hassle inside vue. It's perfect for people who need simple charts up and running as fast as possible.
It abstracts the basic logic but exposes the chart.js object to give you the most possible flexibility.
## Installation
If you are working with Vue.js 2+ simple run:
`yarn add vue-chartjs chart.js`
If you are using vue 1.x please use the `legacy` tag. However the vue 1 version is not maintained anymore.
`yarn add vue-chartjs@legacy`
## Schnellstart
You need to import the base chart and extend it. This gives much more flexibility when working with different data.
You can encapsulate your components and use props to pass data or you can directly imput them inside the component. However this way, your component is not reuseable.
You can import the whole package or each module individual.
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.renderChart(data, options)
}
})
```
You can pass the `renderChart()` method, two arguments:
- Data object
- Options object
### Data object
The data object looks like this:
```javascript
{
labels: ['January', 'February'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
```
For more information take a look at the [Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) docs.
## Props
There are some basic props defined in the BaseCharts. Because you `extend()` them, they are *invisible*, but you can overwrite them:
| Prop | Description |
|---|---|
| width | chart width |
| height | chart height |
| chart-id | id of the canvas |
## Examples
Here are some exmaples
### Chart with props
You can create the data and options props to pass data to the chart.
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
After you add your component you can use it:
```html
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
```
If you want to overwrite the width and height:
```html
<line-chart
:data="{your data object}"
:options="{responsive: false, maintainAspectRatio: false}"
:width="400"
:height="200"
>
</line-chart>
```
<p class="warning">
Please keep in mind, that you have to set `responsive: false` to be able to set a fix `width` and `height.
</p>
### Chart with local data
```javascript
import {Bar} from 'vue-chartjs'
export default Bar.extend({
data () {
return {
datacollection: {
labels: ['January', 'February'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
})
```
### Reusebale Components
If you want to keep your chart components reuseable, it's the best to add a wrapper to them. This way the chart component is only responsable for the pure data representation and the wrapper component for the logic behind it. There are many different usecases and it is different if you're running a Single Page Application or integrate it in for example laravel.
## Reactive Data
Chart.js does not provide a live update if you change the datasets. However `vue-chartjs` provides two mixins to achive this.
- `reactiveProp`
- `reactiveData`
Both mixins to actually the same. Most of the time you will use `reactiveProp`. It extends the logic of your chart component and automatically creates a prop names `chartData` and add a `vue watch` on this prop. On data change, it will either call `update()` if only the data inside the datasets has changed or `renderChart()` if new datasets were added.
`reactiveData` simply creates a local chartData variable which is not a prop! And add a watcher.
This is only usefull, if you need single purpose charts and make an API call inside your chart component.
```javascript
data () {
return {
chartData: null
}
}
```
### Example
**LineChart.js**
```javascript
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ['options'],
mounted () {
// this.chartData is created in the mixin
this.renderChart(this.chartData, this.options)
}
})
```
**RandomChart.vue**
```javascript
<template>
<div class="small">
<line-chart :chart-data="datacollection"></line-chart>
<button @click="fillData()">Randomize</button>
</div>
</template>
<script>
import LineChart from './LineChart.js'
export default {
components: {
LineChart
},
data () {
return {
datacollection: null
}
},
mounted () {
this.fillData()
},
methods: {
fillData () {
this.datacollection = {
labels: [this.getRandomInt(), this.getRandomInt()],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}, {
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}
]
}
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
}
</script>
<style>
.small {
max-width: 600px;
margin: 150px auto;
}
</style>
```
<p class="warning">
⚠ Attention: If you mutate your data in a parent component and pass it to your child chart component keep in mind the javascript limitiations.
More info in this [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
</p>
### Limitations
<ul>
<li>[Caveats](https://vuejs.org/v2/guide/list.html#Caveats)</li>
<li>[Change-Detection-Caveats](https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats)</li>
<li>[vm.$watch](https://vuejs.org/v2/api/#vm-watch)</li>
</ul>
## Chart.js object
Sometimes you need more control over chart.js. Thats why you can access the chart.js instance over `this._chart`
## Available Charts
### Bar Chart
<p class="tip">
There are two versions of the Bar chart. `{Bar}` and `{HorizontalBar}`
</p>
![Bar](../assets/bar.png)
### Line Chart
![Line](../assets/line.png)
### Doughnut
![Doughnut](../assets/doughnut.png)
### Pie
![Pie](../assets/pie.png)
### Radar
![Pie](../assets/radar.png)
### Polar Area
![Pie](../assets/polar.png)
### Bubble
![Bubble](../assets/bubble.png)
## Webpack, Browserify and dist files.
If you use `import VueCharts from 'vue-chartjs'` you will mostly import the UMD build of vue-chart.js
This is because of compatibility reasons. This approach however has a downside: vue.js and chart.js are bundled into the file.
And you end up with two vue instances.
If you're using webpack 2 or rollup however, it will automatically import the transpiled ES sources.
If you know what you're doing you can import directly from the transpiled es sources:
```
import { Line } from 'vue-chartjs/es'
```
### Browserify
In order for a browserify user to transpile the code, they would need to install `babelify` and `babel-preset-es2015` and add a .babelrc file in the root of their project with the following code:
```
{
"presets": ["es2015"]
}
```

View File

@@ -1,32 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<title>vue-chartjs doc</title>
<link rel="stylesheet" href="https://unpkg.com/docute@2/dist/docute.css">
</head>
<body>
<!-- don't remove this part start -->
<div id="app"></div>
<script src="https://unpkg.com/docute-evanyou"></script>
<script src="https://unpkg.com/docute/dist/docute.js"></script>
<script src="https://unpkg.com/docute/plugins/docsearch.js"></script>
<script src="./config.js"></script>
<!-- don't remove this part end -->
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-92766713-1', 'auto');
ga('send', 'pageview');
docute.router.afterEach(function (to) {
ga('set', 'page', to.fullPath);
ga('send', 'pageview');
});
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
</body>
</html>

View File

@@ -1,318 +0,0 @@
---
search: ja
---
# vue-chartjs
**vue-chartjs** は [Chart.js](https://github.com/chartjs/Chart.js) をvueで使用するためのラッパーです。 再利用可能なチャートコンポーネントを簡単に作成できます。
## イントロ
`vue-chartjs` vueの中であまり面倒なくchart.jsを使うことができます。 シンプルなチャートをできるだけ早く実行したいという人に最適です。
chart.jsの基本ロジックを抽象化していますが、公開されたchart.jsのオブジェクト使用して柔軟にカスタマイズできます。
## インストール
Vue.jsの Version2以上を使用している場合は簡単にインストールできます。:
`yarn add vue-chartjs chart.js`
Vue.jsの Version 1.xを使用している場合は`legacy`タグを使用してください。しかし、vueのバージョン1はもうメンテナンスされません。
`yarn add vue-chartjs@legacy`
## クイックスタート
BaseChartをインポートしてextendします。
異なるデータのチャートを表示するときに柔軟性が大幅に向上します。
コンポーネントをカプセル化し、プロパティをコンポーネントのデータに渡したり、コンポーネント内に直接データを記述することができます。ただし直接データを記述した場合はコンポーネントの再利用ができません。
パッケージ全体またはモジュールごとに個別にインポートすることができます。
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.renderChart(data, options)
}
})
```
renderChart()メソッドに2つの引数を渡すことができます:
- Data object
- Options object
### データオブジェクト
データオブジェクトは、次のようになります。:
```javascript
{
labels: ['January', 'February'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
```
詳細については、[Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) のドキュメントをご覧ください。
## プロパティ
BaseChartsには基本プロパティがいくつか定義されています。 extendされたときにそれらは明示的に表示されていませんが、使用するときに上書きして設定することができます。
| プロパティ | 説明 |
|---|---|
| width | chartの表示幅 |
| height | chartの表示高さ |
| chart-id | canvas要素のid |
## 実装例
いくつか例を記載します。
### プロパティの利用
dataとoptionsプロパティを作成して、チャートにデータを渡すことが出来ます。
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
コンポーネントに追加して、使用することができます。
```html
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
```
幅と高さを上書きする場合:
```html
<line-chart
:data="{your data object}"
:options="{responsive: false, maintainAspectRatio: false}"
:width="400"
:height="200"
>
</line-chart>
```
<p class="warning">
`width``height` を反映させるためには、 `responsivefalse` を設定しなければならないことに注意してください。
</p>
### コンポーネント内のローカルデータを使用する場合
```javascript
import {Bar} from 'vue-chartjs'
export default Bar.extend({
data () {
return {
datacollection: {
labels: ['January', 'February'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
}
}
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
})
```
### コンポーネントの再利用
チャートコンポーネントを再利用可能にしたい場合は、ラッパーを使用することをお勧めします。このようにすると、チャートコンポーネントはデータ表示とロジックを含むラッパーコンポーネントに対してのみ応答可能です。単一ページアプリケーションを実行している場合や、laravelで統合されている場合は、異なった方法があります。
## リアクティブデータ
Chart.js はデータセットを変更したときのライブアップデートを提供していません。`vue-chartjs` ではこれを実現するために2つのミックスインを提供します。
- `reactiveProp`
- `reactiveData`
この2つのミックスインは実際には同じものです。 ほとんどの場合 `reactiveProp` を使用します。これはチャートコンポーネントのロジックを拡張し、自動的に `chartData` という名前のプロパティを追加し、さらにこのプロパティに対して `vue watch` を追加します。 データの更新に対して、データセット内のデータのみが変更されたときには `update()` を呼び出し、新しいデータセットが追加された場合は `renderChart()` が呼び出されます。
`reactiveData` は単純に(プロパティではない!!)ローカルの chartData 変数を追加し、ウォッチャーを追加します。
単一の目的のチャートのみ必要でチャートコンポーネント内でAPI呼び出しを行うときのみ有用です。
```javascript
data () {
return {
chartData: null
}
}
```
### 例
**LineChart.js**
```javascript
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ['options'],
mounted () {
// this.chartData is created in the mixin
this.renderChart(this.chartData, this.options)
}
})
```
**RandomChart.vue**
```javascript
<template>
<div class="small">
<line-chart :chart-data="datacollection"></line-chart>
<button @click="fillData()">Randomize</button>
</div>
</template>
<script>
import LineChart from './LineChart.js'
export default {
components: {
LineChart
},
data () {
return {
datacollection: null
}
},
mounted () {
this.fillData()
},
methods: {
fillData () {
this.datacollection = {
labels: [this.getRandomInt(), this.getRandomInt()],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}, {
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}
]
}
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
}
</script>
<style>
.small {
max-width: 600px;
margin: 150px auto;
}
</style>
```
<p class="warning">
⚠ 注意:親コンポーネントでデータを変更し、それを子チャートコンポーネントに渡す場合は、JavaScriptの制限事項に注意してください。
この問題の詳細 [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
</p>
### 制限事項
<ul>
<li>[注意事項](https://jp.vuejs.org/v2/guide/list.html#注意事項)</li>
<li>[変更検出の注意事項](https://jp.vuejs.org/v2/guide/reactivity.html#変更検出の注意事項)</li>
<li>[vm.$watch](https://jp.vuejs.org/v2/api/#vm-watch)</li>
</ul>
## Chart.js オブジェクト
場合によっては、chart.jsをより詳細に制御する必要があります。Chart.jsインスタンスには `this._chart` を使ってアクセスします。
## 利用可能なグラフ
### 棒グラフ
<p class="tip">
棒グラフには `{Bar}``{HorizontalBar}` の2つのバージョンがあります。
</p>
![Bar](../assets/bar.png)
### 折れ線グラフ
![Line](../assets/line.png)
### ドーナツチャート
![Doughnut](../assets/doughnut.png)
### パイチャート
![Pie](../assets/pie.png)
### レーダーチャート
![Pie](../assets/radar.png)
### 鶏頭図
![Pie](../assets/polar.png)
### バブルチャート
![Bubble](../assets/bubble.png)
## ビルド方法の違い
あなたが使用するビルドツールに依存した3つの異なるエントリーポイントがあります。 依存するライブラリは一緒にバンドルされているか、または peerDependency として指定します。
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Bundled | Bundled |
| vue-chartjs.full.min.js | Bundled | Bundled |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### ブラウザー
`vue-chartjs` をビルドツールを使用せず直接ブラウザー内で使用します。 例 [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010) このケースでは縮小版の `vue-chartjs.full.min.js` を使用します。これにはVue.js と Chart.js が 含まれていて、UMD Module として定義されています。従ってあなたはただ一つのファイルしか必要としません。
### Browserify / Webpack 1
Gulp、BrowserifyまたはWebpackのバージョン1を使用している場合は、__トランスパイル__ され UMD Moduleとして __バンドル__ された `vue-chartjs.js` を使用します。
Vue.jsとChart.jsは `peerDependencies` なので別にインストールする必要があります。ほとんどのプロジェクトでは、Vue.jsはすでにインストールされているでしょう。この方法では、このパッケージと異なるバージョンのVue.jsとChart.jsを持つことができます。
### Webpack 2
Webpack 2を使用している場合、 `jsnext:main` または `module``es/index.js` を指定します。 ソースファイルは __トランスパイル__ されます。またmoduleには __バンドル__ されません。このようにすると `tree shaking` が動作します。バンドル版のように、`peerDependencies` で指定された `Vue.js``Chart.js` はインストールする必要があります。

View File

@@ -1,284 +0,0 @@
<div align="center">
<img width="256" heigth="256" src="/assets/vue-chartjs.png" alt="vue-chartjs logo">
</div>
[![npm version](https://badge.fury.io/js/vue-chartjs.svg)](https://badge.fury.io/js/vue-chartjs)
[![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)
[![Package Quality](http://npm.packagequality.com/shield/vue-chartjs.svg)](http://packagequality.com/#?package=vue-chartjs)
[![npm](https://img.shields.io/npm/dm/vue-chartjs.svg)](https://www.npmjs.com/package/vue-chartjs)
[![Gitter chat](https://img.shields.io/gitter/room/TechnologyAdvice/Stardust.svg)](https://gitter.im/vue-chartjs/Lobby)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/apertureless/vue-chartjs/blob/master/LICENSE.txt)
[![CDNJS version](https://img.shields.io/cdnjs/v/vue-chartjs.svg)](https://cdnjs.com/libraries/vue-chartjs)
# vue-chartjs
**vue-chartjs** é um wrapper para o [Chart.js](https://github.com/chartjs/Chart.js) no vue. Você pode criar gráficos reutilizáveis facilmente.
## Demo & Docs
- 📺 [Demo](http://demo.vue-chartjs.org/)
- 📖 [Docs](http://www.vue-chartjs.org/)
### Compatibilidade
- v1 later `@legacy`
- Vue.js 1.x
- v2 later
- Vue.js 2.x
Após a release final do vue.js 2, você também instala por padrão o vue-chartjs v2 pelo npm.
Não é mas necessária a tag @next. Se você quiser a versão v1, você precisa definir a versão ou usar uma tag legada.
Se está procurando pela versão v1, dê uma olhada nessa [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.1.3)
## Instalação
Simplemente execute `yarn add vue-chartjs chart.js`
Ou se quiser utilizar diretamente no browser, adicione
```html
<script src="https://unpkg.com/vue-chartjs@2.6.0/dist/vue-chartjs.full.min.js"></script>
```
em seus scripts. Veja [Codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010)
## Explicação das diferentes builds
Existem três diferentes pontos de entrada (entry points). Isso depende da configuração de build que você possui. As dependências são empacotadas (bundled) ou requisitadas como peerDependency.
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Bundled | Bundled |
| vue-chartjs.full.min.js | Bundled | Bundled |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### Browser
Você pode usar o `vue-chartjs` diretamente no seu browser sem qualquer configuração de build. Como em [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). Nesse caso, use `vue-chartjs.full.min.js` que é a versão minificada. Esse arquivo contém o Vue.js e o Chart.js inseridos nele. E são And empacotados (bundled) em um módulo UMD. Então você precisa somente desse arquivo.
### Browserify / Webpack 1
Se você estiver usando Gulb, Browserify ou Webpack 1 a opção é `vue-chartjs.js`, que é __transpiled__ e __bundled__ no modelo UMD.
Porém, Vue.js e Chart.js são `peerDependencies`, então você precisa instalá-los seperadamente. Na maioria dos projetos você terá o `Vue.js` instalado de qualquer maneira. Dessa forma, você pode ter diferentes versões do Vue.js e do Chart.j nesse pacote.
### Webpack 2
Se você está usando o Webpack 2, ele automaticamente usará a opção `jsnext:main` / `module`. Que é `es/index.js`, uma versão do código do es __transpiled__. Não é __bundled__ em módulo algum. Dessa forma, seu [tree shaking](https://webpack.js.org/guides/tree-shaking/) funcionará. Como na versão bundled, o `Vue.js` e o `Chart.js` são `peerDependencies` e precisam ser instalados.
## Como usar
Você precisa importar a classe de gráficos básica e extendê-la. Isso garante muito mais flexibilidade quando se está trabalhando com dados diferentes. Você pode passar dados via props ou vue-resource.
Você pode importar todo o pacote ou cada módulo individualmente.
```javascript
import VueCharts from 'vue-chartjs'
import { Bar, Line } from 'vue-chartjs'
```
Apenas crie seu próprio componente.
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
})
}
})
```
Então, simplesmente importe e use seu próprio componente extendido como um componente vue.
```javascript
import CommitChart from 'path/to/component/CommitChart'
```
## Another Example with options
Você pode sobreescrever as options (opções) padrão do gráfico. Basta passar o objeto options como segundo parâmetro do método de renderização.
```javascript
// MonthlyIncome.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ["data", "options"],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
Use isso no seu componente vue
```javascript
import MonthlyIncome from 'path/to/component/MonthlyIncome'
<template>
<monthly-income :data={....} />
</template>
<script>
export default {
components: { MonthlyIncome },
....
}
</script>
```
## Reactivity (Reatividade)
O Chart.js não atualiza nem re-renderiza o gráfico se novos dados são passados.
Porém, você pode implementar isso por si só ou usar um dos dois mixins inclusos.
- `reactiveProp`
- `reactiveData`
Ambos estão incluídos no módulo de `mixins`.
Os mixins criam automaticamente o `chartData` como um prop ou como um data. E adiciona um watcher. Se os dados mudarem, o gráfico será atualizado. Mas matenha em mente as limitações do vue e do javascript para as mutations(mutações) em vetores e objetos. Mais informações [aqui](http://vue-chartjs.org/#/home?id=reactive-data)
```javascript
// MonthlyIncome.js
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ["chartData", "options"],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
### Módulo de Mixins
O módulo de `mixins` está incluído no módulo do `VueCharts` e como módulo separado.
Algumas maneiras de importá-los:
```javascript
// Load complete module with all charts
import VueCharts from 'vue-chartjs'
export default VueCharts.Line.extend({
mixins: [VueCharts.mixins.reactiveProp],
props: ["chartData", "options"],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
```javascript
// Load speperate modules
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ["chartData", "options"],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
```javascript
// Load speperate modules with destructure assign
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ["chartData", "options"],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
## Gráficos disponíveis
### Gráfico de Barra
![Barra](../assets/bar.png)
### Gráfico de Linha
![Linha](../assets/line.png)
### Donut
![Donut](../assets/doughnut.png)
### Pizza
![Pizza](../assets/pie.png)
### Radar
![Radar](../assets/radar.png)
### Área Polar
![Área Polar](../assets/polar.png)
### Bolha
![Bolha](../assets/bubble.png)
## Configurações de Build
``` bash
# Instala as dependências
npm install
# roda o servidor com hot reload at localhost:8080
npm run dev
# build para produção com minificação
npm run build
# roda testes unitários
npm run unit
# roda testes e2e
npm run e2e
# roda todos os teste
npm test
```
Para informações detalhadas de como as coisas funcionam, confira o [guia](http://vuejs-templates.github.io/webpack/) e [documentação do vue-loader](http://vuejs.github.io/vue-loader).
## Contribuindo
1. Faça um fork o projeto ( https://github.com/apertureless/vue-chartjs/fork )
2. Crie uma branch da sua feature (`git checkout -b my-new-feature`)
3. Faça o commit das suas modificações (`git commit -am 'Add some feature'`)
4. Faça o push da branch (`git push origin my-new-feature`)
5. Crie uma nova requisição de pull
## License
Esse software é distribuído sob a licença [MIT license](LICENSE.txt).

View File

@@ -1,294 +0,0 @@
---
search: ru
---
<div align="center">
<img width="256" heigth="256" src="../../assets/vue-chartjs.png" alt="vue-chartjs logo">
</div>
[![npm version](https://badge.fury.io/js/vue-chartjs.svg)](https://badge.fury.io/js/vue-chartjs)
[![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)
[![Package Quality](http://npm.packagequality.com/shield/vue-chartjs.svg)](http://packagequality.com/#?package=vue-chartjs)
[![npm](https://img.shields.io/npm/dm/vue-chartjs.svg)](https://www.npmjs.com/package/vue-chartjs)
[![Gitter chat](https://img.shields.io/gitter/room/TechnologyAdvice/Stardust.svg)](https://gitter.im/vue-chartjs/Lobby)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/apertureless/vue-chartjs/blob/master/LICENSE.txt)
[![CDNJS version](https://img.shields.io/cdnjs/v/vue-chartjs.svg)](https://cdnjs.com/libraries/vue-chartjs)
# vue-chartjs
**vue-chartjs** обертка для [Chart.js](https://github.com/chartjs/Chart.js) в vue. Вы можете с легкостью создавать многоразовые компоненты диаграмм.
## Демо & Документация
- 📺 [Demo](http://demo.vue-chartjs.org/)
- 📖 [Docs](http://www.vue-chartjs.org/)
### Совместимость
- v1 later `@legacy`
- Vue.js 1.x
- v2 later
- Vue.js 2.x
После филнального выпуска vue.js 2, вы получите v2 по умолчанию, если установите vue-chartjs через npm.
Больше нет необходимости в @next теге. Если вы нуждаетесь в v1, вам необходимо указать версию или использовать legacy тег.
Если вы ищите v1, проверьте эту [ветку](https://github.com/apertureless/vue-chartjs/tree/release/1.x).
## Установка
Просто выполните `yarn add vue-chartjs chart.js`
В случаи если вы хотите использовать библиотеку прямо в браузере, добавьте
```html
<script src="https://unpkg.com/vue-chartjs@2.6.0/dist/vue-chartjs.full.min.js"></script>
```
в ваши скрипты. Смотрите [Codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010)
## Описание различий сборок
Существует три различные точки входа. Это зависит от того, какая сборка стоит у вас. Зависимости собираются или подключаются как peerDependency.
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Bundled | Bundled |
| vue-chartjs.full.min.js | Bundled | Bundled |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### Браузер
Вы можете использовать `vue-chartjs` прямо в браузере без установки каких-либо сборок. Пример на [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). В этом случаи, пожалуйста, используйте `vue-chartjs.full.min.js`. Это минифицированноая версиея библиотеки, содержащая Vue.js и Chart.js в себе, с возможностью подключения при помощи UMD Module. Таким образом, вам необходим лишь один файл.
### Browserify / Webpack 1
Если вы используете Gulp, Browserify или Webpack 1, входная точка находится в `vue-chartjs.js`. Она __транслируется__ и __собирается__ при помощи UMD Module.
Однако Vue.js и Chart.js является `peerDependencies`, поэтому вы можете устанавливать их отдельно. В большинстве проектов вы в любом случаи будете иметь установленный `Vue.js`. В этом случаи, вы можете иметь различные версии Vue.js и Chart.js.
### Webpack 2
Если вы используете Webpack 2, он будет автоматически использовать `jsnext:main` / `module` в качестве входной точки, которая расположена в `es/index.js`.
Это транслированная es версия кода, которая не __собирается__ в модуль. Таким образом, three shaking будет работать.
Как и в собранной версии, `Vue.js` и `Chart.js` являются `peerDependencies` и не нуждаются в установке.
## Как использовать
Вам необходимо импортировать базовый класс диаграммы и унаследовать его. Это даст гораздо большую гибкость при работе с различными данными. Вы можете передать данные через props или vue-resource.
Вы можете импортировать весь проект или каждый модуль по отдельности.
```javascript
import VueCharts from 'vue-chartjs'
import { Bar, Line } from 'vue-chartjs'
```
Просто создайте ваш собственный компонент.
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Переопределение базового рендер метода с реальными данными.
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
})
}
})
```
Затем просто импортируйте и используйте ваши собственные расширенные компоненты как обычные vue компоненты.
```javascript
import CommitChart from 'path/to/component/CommitChart'
```
## Другой пример с options
Вы можете переопределить стандартные опции графика. Просто передайте объект с опциями в качестве второго параметра в рендер метод.
```javascript
// MonthlyIncome.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
Используйте это в вашем vue приложении
```javascript
import MonthlyIncome from 'path/to/component/MonthlyIncome'
<template>
<monthly-income :data={....} />
</template>
<script>
export default {
components: { MonthlyIncome },
....
}
</script>
```
## Реактивность
Chart.js не обновляет и не перерисовывает диаграмму при передаче новых данных.
Впрочем, вы можете реализовать это самостоятельно или использовав один из двух подключенных миксинов:
- `reactiveProp`
- `reactiveData`
Оба включены в `mixins` модуль.
Миксины автоматически создают `chartData` в виде prop или data. И добавляют watcher. Если данные были измененны, график обновится.
Но помните про ограничение vue и javascript на изменений массивов и объектов. Больше информации можно получить [здесь](http://vue-chartjs.org/#/home?id=reactive-data)
```javascript
// MonthlyIncome.js
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
### Mixins модуль
Модуль `mixins` включен в `VueCharts`, а также доступен в виде отдельного модуля.
Несколько способов импортировать их:
```javascript
// Load complete module with all charts
import VueCharts from 'vue-chartjs'
export default VueCharts.Line.extend({
mixins: [VueCharts.mixins.reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
```javascript
// Load speperate modules
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
mixins: [mixins.reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
```javascript
// Load speperate modules with destructure assign
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
```
## Доступные диаграммы
### Bar Chart
![Bar](../assets/bar.png)
### Line Chart
![Line](../assets/line.png)
### Doughnut
![Doughnut](../assets/doughnut.png)
### Pie
![Pie](../assets/pie.png)
### Radar
![Pie](../assets/radar.png)
### Polar Area
![Pie](../assets/polar.png)
### Bubble
![Bubble](../assets/bubble.png)
### Scatter
![Scatter](../assets/scatter.png)
## Настройка сборки
``` bash
# инициализация зависимостей
npm install
# сборка с горячей заменой на localhost:8080
npm run dev
# сборка для production с минификацией
npm run build
# запуск unit тестов
npm run unit
# запуск e2e тестов
npm run e2e
# запуск всех тестов
npm test
```
Для детальных объяснений того, как это работает, перейдите в [руководство](http://vuejs-templates.github.io/webpack/) и [документацию для 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).

View File

@@ -1,358 +0,0 @@
---
search: zh-cn
---
# vue-chartjs
**vue-chartjs** 是基于 vue 的 [Chart.js](https://github.com/chartjs/Chart.js) 封装。你可以轻松的创建可复用的图表组件。
## 简介
`vue-chartjs` 让你在 vue 中使用 chart.js 省去很多麻烦。非常适合需要快速生成简单图表的人。
它抽象化了基本逻辑但提供了非常灵活的 chart.js 对象。
## 安装
如果你正在使用 Vue.js 2.x 的版本,只需要运行:
`yarn add vue-chartjs chart.js`
如果你正在使用 Vue.js 1.x 的版本,请使用 `legacy` 标签。然而这个版本已经不再维护了。
`yarn add vue-chartjs@legacy`
## 快速开始
你需要引入基本图表并且扩展它。这在处理不同的数据时提供了更多的灵活性。
你可以封装您的组件,并使用 props 来传递数据。或者直接将数据放入组件中,但是这样做组件就不能复用了。
你可以加载整个包或者按需加载。
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
mounted () {
// Overwriting base render method with actual data.
this.renderChart(data, options)
}
})
```
你可以给 `renderChart()` 方法传递两个参数:
- Data object
- Options object
### 数据对象
数据对象如下所示:
```javascript
{
labels: ['January', 'February'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
```
详细信息请查阅 [Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data) 的文档。
## 属性
基本图表中定义了一些属性。因为你 `extend()` 了它们,他们使用 *初始值*,但是你可以覆盖它们:
| 属性 | 说明 |
|---|---|
| width | 图表宽度 |
| height | 图表高度 |
| chart-id | canvas的id |
## 实例
下面是一些实例。
### 图表和属性
你可以创建数据和选项传递给图表。
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
```
然后你可以把它作为组件使用。
```html
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
```
如果你想要覆盖宽度和高度:
```html
<line-chart
:data="{your data object}"
:options="{responsive: false, maintainAspectRatio: false}"
:width="400"
:height="200"
>
</line-chart>
```
<p class="warning">
请注意,你必须设置 `responsive: false` 才可以使用 `width``height`
</p>
### 使用本地数据创建图表
```javascript
import {Bar} from 'vue-chartjs'
export default Bar.extend({
data () {
return {
datacollection: {
labels: ['January', 'February'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
})
```
### 可复用的组件
如果你希望你的组件可以复用,那么你最好封装它们。这样图表组件只是负责显示你封装的数据。单页应用和集成到 laravel 中有不同的使用方式。
## 动态数据
Chart.js 并不提供实时更新,然而 `vue-chartjs` 提供了两种方式。
- `reactiveProp`
- `reactiveData`
两种方式其实是一样的。多部分情况会使用 `reactiveProp`。它扩展了图表逻辑并且自动添加 `chartData` props 和 `vue watch`。当数据改变,它将会调用 `update()`。当添加了新的数据集,将会调用 `renderChart()`
`reactiveData` 只是创建了本地变量并且添加到 watcher而不是 prop他只用在你创建单一图表并且在组件创建 api 的时候。
```javascript
data () {
return {
chartData: null
}
}
```
### 实例
**LineChart.js**
```javascript
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
mixins: [reactiveProp],
props: ['options'],
mounted () {
// this.chartData is created in the mixin
this.renderChart(this.chartData, this.options)
}
})
```
**RandomChart.vue**
```javascript
<template>
<div class="small">
<line-chart :chart-data="datacollection"></line-chart>
<button @click="fillData()">Randomize</button>
</div>
</template>
<script>
import LineChart from './LineChart.js'
export default {
components: {
LineChart
},
data () {
return {
datacollection: null
}
},
mounted () {
this.fillData()
},
methods: {
fillData () {
this.datacollection = {
labels: [this.getRandomInt(), this.getRandomInt()],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}, {
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt()]
}
]
}
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
}
</script>
<style>
.small {
max-width: 600px;
margin: 150px auto;
}
</style>
```
<p class="warning">
⚠ 注意:如果在父组件中修改数据并将数据传递给子图表组件时,请注意 JavaScript 的限制。
更多信息请查阅 [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
</p>
### 限制
<ul>
<li>[Caveats](https://vuejs.org/v2/guide/list.html#Caveats)</li>
<li>[Change-Detection-Caveats](https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats)</li>
<li>[vm.$watch](https://vuejs.org/v2/api/#vm-watch)</li>
</ul>
## Chart.js 对象
有时你需要更多的调整 chart.js。你可以访问 `this._chart` 实例。
## 内联插件
在 Chart.js 你可以定义全局和内联插件。全局插件在 `vue-chartjs` 中没有问题,参照 [chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html) 的说明。
如果你想添加内联插件 `vue-chartjs` 提供了一个方法 `addPlugin()`
你必须在 `renderChart()` 之前调用 `addPlugin()` 方法。
### 实例
```javascript
mounted () {
this.addPlugin({
id: 'my-plugin',
beforeInit: function (chart) {
....
}
})
}
```
## 支持的图表
### 柱状图
<p class="tip">
柱状图有两个版本。 `{Bar}``{HorizontalBar}`
</p>
![Bar](assets/bar.png)
### 折线图
![Line](assets/line.png)
### 环形图
![Doughnut](assets/doughnut.png)
### 饼图
![Pie](assets/pie.png)
### 雷达图
![Pie](assets/radar.png)
### 极坐标
![Pie](assets/polar.png)
### 热点图
![Bubble](assets/bubble.png)
### 散点图
这个图表有不同的数据结构。目前动态数据不适用于此图表类型。
![Scatter](assets/scatter.png)
## 不同构建工具的说明
有三种不同的切入点,取决于你用哪种构建工具。作为 dependencies 或者 peerDependency。
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Bundled | Bundled |
| vue-chartjs.full.min.js | Bundled | Bundled |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### 浏览器
你可以在浏览中直接使用 `vue-chartjs`。像是 [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010) 这种情况,请使用 `vue-chartjs.full.min.js` 捆绑版本。他将 Vue.js 和 Chart.js 绑定在了一起,你只需要一个文件。
### Browserify / Webpack 1
如果你使用 Gulp, Browserify 或者 Webpack 1`vue-chartjs.js` 被捆绑到 UMD 模块。
然而 Vue.js 和 Chart.js 是 `peerDependencies` 所以你需要独立安装它们。 大部分情况下你已经安装了 `Vue.js`,你可以使用不同版本的 Vue.js 和 Chart.js。
### Webpack 2
如果你使用 Webpack 2 它将自动使用 `jsnext:main` / `module` 入口。
像捆绑版本一样,`Vue.js``Chart.js` 都是 `peerDependencies`,需要安装。
## 资源
你可以在这里找到一些如何使用 `vue-chartjs` 的资源。
- [Using vue-chartjs with WordPress](https://medium.com/@apertureless/wordpress-vue-and-chart-js-6b61493e289f)
- [Create stunning Charts with Vue and Chart.js](https://hackernoon.com/creating-stunning-charts-with-vue-js-and-chart-js-28af584adc0a)
- [Lets Build a Web App with Vue, Chart.js and an API Part I](https://hackernoon.com/lets-build-a-web-app-with-vue-chart-js-and-an-api-544eb81c4b44)
- [Lets Build a Web App with Vue, Chart.js and an API Part II](https://hackernoon.com/lets-build-a-web-app-with-vue-chart-js-and-an-api-part-ii-39781b1d5acf)
- [Build a realtime chart with VueJS and Pusher](https://blog.pusher.com/build-realtime-chart-with-vuejs-pusher/)

View File

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

View File

@@ -1,34 +1,12 @@
{
"name": "vue-chartjs",
"version": "2.8.2",
"description": "vue.js wrapper for chart.js",
"author": "Jakub Juszczak <jakub@posteo.de>",
"homepage": "http://vue-chartjs.org",
"license": "MIT",
"contributors": [
{
"name": "Thorsten Lünborg",
"web": "https://github.com/LinusBorg"
},
{
"name": "Juan Carlos Alonso",
"web": "https://github.com/jcalonso"
}
],
"maintainers": [
{
"name": "Jakub Juszczak",
"email": "jakub@posteo.de",
"web": "http://www.jakubjuszczak.de"
}
],
"version": "1.2.0",
"description": "Vue wrapper for chart.js",
"author": "Jakub Juszczak <jakub@nextindex.de>",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:apertureless/vue-chartjs.git"
},
"bugs": {
"url": "https://github.com/apertureless/vue-chartjs/issues"
},
"keywords": [
"ChartJs",
"Vue",
@@ -37,116 +15,77 @@
"Charts"
],
"main": "dist/vue-chartjs.js",
"unpkg": "dist/vue-chartjs.full.min.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"files": [
"src",
"dist",
"es"
"dist"
],
"scripts": {
"dev": "node build/dev-server.js",
"build": "yarn run release && yarn run build:es",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"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",
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
"release": "webpack --progress --hide-modules --config ./build/webpack.release.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js && webpack --progress --hide-modules --config ./build/webpack.release.full.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.full.min.js",
"prepublish": "yarn run lint && yarn run test && yarn run build"
"lint": "eslint --ext .js,.vue src test/unit/specs",
"prepublish": "node build/build.js"
},
"dependencies": {
"lodash": "^4.17.4"
},
"peerDependencies": {
"babel-runtime": "^6.0.0",
"chart.js": "^2.6.0",
"vue": "^2.4.2"
"vue": "^1.0.21"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-loader": "^7.0.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-runtime": "^6.23.0",
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"chai": "^3.5.0",
"chart.js": "^2.6.0",
"chromedriver": "^2.28.0",
"chromedriver": "^2.21.2",
"connect-history-api-fallback": "^1.1.0",
"cross-env": "^3.2.4",
"cross-spawn": "^5.1.0",
"css-loader": "^0.28.0",
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^2.0.7",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^2.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"cross-spawn": "^2.1.5",
"css-loader": "^0.23.0",
"eslint": "^2.10.2",
"eslint-config-standard": "^5.1.0",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.3.0",
"eslint-plugin-html": "^1.3.0",
"eslint-plugin-promise": "^1.0.8",
"eslint-plugin-standard": "^1.3.2",
"eventsource-polyfill": "^0.9.6",
"express": "^4.15.2",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.10.1",
"file-loader": "^0.8.4",
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.4",
"inject-loader": "^3.0.0",
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.12.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"jasmine-core": "^2.5.2",
"json-loader": "^0.5.4",
"karma": "^1.5.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma": "^0.13.15",
"karma-coverage": "^0.5.5",
"karma-mocha": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon-chai": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.30",
"karma-webpack": "1.8.1",
"lolex": "^1.6.0",
"mocha": "^3.1.0",
"nightwatch": "^0.9.14",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.13",
"selenium-server": "^3.3.1",
"shelljs": "^0.7.7",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"url-loader": "^0.5.8",
"vue": "^2.4.2",
"vue-hot-reload-api": "^2.1.0",
"vue-html-loader": "^1.2.4",
"vue-loader": "^12.2.2",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.4.2",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.10.1",
"webpack-hot-middleware": "^2.17.1",
"webpack-merge": "1.1.1"
},
"engines": {
"node": ">=6.9.0"
},
"babel": {
"presets": [
"es2015"
]
},
"browserify": {
"transform": [
"babelify"
]
},
"greenkeeper": {
"ignore": [
"extract-text-webpack-plugin",
"karma-webpack",
"webpack",
"webpack-merge"
]
"karma-spec-reporter": "0.0.24",
"karma-webpack": "^1.7.0",
"lodash": "^4.15.0",
"lolex": "^1.4.0",
"mocha": "^2.4.5",
"nightwatch": "^0.8.18",
"ora": "^0.2.0",
"phantomjs-prebuilt": "^2.1.3",
"selenium-server": "2.53.0",
"shelljs": "^0.6.0",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.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-style-loader": "^1.0.0",
"webpack": "^1.12.2",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0",
"webpack-merge": "^0.8.3"
}
}

View File

@@ -3,26 +3,12 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width="{{width}}" height="{{height}}" v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
default: 'bar-chart',
@@ -35,22 +21,9 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
@@ -71,25 +44,22 @@ export default Vue.extend({
barPercentage: 0.2
}]
}
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'bar',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,63 +21,28 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
},
gridLines: {
display: false
}
}],
xAxes: [ {
gridLines: {
display: false
},
categoryPercentage: 0.5,
barPercentage: 0.2
}]
}
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'bubble',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,46 +21,28 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'doughnut',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -1,102 +0,0 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
props: {
chartId: {
default: 'horizontalbar-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
},
gridLines: {
display: false
}
}],
xAxes: [ {
gridLines: {
display: false
},
categoryPercentage: 0.5,
barPercentage: 0.2
}]
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options, type) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'horizontalBar',
data: data,
options: chartOptions,
plugins: this.plugins
}
)
}
},
beforeDestroy () {
if (this._chart) {
this._chart.destroy()
}
}
})

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,20 +21,6 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
@@ -71,26 +42,22 @@ export default Vue.extend({
}
}]
}
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'line',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,46 +21,28 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'pie',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,46 +21,28 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'polarArea',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,46 +21,28 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
data () {
return {
defaultOptions: {
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'radar',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -3,26 +3,11 @@ import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
render: function (createElement) {
return createElement(
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
}
)
]
)
},
template: `
<div>
<canvas id="{{chartId}}" width={{width}} height={{height}} v-el:canvas></canvas>
</div>
`,
props: {
chartId: {
@@ -36,20 +21,6 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object,
default () {
return {
width: '100%',
height: '100%',
position: 'relative'
}
}
}
},
@@ -62,26 +33,22 @@ export default Vue.extend({
position: 'bottom'
}]
}
},
plugins: []
}
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
render (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
this.$els.canvas.getContext('2d'), {
type: 'scatter',
data: data,
options: chartOptions,
plugins: this.plugins
options: chartOptions
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {

View File

@@ -1,54 +1,12 @@
<template>
<div class="container">
<div class="Chart">
<h1 style="text-align:center;">Barchart</h1>
<bar-example></bar-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Barchart with reactive mixing for live data</h1>
<reactive-example></reactive-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Barchart with reactive mixing for live data as props</h1>
<reactive-prop-example :chart-data="dataPoints"></reactive-prop-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Linechart</h1>
<line-example></line-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Doughnutchart</h1>
<doughnut-example></doughnut-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Piechart</h1>
<pie-example></pie-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Radarchart</h1>
<radar-example></radar-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Polararea</h1>
<polar-area-example></polar-area-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Bubblechart</h1>
<bubble-example></bubble-example>
</div>
<div class="Chart">
<h1 style="text-align:center;">Scatter Chart</h1>
<scatter-example></scatter-example>
</div>
<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>
@@ -60,9 +18,6 @@
import RadarExample from './RadarExample'
import PolarAreaExample from './PolarAreaExample'
import BubbleExample from './BubbleExample'
import ReactiveExample from './ReactiveExample'
import ReactivePropExample from './ReactivePropExample'
import ScatterExample from './ScatterExample'
export default {
components: {
@@ -72,49 +27,7 @@
PieExample,
RadarExample,
PolarAreaExample,
BubbleExample,
ReactiveExample,
ReactivePropExample,
ScatterExample
},
data () {
return {
dataPoints: null,
height: 20
}
},
mounted () {
setInterval(() => {
this.fillData()
}, 2000)
},
methods: {
increaseHeight () {
this.height += 10
},
getRandomInt () {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
},
fillData () {
this.dataPoints = {
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()]
}
]
}
}
},
computed: {
myStyles () {
return {
height: `${this.height}px`,
position: 'relative'
}
}
BubbleExample
}
}
</script>
@@ -124,21 +37,4 @@
max-width: 800px;
margin: 0 auto;
}
h1 {
font-family: 'Helvetica', Arial;
color: #464646;
text-transform: uppercase;
border-bottom: 1px solid #f1f1f1;
padding-bottom: 15px;
font-size: 28px;
margin-top: 0;
}
.Chart {
padding: 20px;
box-shadow: 0px 0px 20px 2px rgba(0, 0, 0, .4);
border-radius: 20px;
margin: 50px 0;
}
</style>

View File

@@ -1,8 +1,8 @@
import BarChart from '../BaseCharts/Bar'
export default BarChart.extend({
mounted () {
this.renderChart({
ready () {
this.render({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{

View File

@@ -1,8 +1,8 @@
import BubbleChart from '../BaseCharts/Bubble'
export default BubbleChart.extend({
mounted () {
this.renderChart({
ready () {
this.render({
datasets: [
{
label: 'Data One',
@@ -47,6 +47,6 @@ export default BubbleChart.extend({
]
}
]
}, {responsive: true, maintainAspectRatio: false})
})
}
})

View File

@@ -1,8 +1,8 @@
import DoughnutChart from '../BaseCharts/Doughnut'
export default DoughnutChart.extend({
mounted () {
this.renderChart({
ready () {
this.render({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
datasets: [
{
@@ -15,6 +15,6 @@ export default DoughnutChart.extend({
data: [40, 20, 80, 10]
}
]
}, {responsive: true, maintainAspectRatio: false})
})
}
})

View File

@@ -1,16 +0,0 @@
import HorizontalBarChart from '../BaseCharts/HorizontalBar'
export default HorizontalBarChart.extend({
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
}, {responsive: true, maintainAspectRatio: false})
}
})

View File

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

View File

@@ -1,8 +1,8 @@
import PieChart from '../BaseCharts/Pie'
export default PieChart.extend({
mounted () {
this.renderChart({
ready () {
this.render({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
datasets: [
{
@@ -15,6 +15,6 @@ export default PieChart.extend({
data: [40, 20, 80, 10]
}
]
}, {responsive: true, maintainAspectRatio: false})
})
}
})

View File

@@ -1,8 +1,8 @@
import PolarAreaChart from '../BaseCharts/PolarArea'
export default PolarAreaChart.extend({
mounted () {
this.renderChart({
ready () {
this.render({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
datasets: [
{
@@ -24,6 +24,6 @@ export default PolarAreaChart.extend({
data: [28, 48, 40, 19, 96, 27, 100]
}
]
}, {responsive: true, maintainAspectRatio: false})
})
}
})

View File

@@ -1,8 +1,8 @@
import RadarChart from '../BaseCharts/Radar'
export default RadarChart.extend({
mounted () {
this.renderChart({
ready () {
this.render({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
datasets: [
{
@@ -26,6 +26,6 @@ export default RadarChart.extend({
data: [28, 48, 40, 19, 96, 27, 100]
}
]
}, {responsive: true, maintainAspectRatio: false})
})
}
})

View File

@@ -1,41 +0,0 @@
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, {responsive: true, maintainAspectRatio: false})
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

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

View File

@@ -1,52 +0,0 @@
import Scatter from '../BaseCharts/Scatter'
export default Scatter.extend({
mounted () {
this.renderChart({
datasets: [{
label: 'Scatter Dataset 1',
fill: false,
borderColor: '#f87979',
backgroundColor: '#f87979',
data: [{
x: -2,
y: 4
}, {
x: -1,
y: 1
}, {
x: 0,
y: 0
}, {
x: 1,
y: 1
}, {
x: 2,
y: 4
}]
},
{
label: 'Scatter Dataset 2',
fill: false,
borderColor: '#7acbf9',
backgroundColor: '#7acbf9',
data: [{
x: -2,
y: -4
}, {
x: -1,
y: -1
}, {
x: 0,
y: 1
}, {
x: 1,
y: -1
}, {
x: 2,
y: -4
}]
}]
}, {responsive: true, maintainAspectRatio: false})
}
})

View File

@@ -1,5 +1,4 @@
import Bar from './BaseCharts/Bar'
import HorizontalBar from './BaseCharts/HorizontalBar'
import Doughnut from './BaseCharts/Doughnut'
import Line from './BaseCharts/Line'
import Pie from './BaseCharts/Pie'
@@ -7,35 +6,16 @@ import PolarArea from './BaseCharts/PolarArea'
import Radar from './BaseCharts/Radar'
import Bubble from './BaseCharts/Bubble'
import Scatter from './BaseCharts/Scatter'
import mixins from './mixins/index.js'
import npmCfg from '../package.json'
const VueCharts = {
version: npmCfg.version,
Bar,
HorizontalBar,
Doughnut,
Line,
Pie,
PolarArea,
Radar,
Bubble,
Scatter,
mixins
Scatter
}
export default VueCharts
export {
VueCharts,
Bar,
HorizontalBar,
Doughnut,
Line,
Pie,
PolarArea,
Radar,
Bubble,
Scatter,
mixins
}
module.exports = VueCharts

View File

@@ -1,9 +0,0 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './examples/App'
/* eslint-disable no-new */
new Vue({
render: h => h(App)
}).$mount('#app')

View File

@@ -1,7 +0,0 @@
import reactiveData from './reactiveData.js'
import reactiveProp from './reactiveProp.js'
export default {
reactiveData,
reactiveProp
}

View File

@@ -1,71 +0,0 @@
module.exports = {
data () {
return {
chartData: null
}
},
watch: {
'chartData': {
handler (newData, oldData) {
if (oldData) {
let chart = this._chart
// Get new and old DataSet Labels
let newDatasetLabels = newData.datasets.map((dataset) => {
return dataset.label
})
let oldDatasetLabels = oldData.datasets.map((dataset) => {
return dataset.label
})
// Stringify 'em for easier compare
const oldLabels = JSON.stringify(oldDatasetLabels)
const newLabels = JSON.stringify(newDatasetLabels)
// Check if Labels are equal and if dataset length is equal
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
newData.datasets.forEach((dataset, i) => {
// Get new and old dataset keys
const oldDatasetKeys = Object.keys(oldData.datasets[i])
const newDatasetKeys = Object.keys(dataset)
// Get keys that aren't present in the new data
const deletionKeys = oldDatasetKeys.filter((key) => {
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1
})
// Remove outdated key-value pairs
deletionKeys.forEach((deletionKey) => {
delete chart.data.datasets[i][deletionKey]
})
// Update attributes individually to avoid re-rendering the entire chart
for (const attribute in dataset) {
if (dataset.hasOwnProperty(attribute)) {
chart.data.datasets[i][attribute] = dataset[attribute]
}
}
})
if (newData.hasOwnProperty('labels')) {
chart.data.labels = newData.labels
}
if (newData.hasOwnProperty('xLabels')) {
chart.data.xLabels = newData.xLabels
}
if (newData.hasOwnProperty('yLabels')) {
chart.data.yLabels = newData.yLabels
}
chart.update()
} else {
chart.destroy()
this.renderChart(this.chartData, this.options)
}
} else {
this.renderChart(this.chartData, this.options)
}
}
}
}
}

View File

@@ -1,71 +0,0 @@
module.exports = {
props: {
chartData: {
required: true
}
},
watch: {
'chartData': {
handler (newData, oldData) {
if (oldData) {
let chart = this._chart
// Get new and old DataSet Labels
let newDatasetLabels = newData.datasets.map((dataset) => {
return dataset.label
})
let oldDatasetLabels = oldData.datasets.map((dataset) => {
return dataset.label
})
// Stringify 'em for easier compare
const oldLabels = JSON.stringify(oldDatasetLabels)
const newLabels = JSON.stringify(newDatasetLabels)
// Check if Labels are equal and if dataset length is equal
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
newData.datasets.forEach((dataset, i) => {
// Get new and old dataset keys
const oldDatasetKeys = Object.keys(oldData.datasets[i])
const newDatasetKeys = Object.keys(dataset)
// Get keys that aren't present in the new data
const deletionKeys = oldDatasetKeys.filter((key) => {
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1
})
// Remove outdated key-value pairs
deletionKeys.forEach((deletionKey) => {
delete chart.data.datasets[i][deletionKey]
})
// Update attributes individually to avoid re-rendering the entire chart
for (const attribute in dataset) {
if (dataset.hasOwnProperty(attribute)) {
chart.data.datasets[i][attribute] = dataset[attribute]
}
}
})
if (newData.hasOwnProperty('labels')) {
chart.data.labels = newData.labels
}
if (newData.hasOwnProperty('xLabels')) {
chart.data.xLabels = newData.xLabels
}
if (newData.hasOwnProperty('yLabels')) {
chart.data.yLabels = newData.yLabels
}
chart.update()
} else {
chart.destroy()
this.renderChart(this.chartData, this.options)
}
} else {
this.renderChart(this.chartData, this.options)
}
}
}
}
}

View File

@@ -4,10 +4,6 @@
},
"globals": {
"expect": true,
"jasmine": true,
"sinon": true
},
"rules": {
"no-unused-expressions": 0
}
}

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', 'jasmine'],
frameworks: ['mocha', 'sinon-chai'],
reporters: ['spec', 'coverage'],
files: ['./index.js'],
preprocessors: {

View File

@@ -2,83 +2,16 @@ 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({
render: function (createElement) {
return createElement(
BarChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
BarChart, {
props: {
chartId: 'barchartprop'
}
}
)
},
components: { BarChart }
}).$mount(el)
expect(vm.$el.querySelector('#barchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
BarChart
)
},
components: { BarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.equal
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
BarChart
)
},
components: { BarChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -2,83 +2,16 @@ 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({
render: function (createElement) {
return createElement(
BubbleChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
BubbleChart, {
props: {
chartId: 'bubblechartprop'
}
}
)
},
components: { BubbleChart }
}).$mount(el)
expect(vm.$el.querySelector('#bubblechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
BubbleChart
)
},
components: { BubbleChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
BubbleChart
)
},
components: { BubbleChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -2,83 +2,16 @@ 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({
render: function (createElement) {
return createElement(
DoughnutChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
DoughnutChart, {
props: {
chartId: 'doughnutchartprop'
}
}
)
},
components: { DoughnutChart }
}).$mount(el)
expect(vm.$el.querySelector('#doughnutchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
DoughnutChart
)
},
components: { DoughnutChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
DoughnutChart
)
},
components: { DoughnutChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -1,84 +0,0 @@
import Vue from 'vue'
import HorizontalBarChart from 'src/examples/HorizontalBarExample'
describe('HorizontalBarChart', () => {
let el
beforeEach(() => {
el = document.createElement('div')
})
it('should render a canvas', () => {
const vm = new Vue({
render: function (createElement) {
return createElement(
HorizontalBarChart
)
},
components: { HorizontalBarChart }
}).$mount(el)
expect(vm.$el.querySelector('#horizontalbar-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
it('should change id based on prop', () => {
const vm = new Vue({
render: function (createElement) {
return createElement(
HorizontalBarChart, {
props: {
chartId: 'horizontalbarchartprop'
}
}
)
},
components: { HorizontalBarChart }
}).$mount(el)
expect(vm.$el.querySelector('#horizontalbarchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
HorizontalBarChart
)
},
components: { HorizontalBarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
HorizontalBarChart
)
},
components: { HorizontalBarChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -2,83 +2,16 @@ 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({
render: function (createElement) {
return createElement(
LineChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
LineChart, {
props: {
chartId: 'linechartprop'
}
}
)
},
components: { LineChart }
}).$mount(el)
expect(vm.$el.querySelector('#linechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
LineChart
)
},
components: { LineChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
LineChart
)
},
components: { LineChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -2,82 +2,16 @@ 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({
render: function (createElement) {
return createElement(
PieChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
PieChart, {
props: {
chartId: 'piechartprop'
}
}
)
},
components: { PieChart }
}).$mount(el)
expect(vm.$el.querySelector('#piechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
PieChart
)
},
components: { PieChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
PieChart
)
},
components: { PieChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -2,83 +2,16 @@ 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({
render: function (createElement) {
return createElement(
PolarChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
PolarChart, {
props: {
chartId: 'polarchartprop'
}
}
)
},
components: { PolarChart }
}).$mount(el)
expect(vm.$el.querySelector('#polarchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
PolarChart
)
},
components: { PolarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
PolarChart
)
},
components: { PolarChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -2,82 +2,16 @@ 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({
render: function (createElement) {
return createElement(
RadarChart
)
},
el: 'body',
replace: false,
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({
render: function (createElement) {
return createElement(
RadarChart, {
props: {
chartId: 'rodarchartprop'
}
}
)
},
components: { RadarChart }
}).$mount(el)
expect(vm.$el.querySelector('#rodarchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
RadarChart
)
},
components: { RadarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
RadarChart
)
},
components: { RadarChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

View File

@@ -1,84 +0,0 @@
import Vue from 'vue'
import ScatterChart from 'src/examples/ScatterExample'
describe('ScatterChart', () => {
let el
beforeEach(() => {
el = document.createElement('div')
})
it('should render a canvas', () => {
const vm = new Vue({
render: function (createElement) {
return createElement(
ScatterChart
)
},
components: { ScatterChart }
}).$mount(el)
expect(vm.$el.querySelector('#scatter-chart')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined')
expect(vm.$el.querySelector('canvas')).not.to.be.an('null')
expect(vm.$el.querySelector('canvas')).to.exist
})
it('should change id based on prop', () => {
const vm = new Vue({
render: function (createElement) {
return createElement(
ScatterChart, {
props: {
chartId: 'linechartprop'
}
}
)
},
components: { ScatterChart }
}).$mount(el)
expect(vm.$el.querySelector('#linechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
ScatterChart
)
},
components: { ScatterChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
it('should add an inline plugin to the array', () => {
const testPlugin = {
id: 'test'
}
const vm = new Vue({
render: function (createElement) {
return createElement(
ScatterChart
)
},
components: { ScatterChart }
}).$mount(el)
expect(vm.$children[0].plugins).to.exist
vm.$children[0].addPlugin(testPlugin)
expect(vm.$children[0].plugins.length).to.equal(1)
})
})

2333
yarn.lock

File diff suppressed because it is too large Load Diff