Compare commits

...

198 Commits

Author SHA1 Message Date
Jakub Juszczak
d9e5d5a5f0 💎 Release new version 3.0.2
Fixed unpkg target
2017-11-07 11:03:36 +01:00
Jakub Juszczak
a5f112e952 📝 Update CHANGELOG 2017-11-06 16:28:13 +01:00
Jakub Juszczak
6e24da3c90 💎 Release new version 3.0.1 2017-11-06 16:25:57 +01:00
Jakub
2f0ab67b79 Merge pull request #246 from apertureless/feature/dependency_and_build_fix
Feature/dependency and build fix
2017-11-06 16:14:58 +01:00
Jakub Juszczak
474b58196e 📝 Update README 2017-11-06 16:06:19 +01:00
Jakub Juszczak
d104e628e2 🐛 Fix webpack externals 2017-11-06 15:41:33 +01:00
Jakub Juszczak
b17602d041 🔥 Remove full build with bundled chart.js 2017-11-06 15:40:43 +01:00
Jakub
0b50728b28 Merge pull request #238 from chakan/en-docs-typo-fix
Typo fix in EN docs
2017-10-29 16:45:32 +01:00
Jakub
9abdaa9f66 Merge pull request #227 from kingkong64/develop
update webpack to version 3
2017-10-29 16:37:13 +01:00
Imre Csige
f19c6a4cfa Typo fix in EN docs
Sorry, it was very annoying to me.
2017-10-29 16:35:25 +01:00
Jakub
d2f2374d7d Merge pull request #232 from music-mind/patch-2
Made some small edits to French README.MD
2017-10-29 16:21:21 +01:00
Arri
d11eb27bc1 Made some small edits to French README.MD
Some edits and typo fixes
2017-10-24 02:58:45 -04:00
Chanwit Piromplad
50130a7a4d update webpack to version 3 2017-10-15 20:34:19 +07:00
Jakub
05d69520af Fix table in readme 2017-10-14 16:47:42 +02:00
Jakub Juszczak
b465070a7a 💎 Release new version 3.0.0 2017-10-14 16:30:12 +02:00
Jakub
d498b7c8cf Feature/v3 (#225)
* Remove Vue dependency and change extends

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>

* 💎 Release new version 3.0.0-rc0

* ⬆️ Update examples

* 📝 Update README.md

* ⬆️ Update examples

* ⬆️ Update englishd docs

* ⬆️ Update transalted docs with current code examples

* 🔥 Remove dist files from gitignore

* ⬆️ Update dependencies vue and chartjs

* Change private data

Implements #182. The private chart instance is now in the vue.js data model. And can be accessed over `this.$data._chart`
Updated unit tests

* 📝 Update docs with private data

*  Add codeclimate ignore

* ⬆️ Update codeclimate

* ⬆️ Update codeclimate

* ⬆️ Update codeclimate

Add build and config folders to ignore
2017-10-14 16:27:07 +02:00
Jakub
0fa8261664 Merge pull request #215 from cugu/spelling
✏️ Spelling in docs
2017-10-10 10:31:23 +02:00
Jonas Plum
653b4d7580 Spelling
- Fix some spelling mistakes
- Apply consistent naming for Vue and Chart.js
- Minor text changes
2017-10-10 00:44:26 +02:00
Jakub
8b52bae9c1 Merge pull request #214 from pushkyn/fix-russian-translation
Fix inaccuracies in Russian translation
2017-10-07 17:23:02 +02:00
pushkyn
b8012b9944 Fix inaccuracies in Russian translation 2017-10-07 17:45:56 +03:00
Jakub
4b363b3e29 Merge pull request #213 from tesarwijaya/id-docs
Add id docs readme support
2017-10-05 20:40:58 +02:00
Jakub
b46d193caf Merge pull request #211 from julienc91/french-readme
French translation for README.md
2017-10-05 20:40:15 +02:00
julien
831a70574f Added French doc to config 2017-10-05 19:53:51 +02:00
Tesar Wijaya
a6593910ac add bahasa indonesia docs 2017-10-05 22:51:07 +07:00
julien
892c5ed2ab did not translate the correct file... 2017-10-04 20:28:21 +02:00
julien
3451769a65 French translation for README.md 2017-10-02 22:06:52 +02:00
Jakub
7e5bf7d9bc Add dist files to repo 2017-09-24 18:38:37 +02:00
Jakub Juszczak
58523d6155 💎 Release new version 2.8.7 2017-09-16 13:35:48 +02:00
Jakub Juszczak
b71cd6c2eb Merge branch 'feature/dependencies' into develop
* feature/dependencies:
  Update peerDependencies
  ⬆️ Update dependencies
2017-09-16 12:43:49 +02:00
Jakub Juszczak
3fea6f413b Update peerDependencies 2017-09-16 12:42:08 +02:00
Jakub Juszczak
fcd9071f9a ⬆️ Update dependencies 2017-09-16 12:40:10 +02:00
Jakub Juszczak
37a92813eb 💎 Release new version 2.8.6 2017-09-12 15:45:46 +02:00
Jakub Juszczak
1260b8aa3b 📝 Update CHANGELOG 2017-09-12 10:57:06 +02:00
Jakub Juszczak
644859ce85 v2.8.5 2017-09-12 10:55:34 +02:00
Jakub Juszczak
e4977a6be7 Replace deepmerge with lodash.merge 2017-09-12 10:53:31 +02:00
Jakub Juszczak
41736c840d 📝 Update CHANGELOG 2017-09-08 10:17:16 +02:00
Jakub Juszczak
4c37616d00 v2.8.4 2017-09-08 10:15:31 +02:00
Jakub
5dc655a47a Merge pull request #191 from apertureless/feature/deepmerge
Replace Object.assign with deepmerge
2017-09-08 10:13:47 +02:00
Jakub Juszczak
3d291996f6 🔥 Remove transform-object-assign 2017-09-08 10:02:38 +02:00
Jakub Juszczak
750abb2e88 Add dependency deepmerge 2017-09-08 09:59:37 +02:00
Jakub Juszczak
46569a89cb 📝 Update CHANGELOG 2017-09-06 20:06:15 +02:00
Jakub Juszczak
932b73a1dc 💎 Release new version 2.8.3 2017-09-06 19:57:57 +02:00
Jakub
0569a9f794 Merge pull request #187 from apertureless/feature/fix_styles
🔥 Remove default styles object as it causes problems
2017-09-02 15:28:27 +02:00
Jakub Juszczak
154e284528 🔥 Remove default styles object as it causes problems
This will fix #176

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-09-02 15:11:47 +02:00
Jakub
491625b49b Merge pull request #186 from apertureless/feature/lodash-merge
remvove lodash merge
2017-09-02 14:36:55 +02:00
Jakub Juszczak
d26078f08c 🔥 Remove lodash merge
Replaced with Object.assign()

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-09-02 14:27:48 +02:00
Jakub Juszczak
6de69631b3 Replace lodash with lodash.merge
Single module should be smaller

Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-09-02 13:40:16 +02:00
Jakub Juszczak
82712948e9 📝 Update CHANGELOG
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-08-12 20:16:01 +02:00
Jakub Juszczak
9237fa538f 💎 Release new version 2.8.2
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-08-12 20:13:04 +02:00
Jakub
82c502cf45 Merge pull request #166 from dsbert/patch-1
Add support for xLabels and yLabels
2017-08-09 14:17:48 +02:00
bertolds
676a60a363 fix linting errors 2017-08-07 09:49:46 -04:00
bertolds
f60f87c141 Merge branch 'develop' into patch-1 2017-08-07 09:46:37 -04:00
bertolds
b7f2bf7db2 Merge branch 'patch-1' of https://github.com/dsbert/vue-chartjs into patch-1 2017-08-07 09:46:03 -04:00
bertolds
0e419886b1 Add cross-env to all steps of build script 2017-08-07 09:42:16 -04:00
Dan
f95ea49a19 Merge pull request #1 from apertureless/develop
Bring up to date with origin
2017-08-07 09:41:47 -04:00
Dan
1e392091ea Add support for xLabels and yLabels 2017-08-07 09:41:33 -04:00
Jakub
4bf4f5736c Merge pull request #165 from mikeybeck/patch-1
Update README.md
2017-08-07 10:24:38 +02:00
Mikey Beck
703a91dafa Update README.md 2017-08-07 12:07:18 +12:00
Mikey Beck
d68af61dce Update README.md
Typo
2017-08-07 12:05:01 +12:00
Jakub Juszczak
0fbdcc10b0 💎 Release new version 2.8.1
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-08-05 14:24:28 +02:00
Jakub Juszczak
ab31dfe727 🐛 Fix default height to 100% 2017-08-05 14:23:38 +02:00
Dan
a5b58c3b98 Add support for xLabels and yLabels 2017-08-04 15:06:22 -04:00
Jakub
85fafd9b58 Merge pull request #163 from dood-/feature-ru-translation
Add Russian documentation
2017-08-04 16:41:51 +02:00
Daniel Gurev
54d85da955 Add Russian docs to the config array 2017-08-04 17:31:35 +03:00
Jakub Juszczak
60f87e72ae 💎 Release new version 2.8.0 2017-08-04 09:59:11 +02:00
Jakub Juszczak
896b7ddfa3 🐛 Fix cdn link in readme 2017-08-04 09:58:41 +02:00
Daniel Gurev
6d19370687 Add Russian documentation 2017-08-04 02:31:02 +03:00
Jakub
c9bc36ee59 Merge pull request #162 from apertureless/feature/dynamic_styles
Feature/dynamic styles
2017-08-01 19:19:50 +02:00
Jakub Juszczak
7e52380bd4 Clean up example 2017-07-31 21:46:37 +02:00
Jakub Juszczak
32229fbfdd Add dynamic styles and css classes as prop
You can now pass in css classes as a string for the surrounding div of the canvas and a styles object which will be applied as inline styles.
This way you can have a dynamic height with `reposnive: true`

## Example

```js
<template>
   <line-chart :styles="myStyles"/>
</template>

<script>
export default {
  data () {
    return {
          height: 100
    }
  },
  computed: {
    myStyles () {
      return {
        height: `${this.height}px`,
        position: 'relative'
      }
    }
  }
}
</script>
```
2017-07-31 21:42:48 +02:00
Jakub
e0c771f3d3 Merge pull request #159 from Mooooooon/develop
Add Chinese simplified docs support.
2017-07-31 10:06:48 +02:00
moon
57cff76747 Add Chinese simplified docs support. 2017-07-30 07:00:31 +08:00
Jakub Juszczak
79c138d65a 📝 Update README 2017-07-25 13:01:23 +02:00
Jakub Juszczak
64c6cedd74 📝 Update CHANGELOG 2017-07-22 18:17:59 +02:00
Jakub Juszczak
188ab83989 💎 Release new version 2.7.2 2017-07-22 18:14:09 +02:00
Jakub
d9f53e6ef4 Merge pull request #154 from apertureless/feature/update_peerdependency
⬆️ Update dependency vue to 2.4.2
2017-07-22 18:11:58 +02:00
Jakub Juszczak
7d1dacf77c ⬆️ Update dependency vue to 2.4.2 2017-07-22 18:09:37 +02:00
Jakub
67c01133d0 Merge pull request #153 from clarkdo/develop
Remove useless labels
2017-07-22 17:20:09 +02:00
Clark Du
ab9721b577 remove useless labels 2017-07-22 22:36:05 +08:00
Jakub
71bcafa804 Merge pull request #145 from k-rumi/remove-generate-legend
✏️ Remove generateLegend()  from initialization codes
2017-07-08 18:19:20 +02:00
kutrumi
882bdd86b8 ✏️ Remove generateLegend() from initialization codes 2017-07-08 19:18:20 +09:00
Jakub Juszczak
4f7dda3c3b 💎 Release new version 2.7.1 2017-07-05 21:04:51 +02:00
Jakub Juszczak
f04441ab36 🐛 Fix missing exports 2017-07-05 21:04:10 +02:00
Jakub
acb3d5c823 Merge pull request #141 from k-rumi/fix-image-link-in-doc
Fix links to images in translated documents
2017-07-04 14:42:58 +02:00
kutrumi
92bac84dae Fix links to images in translated documents 2017-07-04 19:05:16 +09:00
Jakub Juszczak
85e946dbe1 📝 Update CHANGELOG 2017-07-04 11:06:06 +02:00
Jakub Juszczak
640ce5c932 💎 Release new version 2.7.0 2017-07-04 11:03:18 +02:00
Jakub
ef77c0d831 Merge pull request #140 from apertureless/feature/update_tests
 Update tests for addPlugin method
2017-07-04 10:47:17 +02:00
Jakub Juszczak
a996049a6b 📝 Update docs with inline-plugin support 2017-07-04 10:44:22 +02:00
Jakub Juszczak
4109fb30f3 Update tests for addPlugin method 2017-07-04 10:31:21 +02:00
Jakub Juszczak
b23ce23015 Merge branch 'develop' of github.com:apertureless/vue-chartjs into develop
* 'develop' of github.com:apertureless/vue-chartjs:
  Fix beforeDestory when renderChart was not called
2017-07-04 10:30:53 +02:00
Jakub Juszczak
7f62914edb Add addPlugin method to scatter chart 2017-07-04 10:30:46 +02:00
Jakub
677c53d9fe Merge pull request #139 from ZhangYiJiang/patch-beforeDestroy
Fix beforeDestory when renderChart was not called
2017-07-04 09:59:24 +02:00
Zhang Yijiang
3e423fd7ae Fix beforeDestory when renderChart was not called 2017-07-04 09:58:52 +08:00
Jakub
362639c4e2 Merge pull request #137 from kurbar/inline-plugins-support
Add support for inline plugins
2017-07-03 10:09:23 +02:00
Karl Viiburg
ef127686cd Add support for inline plugins 2017-07-03 08:12:28 +03:00
Jakub
0a483946bc Merge pull request #136 from apertureless/feature/scatter_chart
Feature/scatter chart
2017-07-02 17:17:42 +02:00
Jakub Juszczak
ba5cedc981 📝 Update README and assets 2017-07-02 17:02:34 +02:00
Jakub Juszczak
9b8e961d1c Add test for scatter chart 2017-07-02 16:40:46 +02:00
Jakub Juszczak
d304a2c5ab Add scatter chart 2017-07-02 16:40:38 +02:00
Jakub Juszczak
80799b7bd5 🐛 Fix reactive-prop example 2017-07-02 16:18:47 +02:00
Jakub Juszczak
9d44758976 📺 Add reactive-prop example 2017-07-02 16:14:03 +02:00
Jakub
e8cbef7fa7 Merge pull request #135 from apertureless/patch/122
🐛 Fix #122 reactive mixin
2017-07-02 16:09:24 +02:00
Jakub
a2b023d226 Merge pull request #133 from apertureless/feature/docs
📝 Add resources & tutorials to docs
2017-07-02 16:03:19 +02:00
Jakub Juszczak
7a048a07df 🐛 Fix #122 reactive mixin
Reactive mixin broke if the initial data was set to null.
2017-07-02 16:02:10 +02:00
Jakub Juszczak
10535095be 📝 Add resources & tutorials to docs 2017-07-02 15:45:44 +02:00
Jakub
0b12e0f8b7 Merge pull request #131 from JobV/patch-1
fix a typo in an example
2017-07-01 14:18:29 +02:00
Job van der Voort
43bada7b15 fix a typo in an example 2017-06-29 20:43:39 +01:00
Jakub
6736715895 Merge pull request #121 from stoykostanchev/patch-1
Update README
2017-06-15 14:34:23 +02:00
Stoyko Stanchev
5d159e7841 Create README.md 2017-06-15 12:04:00 +01:00
Jakub Juszczak
c22bd65a8e 📝 Update changelog 2017-06-10 15:15:12 +02:00
Jakub Juszczak
030ba0c035 💎 Release new version 2.6.5 2017-06-10 15:13:36 +02:00
Jakub Juszczak
ab3321001b ⬆️ Update peerDependencies
vue@2.3.4
chart.js@2.6.0
2017-06-10 15:12:50 +02:00
Jakub Juszczak
0f6e04cd5e 📝 Update CHANGELOG 2017-06-04 15:42:48 +02:00
Jakub Juszczak
cc869c979d 💎 Release new version 2.6.4 2017-06-04 15:40:21 +02:00
Jakub Juszczak
8b6afd1e70 📝 Update README 2017-06-04 15:40:06 +02:00
Jakub
43363fc2ae Merge pull request #109 from MuseofMoose/patch-1
Fix reactive mixins animation re-rendering issue.
2017-06-04 15:06:52 +02:00
Jakub
29d1ca3428 Merge pull request #115 from euledge/fix_typo_in_docs
Fix typo in docs
2017-05-31 10:01:11 +02:00
Hitoshi Kuroyanagi
2e737e9394 Fix typo in docs 2017-05-31 15:56:39 +09:00
Jakub Juszczak
5da4b6165e 🐛 Fix typo in docs #111 2017-05-22 22:16:03 +02:00
Jakub Juszczak
1f522e7fd2 🐛 📝 Update README #112 2017-05-22 22:14:29 +02:00
Jakub Juszczak
8324f2c578 Add pt-br doc to config 2017-05-20 15:00:30 +02:00
Jakub
ac09ae744e Merge pull request #110 from kimuraz/pt-br-readme
📝 Add pt-br readme support
2017-05-20 14:32:02 +02:00
Kimura
39d0b4b95c 📝 Add pt-br readme support 2017-05-20 09:03:06 -03:00
Spencer Dellis
dbce4d7c2c Fixing eslint issues. 2017-05-19 11:11:56 -04:00
Spencer Dellis
d49b06f92a Fixing eslint issues. 2017-05-19 11:11:33 -04:00
Spencer Dellis
5cc8f0a878 Resolve reactivity mixin animation issue.
A small consequence of replacing the entire dataset in the [reactive mixins files](https://github.com/apertureless/vue-chartjs/blob/develop/src/mixins/reactiveData.js) is that it causes charts to completely re-render even if only the 'data' attribute of a dataset is changing. In my case, I set up a reactive doughnut chart with two data points but whenever the data values change, instead of shifting the fill coloring, it completely re-renders the entire chart.

You can see the issue in this fiddle (the problem remains even when changing chart type):
https://jsfiddle.net/sg0c82ev/11/

To solve the issue, I instead run a diff between the new and old dataset keys, remove keys that aren't present in the new data,  and update the rest of the attributes individually. After making these changes my doughnut chart is animating as expected (even when adding and removing new dataset attributes).

A fiddle with my changes:
https://jsfiddle.net/sg0c82ev/12/

Perhaps this is too specific of a scenario to warrant a complexity increase (and better suited for a custom handler) but I figured it would be better to dump it here and make it available for review. Let me know what you think.
2017-05-19 03:16:12 -04:00
Spencer Dellis
b762d400d2 Removing unnecessary line 2017-05-19 03:13:43 -04:00
Spencer Dellis
ceb5988e1c Resolve reactive props animation issue.
A small consequence of replacing the entire dataset in the mixins files is that it causes certain charts to completely re-render even if only the 'data' attribute of a dataset is changing. In my case, I set up a reactive doughnut chart with two data points but whenever the data values change, instead of shifting the fill coloring, it completely re-renders the entire chart.

You can see the issue in this fiddle (note the constant re-rendering):
https://jsfiddle.net/sg0c82ev/11/

To solve the issue, I instead run a diff between the new and old dataset keys, remove keys that aren't present in the new data,  and update the rest of the attributes individually. After making these changes my doughnut chart is animating as expected (even when adding and removing new dataset attributes).

A fiddle with my changes:
https://jsfiddle.net/sg0c82ev/12/

Perhaps this is too specific of a scenario to warrant a complexity increase like this (and better suited for a custom watcher) but I figured it would be better to dump it here and make it available for review. Let me know what you think.
2017-05-19 02:40:29 -04:00
Jakub Juszczak
d60c63edbb 💎 Release new version 2.6.3
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-05-14 12:56:24 +02:00
Jakub Juszczak
da6789d4ba ⬆️ Update dependency vue to 2.3.3 2017-05-14 12:54:44 +02:00
Jakub
9a780d9922 Fix npm downloads badge 2017-05-09 22:33:10 +02:00
Jakub
be6f3956cf Merge pull request #105 from guilherfp/patch-1
Update README.md
2017-05-07 21:26:32 +02:00
Guilherme Freitas Pacheco
aeee51dfc8 Update README.md 2017-05-07 15:33:43 -03:00
Jakub Juszczak
92c05b838c 🐛 📝 Update docs 2017-05-05 19:38:34 +02:00
Jakub Juszczak
4be1e8f9da Add japanese docs to config 2017-05-05 19:35:55 +02:00
Jakub
3e641ce620 Merge pull request #102 from euledge/japanese_translate
translated README.md into Japanese
2017-05-05 19:32:41 +02:00
Hitoshi Kuroyanagi
fae16ff894 translated README.md into Japanese 2017-05-05 21:24:40 +09:00
Jakub Juszczak
c325e573a2 📝 Update readme 2017-05-02 08:39:25 +02:00
Jakub
78c212f116 Merge pull request #100 from extend1994/add-badge
add CDNJS version badge in README.md
2017-05-01 11:33:37 +02:00
LboAnn
3e1b5afe7e add CDNJS version badge in README.md
This badge will show the version on CDNJS!
2017-05-01 11:14:30 +02:00
Jakub Juszczak
47c1543e6c 📝 Update CHANGELOG 2017-04-29 15:30:25 +02:00
Jakub Juszczak
25d3766687 💎 Release new version 2.6.2
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-04-29 15:27:18 +02:00
Jakub
1c1ad3c146 Merge pull request #96 from apertureless/feature/update_dependencies
⬆️ Update dev dependencies
2017-04-29 15:22:48 +02:00
Jakub Juszczak
2791e8ed61 ⬆️ Update dev dependencies 2017-04-29 15:17:45 +02:00
Jakub Juszczak
06cb7e79f6 📝 Update CHANGELOG
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-04-21 16:21:33 +02:00
Jakub Juszczak
6211d034e6 💎 Release new version 2.6.1
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-04-21 16:17:37 +02:00
Jakub Juszczak
f32d989334 🔥 Remove deprecated type argument in barchart
The BarChart got splitted into HorizontalBar and Bar, so the type is not nessasary anymore.
2017-04-21 16:16:31 +02:00
Jakub Juszczak
ba11190e39 📝 Update CHANGELOG 2017-04-09 13:02:53 +02:00
Jakub Juszczak
7234292a49 💎 Release new version 2.6.0
Signed-off-by: Jakub Juszczak <netghost03@gmail.com>
2017-04-09 12:59:49 +02:00
Jakub Juszczak
c91fee9a1a 🐛 Fix tags for docsearch 2017-04-06 11:16:47 +02:00
Jakub Juszczak
7e7e5d0028 Add docsearch plugin from agolia 2017-04-06 11:06:32 +02:00
Jakub Juszczak
2ab4cacf12 🐛 Fix typo 2017-04-05 16:30:11 +02:00
Jakub Juszczak
227f698647 📝 Update DOCS 2017-04-05 16:28:14 +02:00
Jakub Juszczak
8d893eb8b2 📝 Update README 2017-04-05 16:28:08 +02:00
Jakub Juszczak
1b527e9c67 💎 Release new version 2.6.0-rc1 2017-04-05 16:05:20 +02:00
Jakub Juszczak
3103d5acd9 Add browser full build 2017-04-05 16:04:24 +02:00
Jakub Juszczak
2c8d1169e8 Add version to object 2017-04-05 16:04:07 +02:00
Jakub
6ac651e55a Merge pull request #84 from gcoguiec/develop
Update release build to not include externals.
2017-04-05 14:07:40 +02:00
Guillaume Coguiec
129a52e4d7 Restore lodash as a dependency. 2017-04-03 15:19:20 -04:00
Guillaume Coguiec
11015b4080 Remove lodash from externals. 2017-04-03 15:18:23 -04:00
Jakub Juszczak
56edbf2bd4 Add language select and german translation 2017-04-01 20:07:56 +02:00
Jakub Juszczak
77c63d4dd4 ⬆️ Update docute docs 2017-04-01 19:59:25 +02:00
Jakub Juszczak
14cb2f9e62 📝 Update docs 2017-03-30 16:34:41 +02:00
Guillaume Coguiec
9e6b407a1e Update release build to not include externals. 2017-03-29 14:57:26 -04:00
Jakub Juszczak
94dcc0fd0e 💎 Release new version 2.5.6 2017-03-29 17:14:13 +02:00
Jakub Juszczak
cb51f2a187 ⬆️ Update dependencies vue@2.2.6 2017-03-29 17:13:29 +02:00
Jakub Juszczak
770ff26be4 📝 Update CHANGELOG 2017-03-24 17:06:28 +01:00
Jakub Juszczak
13e783c29d 💎 Release new version 2.5.5 2017-03-24 17:03:48 +01:00
Jakub Juszczak
b0b8d88794 🔥 Remove greenkeeper badge 2017-03-24 17:02:50 +01:00
Jakub Juszczak
dc8e198f10 ⬆️ Update dependencies 2017-03-24 17:02:44 +01:00
Jakub Juszczak
348de825bf Add new entry for development 2017-03-22 19:02:49 +01:00
Jakub
87fb35749e Merge pull request #73 from mika76/patch-1
Removed -s flag from yarn command in docs
2017-03-22 15:50:09 +01:00
Mladen Mihajlović
0f697a2bc5 Removed -s flag from yarn command
There is no -s flag (https://github.com/yarnpkg/yarn/issues/2532)
2017-03-22 07:03:48 +02:00
Jakub Juszczak
8c670775f5 Merge branch 'develop'
* develop:
  💎 Release new version 2.5.4
  🔥 Remove browser field from npm
2017-03-19 17:23:03 +01:00
Jakub Juszczak
d6ff509dc0 💎 Release new version 2.5.4 2017-03-19 17:21:45 +01:00
Jakub Juszczak
94ce9f9b96 🔥 Remove browser field from npm 2017-03-19 17:21:17 +01:00
Jakub Juszczak
5fcf1eb79c Merge branch 'develop'
* develop:
  ⬆️ Update dependencies
2017-03-18 15:04:58 +01:00
Jakub Juszczak
50f5aed6d5 ⬆️ Update dependencies 2017-03-18 15:04:29 +01:00
Jakub Juszczak
2573f438ac Merge branch 'develop'
* develop:
  📝 Update CHANGELOG
2017-03-17 17:00:23 +01:00
Jakub Juszczak
a982fde310 📝 Update CHANGELOG 2017-03-17 17:00:11 +01:00
Jakub Juszczak
2894a1d64c Merge branch 'develop'
* develop:
  🐛 Fix badge position
  🐛 Fix lintin
  🐛 Fix dependencies
  docs(readme): add Greenkeeper badge
  chore(package): update dependencies
2017-03-17 16:58:17 +01:00
Jakub Juszczak
a00fd1c7a1 🐛 Fix badge position 2017-03-17 16:57:54 +01:00
Jakub
db3bef1bae Merge pull request #65 from apertureless/greenkeeper/initial
Update dependencies to enable Greenkeeper 🌴
2017-03-17 16:55:51 +01:00
Jakub Juszczak
acc8904c54 🐛 Fix lintin 2017-03-17 16:41:38 +01:00
Jakub Juszczak
e7c1158c25 🐛 Fix dependencies 2017-03-17 16:41:33 +01:00
Jakub Juszczak
8e305d8c46 Merge branch 'develop'
* develop:
  💎 Release new version 2.5.3
   Add browser build
2017-03-17 15:48:32 +01:00
Jakub Juszczak
3fc76050f6 💎 Release new version 2.5.3 2017-03-17 15:48:10 +01:00
Jakub Juszczak
e2a8f3ca3c Add browser build 2017-03-17 15:41:58 +01:00
greenkeeper[bot]
3ecd0c8908 docs(readme): add Greenkeeper badge
https://greenkeeper.io/
2017-03-14 22:12:27 +00:00
greenkeeper[bot]
1c2bf08111 chore(package): update dependencies
https://greenkeeper.io/
2017-03-14 22:12:06 +00:00
Jakub Juszczak
d6a53a6bd6 Merge branch 'develop'
* develop:
  📝 Update CHANGELOG
2017-03-14 13:02:12 +01:00
Jakub Juszczak
6913312be9 📝 Update CHANGELOG 2017-03-14 13:01:58 +01:00
Jakub Juszczak
e0fb6ec8f3 Merge branch 'develop'
* develop:
  💎 Release new version 2.5.2
2017-03-14 13:00:47 +01:00
Jakub Juszczak
2a5512ab9a 💎 Release new version 2.5.2 2017-03-14 12:59:08 +01:00
Jakub
71e032db7d Merge pull request #63 from apertureless/develop
Develop
2017-03-13 13:22:55 +01:00
Jakub
818559f829 Merge pull request #61 from kylestev/patch-1
Fix typo for legacy tag
2017-03-13 13:22:34 +01:00
Kyle Stevenson
374d978577 Fix typo for legacy tag 2017-03-12 22:21:50 -07:00
89 changed files with 21011 additions and 2698 deletions

View File

@@ -1,5 +1,14 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"browsers": [
"last 2 versions"
]
}
}],
"@babel/stage-2"
],
"comments": false
}

18
.codeclimate.yml Normal file
View File

@@ -0,0 +1,18 @@
engines:
eslint:
enabled: true
duplication:
enabled: true
config:
languages:
- javascript:
ratings:
paths:
- "**.js"
exclude_paths:
- "dist/"
- "test/**/*"
- "es/"
- "build/"
- "config/"
- "src/examples/**"

1
.gitignore vendored
View File

@@ -4,5 +4,4 @@ npm-debug.log
selenium-debug.log
test/unit/coverage
test/e2e/reports
dist/
es/

View File

@@ -1,5 +1,394 @@
# Change Log
## [v3.0.1](https://github.com/apertureless/vue-chartjs/tree/v3.0.1) (2017-11-06)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v3.0.0...v3.0.1)
**Closed issues:**
- \[Suggestion\]Loose package dependencies [\#245](https://github.com/apertureless/vue-chartjs/issues/245)
- reactiveData mixin [\#244](https://github.com/apertureless/vue-chartjs/issues/244)
- Customise individual Axis Labels [\#243](https://github.com/apertureless/vue-chartjs/issues/243)
- presets es2015 [\#242](https://github.com/apertureless/vue-chartjs/issues/242)
- Uncaught TypeError: Cannot read property 'transition' of null [\#241](https://github.com/apertureless/vue-chartjs/issues/241)
- Is it possible to create an callback on the onAnimationComplete option [\#240](https://github.com/apertureless/vue-chartjs/issues/240)
- When resizing window, chart returns to first loaded state [\#239](https://github.com/apertureless/vue-chartjs/issues/239)
- Reactively change chart properties [\#237](https://github.com/apertureless/vue-chartjs/issues/237)
- how to enforce the max value on y axis [\#236](https://github.com/apertureless/vue-chartjs/issues/236)
- Chart is not rendered when maintainAspectRatio is set to false and chart container is hidden [\#235](https://github.com/apertureless/vue-chartjs/issues/235)
- How to access Chart.defaults.global [\#234](https://github.com/apertureless/vue-chartjs/issues/234)
- Blank Chart - no data [\#233](https://github.com/apertureless/vue-chartjs/issues/233)
- Maxin with multiple chartData [\#231](https://github.com/apertureless/vue-chartjs/issues/231)
- How to destroy chart before re-rendering? [\#230](https://github.com/apertureless/vue-chartjs/issues/230)
- chnage gridlines color [\#228](https://github.com/apertureless/vue-chartjs/issues/228)
- Stacked bar chart? [\#226](https://github.com/apertureless/vue-chartjs/issues/226)
- Chart crashes when reentering page [\#223](https://github.com/apertureless/vue-chartjs/issues/223)
- 在图表上左右滑动会出现数据错乱的问题 [\#222](https://github.com/apertureless/vue-chartjs/issues/222)
- How do I set the scale of the Y axis? [\#220](https://github.com/apertureless/vue-chartjs/issues/220)
- Upgrading from 2.8.2 to 2.8.3 breaks charts [\#209](https://github.com/apertureless/vue-chartjs/issues/209)
- How to scale the radius property of each bubble in a vue-chartjs bubble chart [\#205](https://github.com/apertureless/vue-chartjs/issues/205)
- Last release is causing problems with Firefox [\#203](https://github.com/apertureless/vue-chartjs/issues/203)
- 🔥 Remove Vue.extend\(\) [\#201](https://github.com/apertureless/vue-chartjs/issues/201)
- Update to webpack@3 [\#134](https://github.com/apertureless/vue-chartjs/issues/134)
**Merged pull requests:**
- Feature/dependency and build fix [\#246](https://github.com/apertureless/vue-chartjs/pull/246) ([apertureless](https://github.com/apertureless))
- Typo fix in EN docs [\#238](https://github.com/apertureless/vue-chartjs/pull/238) ([chakan](https://github.com/chakan))
- Made some small edits to French README.MD [\#232](https://github.com/apertureless/vue-chartjs/pull/232) ([music-mind](https://github.com/music-mind))
- update webpack to version 3 [\#227](https://github.com/apertureless/vue-chartjs/pull/227) ([kingkong64](https://github.com/kingkong64))
## [v3.0.0](https://github.com/apertureless/vue-chartjs/tree/v3.0.0) (2017-10-14)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.7...v3.0.0)
**Closed issues:**
- Create an image of the chart to download [\#219](https://github.com/apertureless/vue-chartjs/issues/219)
- How to achieve this effect? [\#218](https://github.com/apertureless/vue-chartjs/issues/218)
- Some Error [\#217](https://github.com/apertureless/vue-chartjs/issues/217)
- Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "chartData" [\#216](https://github.com/apertureless/vue-chartjs/issues/216)
- can't get legendCallback to fire at all [\#212](https://github.com/apertureless/vue-chartjs/issues/212)
- this demo is not support, is it because version older? [\#210](https://github.com/apertureless/vue-chartjs/issues/210)
- how to change value without reload?? [\#208](https://github.com/apertureless/vue-chartjs/issues/208)
- typescript definition? [\#207](https://github.com/apertureless/vue-chartjs/issues/207)
- 使用动态数据时报错 [\#204](https://github.com/apertureless/vue-chartjs/issues/204)
- Commit the final dist js files to github [\#202](https://github.com/apertureless/vue-chartjs/issues/202)
- \[Best Practices❓\] Usage of Private Data [\#182](https://github.com/apertureless/vue-chartjs/issues/182)
- 📝 Update docs & examples - SSR with nuxt [\#172](https://github.com/apertureless/vue-chartjs/issues/172)
- 📝 Update Docs - Section about extending [\#171](https://github.com/apertureless/vue-chartjs/issues/171)
- Register vue-chartjs as vue-plugin? [\#168](https://github.com/apertureless/vue-chartjs/issues/168)
- Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders [\#151](https://github.com/apertureless/vue-chartjs/issues/151)
**Merged pull requests:**
- Feature/v3 [\#225](https://github.com/apertureless/vue-chartjs/pull/225) ([apertureless](https://github.com/apertureless))
- ✏️ Spelling in docs [\#215](https://github.com/apertureless/vue-chartjs/pull/215) ([cugu](https://github.com/cugu))
- Fix inaccuracies in Russian translation [\#214](https://github.com/apertureless/vue-chartjs/pull/214) ([pushkyn](https://github.com/pushkyn))
- Add id docs readme support [\#213](https://github.com/apertureless/vue-chartjs/pull/213) ([tesarwijaya](https://github.com/tesarwijaya))
- French translation for README.md [\#211](https://github.com/apertureless/vue-chartjs/pull/211) ([julienc91](https://github.com/julienc91))
## [v2.8.7](https://github.com/apertureless/vue-chartjs/tree/v2.8.7) (2017-09-16)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.6...v2.8.7)
**Closed issues:**
- 真机和浏览器呈现的效果不一样的问题 [\#199](https://github.com/apertureless/vue-chartjs/issues/199)
- can not use npm install? [\#198](https://github.com/apertureless/vue-chartjs/issues/198)
- Reactive Props - Max Call Stack Exceeded Error [\#197](https://github.com/apertureless/vue-chartjs/issues/197)
- Unmet Peer Dependency [\#196](https://github.com/apertureless/vue-chartjs/issues/196)
- Is there a way to update options? [\#195](https://github.com/apertureless/vue-chartjs/issues/195)
- deepmerge [\#194](https://github.com/apertureless/vue-chartjs/issues/194)
- TypeError: Cannot convert undefined or null to object [\#193](https://github.com/apertureless/vue-chartjs/issues/193)
## [v2.8.6](https://github.com/apertureless/vue-chartjs/tree/v2.8.6) (2017-09-12)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.5...v2.8.6)
## [v2.8.5](https://github.com/apertureless/vue-chartjs/tree/v2.8.5) (2017-09-12)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.4...v2.8.5)
**Closed issues:**
- Chart error since the addition of deepmerge in build 2.8.4 [\#192](https://github.com/apertureless/vue-chartjs/issues/192)
## [v2.8.4](https://github.com/apertureless/vue-chartjs/tree/v2.8.4) (2017-09-08)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.3...v2.8.4)
**Closed issues:**
- Regression in 2.8.3 [\#190](https://github.com/apertureless/vue-chartjs/issues/190)
- Why default Chart.js styles are overridden? [\#189](https://github.com/apertureless/vue-chartjs/issues/189)
- Legend or other options not working in reactiveProps [\#188](https://github.com/apertureless/vue-chartjs/issues/188)
- Changes to yAxisID property does not re-render chart [\#177](https://github.com/apertureless/vue-chartjs/issues/177)
**Merged pull requests:**
- Replace Object.assign with deepmerge [\#191](https://github.com/apertureless/vue-chartjs/pull/191) ([apertureless](https://github.com/apertureless))
## [v2.8.3](https://github.com/apertureless/vue-chartjs/tree/v2.8.3) (2017-09-06)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.2...v2.8.3)
**Closed issues:**
- Rounded corner for Bar chart [\#185](https://github.com/apertureless/vue-chartjs/issues/185)
- Access canvas object from parents [\#184](https://github.com/apertureless/vue-chartjs/issues/184)
- Issue with DonutChart in Safari [\#183](https://github.com/apertureless/vue-chartjs/issues/183)
- Responsive Width, Fixed Height [\#180](https://github.com/apertureless/vue-chartjs/issues/180)
- Entire Lodash Library Is Loaded!! 200kb chunk! [\#179](https://github.com/apertureless/vue-chartjs/issues/179)
- height changed unexpectedly after re-rendering [\#178](https://github.com/apertureless/vue-chartjs/issues/178)
- Default height no longer working in 2.8 [\#176](https://github.com/apertureless/vue-chartjs/issues/176)
- how to get click on point in bar chart? [\#175](https://github.com/apertureless/vue-chartjs/issues/175)
- clean install of from npm cannot be used in gulp / browserify [\#174](https://github.com/apertureless/vue-chartjs/issues/174)
- tooltip callbacks possible? [\#173](https://github.com/apertureless/vue-chartjs/issues/173)
- Computed object won't populate chart [\#170](https://github.com/apertureless/vue-chartjs/issues/170)
- Error in nextTick: "RangeError: Maximum call stack size exceeded" [\#169](https://github.com/apertureless/vue-chartjs/issues/169)
- Standalone chartjs build \(don't include moment.js\) [\#124](https://github.com/apertureless/vue-chartjs/issues/124)
**Merged pull requests:**
- 🔥 Remove default styles object as it causes problems [\#187](https://github.com/apertureless/vue-chartjs/pull/187) ([apertureless](https://github.com/apertureless))
- remvove lodash merge [\#186](https://github.com/apertureless/vue-chartjs/pull/186) ([apertureless](https://github.com/apertureless))
## [v2.8.2](https://github.com/apertureless/vue-chartjs/tree/v2.8.2) (2017-08-12)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.1...v2.8.2)
**Closed issues:**
- UNMET PEER DEPENDENCY [\#167](https://github.com/apertureless/vue-chartjs/issues/167)
- Base Charts' height: 200% [\#164](https://github.com/apertureless/vue-chartjs/issues/164)
**Merged pull requests:**
- Add support for xLabels and yLabels [\#166](https://github.com/apertureless/vue-chartjs/pull/166) ([dsbert](https://github.com/dsbert))
- Update README.md [\#165](https://github.com/apertureless/vue-chartjs/pull/165) ([mikeybeck](https://github.com/mikeybeck))
## [v2.8.1](https://github.com/apertureless/vue-chartjs/tree/v2.8.1) (2017-08-05)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.8.0...v2.8.1)
**Merged pull requests:**
- Add Russian documentation [\#163](https://github.com/apertureless/vue-chartjs/pull/163) ([dood-](https://github.com/dood-))
## [v2.8.0](https://github.com/apertureless/vue-chartjs/tree/v2.8.0) (2017-08-04)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v1.2.0...v2.8.0)
**Closed issues:**
- Update README CDN link [\#161](https://github.com/apertureless/vue-chartjs/issues/161)
- Options being ignored [\#160](https://github.com/apertureless/vue-chartjs/issues/160)
- Fails to dynamically change height. [\#158](https://github.com/apertureless/vue-chartjs/issues/158)
- Chart doesn't load in bootstrap tab [\#157](https://github.com/apertureless/vue-chartjs/issues/157)
- Add scatter chart to vue-chatjs@legacy [\#155](https://github.com/apertureless/vue-chartjs/issues/155)
- \[Error\] Get error when $destroy is started. [\#149](https://github.com/apertureless/vue-chartjs/issues/149)
**Merged pull requests:**
- Feature/dynamic styles [\#162](https://github.com/apertureless/vue-chartjs/pull/162) ([apertureless](https://github.com/apertureless))
- Add Chinese simplified docs support. [\#159](https://github.com/apertureless/vue-chartjs/pull/159) ([Mooooooon](https://github.com/Mooooooon))
## [v1.2.0](https://github.com/apertureless/vue-chartjs/tree/v1.2.0) (2017-07-25)
[Full Changelog](https://github.com/apertureless/vue-chartjs/compare/v2.7.2...v1.2.0)
**Closed issues:**
- this.$refs doesn't seem to have expected canvas property [\#156](https://github.com/apertureless/vue-chartjs/issues/156)
**Merged pull requests:**
- Before destroy fix [\#152](https://github.com/apertureless/vue-chartjs/pull/152) ([DenisLapi](https://github.com/DenisLapi))
## [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)

123
README.md
View File

@@ -6,9 +6,10 @@
[![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/localeval.svg)](https://www.npmjs.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
@@ -16,8 +17,8 @@
## Demo & Docs
- [Demo](http://demo.vue-chartjs.org/)
- [Docs](http://www.vue-chartjs.org/)
- 📺 [Demo](http://demo.vue-chartjs.org/)
- 📖 [Docs](http://www.vue-chartjs.org/)
### Compatibility
@@ -26,17 +27,61 @@
- v2 later
- Vue.js 2.x
After the final release of vue.js 2, you also get the v2 per default if you install vue-chartjs over npm.
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.1.3)
If you're looking for v1 check this [branch](https://github.com/apertureless/vue-chartjs/tree/release/1.x)
## Install
Simply run `npm install vue-chartjs`
Simply run `yarn add vue-chartjs chart.js`
Or if you want to use it directly in the browser add
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
<script src="https://unpkg.com/vue-chartjs/dist/vue-chartjs.min.js"></script>
```
to your scripts. See [Codepen](https://codepen.io/apertureless/pen/zEvvWM)
### Browser
You can use `vue-chartjs` directly in the browser without any build setup. Like in this [codepen](https://codepen.io/apertureless/pen/zEvvWM). For this case, please use the `vue-chartjs.min.js` which is the minified version. You also need to add the Chart.js CDN script.
You can then simply register your component:
```js
Vue.component('line-chart', {
extends: VueChartJs.Line,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80, 40]
}
]
}, {responsive: true, maintainAspectRatio: false})
}
})
```
### 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 Chart.js is a `peerDependencies` so you have to install it separately. In most projects This way, you can have different versions of 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, `Chart.js` is a `peerDependencies` and need to be installed.
## How to use
You need to import the base chart class and extend it. This gives much more flexibility when working with different data. You can pass the data over props or vue-resource.
You need to import the component and then either use `extends` or `mixins` and add it.
You can import the whole package or each module individual.
@@ -51,7 +96,8 @@ Just create your own component.
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
export default {
extends: Bar,
mounted () {
// Overwriting base render method with actual data.
this.renderChart({
@@ -65,7 +111,7 @@ export default Bar.extend({
]
})
}
})
}
```
Then simply import and use your own extended component and use it like a normal vue component
@@ -79,15 +125,16 @@ import CommitChart from 'path/to/component/CommitChart'
You can overwrite the default chart options. Just pass the options object as a second paramenter to the render method
```javascript
// MonthlyIncome.js
// MonthlyIncome.vue
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ["data", "options"],
export default {
extends: Line,
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
}
```
Use it in your vue app
@@ -110,7 +157,7 @@ export default {
## Reactivity
Chart.js does not update or re-render the chart if new data is passed.
However you can simply implement this by your own or use one of the two mixins which are included.
However you can simply implement this on your own or use one of the two mixins which are included.
- `reactiveProp`
- `reactiveData`
@@ -124,13 +171,14 @@ However keep in mind the limitations of vue and javascript for mutations on arra
// MonthlyIncome.js
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
export default {
extends: Line,
mixins: [mixins.reactiveProp],
props: ["chartData", "options"],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
}
```
@@ -142,26 +190,28 @@ Some ways to import them:
// Load complete module with all charts
import VueCharts from 'vue-chartjs'
export default VueCharts.Line.extend({
export default {
extends: VueCharts.Line,
mixins: [VueCharts.mixins.reactiveProp],
props: ["chartData", "options"],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
}
```
```javascript
// Load speperate modules
import { Line, mixins } from 'vue-chartjs'
export default Line.extend({
export default {
extends: Line,
mixins: [mixins.reactiveProp],
props: ["chartData", "options"],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
}
```
```javascript
@@ -169,29 +219,16 @@ export default Line.extend({
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
export default {
extends: Line,
mixins: [reactiveProp],
props: ["chartData", "options"],
props: ['chartData', 'options'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
}
```
## 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 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'
```
## Available Charts
### Bar Chart
@@ -222,6 +259,10 @@ import { Line } from 'vue-chartjs/es'
![Bubble](assets/bubble.png)
### Scatter
![Scatter](assets/scatter.png)
## Build Setup
``` bash
@@ -244,7 +285,7 @@ npm run e2e
npm test
```
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
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).
## Contributing

BIN
assets/bar.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 25 KiB

BIN
assets/bubble.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 26 KiB

BIN
assets/doughnut.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 41 KiB

BIN
assets/line.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 31 KiB

BIN
assets/pie.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 76 KiB

BIN
assets/polar.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 87 KiB

BIN
assets/radar.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 75 KiB

BIN
assets/scatter.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -1,35 +1,41 @@
// https://github.com/shelljs/shelljs
require('shelljs/global')
env.NODE_ENV = 'production'
'use strict'
require('./check-versions')()
var path = require('path')
var config = require('../config')
var ora = require('ora')
var webpack = require('webpack')
var webpackConfig = require('./webpack.prod.conf')
process.env.NODE_ENV = 'production'
console.log(
' Tip:\n' +
' Built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
)
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
var spinner = ora('building UMD module...')
const spinner = ora('building for production...')
spinner.start()
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
rm('-rf', assetsPath)
mkdir('-p', assetsPath)
webpack(webpackConfig, function (err, stats) {
spinner.stop()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n')
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

49
build/check-versions.js Normal file
View File

@@ -0,0 +1,49 @@
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}

View File

@@ -1,4 +1,5 @@
/* eslint-disable */
'use strict'
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')

View File

@@ -1,45 +1,61 @@
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var config = require('../config')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = process.env.NODE_ENV === 'testing'
'use strict'
require('./check-versions')()
const config = require('../config')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
}
const opn = require('opn')
const path = require('path')
const express = require('express')
const webpack = require('webpack')
const proxyMiddleware = require('http-proxy-middleware')
const webpackConfig = (process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
? require('./webpack.prod.conf')
: require('./webpack.dev.conf')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
const port = process.env.PORT || config.dev.port
// automatically open browser, if not set will be false
const autoOpenBrowser = !!config.dev.autoOpenBrowser
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
const proxyTable = config.dev.proxyTable
var app = express()
var compiler = webpack(webpackConfig)
const app = express()
const compiler = webpack(webpackConfig)
var devMiddleware = require('webpack-dev-middleware')(compiler, {
const devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
chunks: false
}
quiet: true
})
var hotMiddleware = require('webpack-hot-middleware')(compiler)
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: false,
heartbeat: 2000
})
// force page reload when html-webpack-plugin template changes
// currently disabled until this is resolved:
// https://github.com/jantimon/html-webpack-plugin/issues/680
// compiler.plugin('compilation', function (compilation) {
// compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
// hotMiddleware.publish({ action: 'reload' })
// cb()
// })
// })
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
const options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(context, options))
app.use(proxyMiddleware(options.filter || context, options))
})
// handle fallback for HTML5 history API
@@ -48,18 +64,44 @@ app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(devMiddleware)
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// serve pure static assets
var staticPath = path.posix.join(config.build.assetsPublicPath, config.build.assetsSubDirectory)
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
module.exports = app.listen(port, function (err) {
if (err) {
console.log(err)
return
}
console.log('Listening at http://localhost:' + port + '\n')
const uri = 'http://localhost:' + port
var _resolve
var _reject
var readyPromise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})
var server
var portfinder = require('portfinder')
portfinder.basePort = port
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
portfinder.getPort((err, port) => {
if (err) {
_reject(err)
}
process.env.PORT = port
var uri = 'http://localhost:' + port
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
server = app.listen(port)
_resolve()
})
})
module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}

View File

@@ -1,55 +1,71 @@
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
exports.assetsPath = function (_path) {
return path.posix.join(config.build.assetsSubDirectory, _path)
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
// generate loader string to be used with extract text plugin
function generateLoaders (loaders) {
var sourceLoader = loaders.map(function (loader) {
var extraParamChar
if (/\?/.test(loader)) {
loader = loader.replace(/\?/, '-loader?')
extraParamChar = '&'
} else {
loader = loader + '-loader'
extraParamChar = '?'
}
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
}).join('!')
if (options.extract) {
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
} else {
return ['vue-style-loader', sourceLoader].join('!')
const cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
}
}
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(['css']),
postcss: generateLoaders(['css']),
less: generateLoaders(['css', 'less']),
sass: generateLoaders(['css', 'sass?indentedSyntax']),
scss: generateLoaders(['css', 'sass']),
stylus: generateLoaders(['css', 'stylus']),
styl: generateLoaders(['css', 'stylus'])
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
loader: loader
use: loader
})
}
return output

19
build/vue-loader.conf.js Normal file
View File

@@ -0,0 +1,19 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
}),
transformToRequire: {
video: 'src',
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

View File

@@ -1,85 +1,76 @@
var path = require('path')
var config = require('../config')
var utils = require('./utils')
var projectRoot = path.resolve(__dirname, '../')
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: {
app: './src/index.js'
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
publicPath: config.build.assetsPublicPath,
filename: '[name].js'
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
extensions: ['.js', '.vue', '.json'],
alias: {
'src': path.resolve(__dirname, '../src'),
'mixins': path.resolve(__dirname, '../src/mixins'),
'BaseCharts': path.resolve(__dirname, '../src/BaseCharts')
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src')
}
},
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')]
},
module: {
preLoaders: [
rules: [
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter')
}
},
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.html$/,
loader: 'vue-html'
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
vue: {
loaders: utils.cssLoaders()
}
}

View File

@@ -1,9 +1,11 @@
var config = require('../config')
var webpack = require('webpack')
var merge = require('webpack-merge')
var utils = require('./utils')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
@@ -12,23 +14,23 @@ Object.keys(baseWebpackConfig.entry).forEach(function (name) {
module.exports = merge(baseWebpackConfig, {
module: {
loaders: utils.styleLoaders()
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// eval-source-map is faster for development
devtool: '#eval-source-map',
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-module-eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
})
}),
new FriendlyErrorsPlugin()
]
})

View File

@@ -1,33 +1,128 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const base = require('./webpack.base.conf')
const config = require('../config')
var env = process.env.NODE_ENV === 'testing'
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
: config.build.env
base.entry = {
lib: './src/index.js'
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
// UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css')
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vender modules does not change
new webpack.HashedModuleIdsPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor']
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
base.output = {
path: config.build.assetsRoot,
publicPath: config.build.assetsPublicPath,
filename: 'vue-chartjs.js',
library: 'VueChartJs',
libraryTarget: 'umd'
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
var webpackConfig = Object.assign({}, base)
webpackConfig.devtool = '#source-map'
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
new webpack.DefinePlugin({
'process.env.NODE_ENV': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new webpack.optimize.OccurenceOrderPlugin(),
])
module.exports = webpackConfig

View File

@@ -1,9 +1,19 @@
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 webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader')
const npmCfg = require('../package.json')
const vueLoaderConfig = require('./vue-loader.conf')
var banner = [
npmCfg.name + ' v' + npmCfg.version,
'(c) ' + (new Date().getFullYear()) + ' ' + npmCfg.author,
npmCfg.homepage
].join('\n')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: {
@@ -12,32 +22,44 @@ module.exports = {
output: {
filename: './dist/[name].js',
library: 'VueChartJs',
libraryTarget: 'umd'
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
'chart.js': {
root: 'Chart',
commonjs: 'chart.js',
commonjs2: 'chart.js',
amd: 'chart.js'
}
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src')
}
},
module: {
preLoaders: [
rules: [
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter')
}
},
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},
{
test: /\.css$/,
@@ -45,21 +67,21 @@ module.exports = {
},
{
test: /\.s[a|c]ss$/,
loader: ExtractTextPlugin.extract('style-loader','css-loader!sass-loader')
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
}
plugins: [
new webpack.BannerPlugin(banner),
new webpack.optimize.ModuleConcatenationPlugin()
]
}
if (process.env.NODE_ENV === 'production') {
delete module.exports.devtool
module.exports.plugins = [
new webpack.DefinePlugin({
@@ -71,8 +93,6 @@ if (process.env.NODE_ENV === 'production') {
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
// new ExtractTextPlugin('build.css')
})
]
}

18
build/webpack.release.min.js vendored Normal file
View File

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

View File

@@ -0,0 +1,32 @@
'use strict'
// This is the webpack config used for unit tests.
const utils = require('./utils')
const webpack = require('webpack')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const webpackConfig = merge(baseWebpackConfig, {
// use inline sourcemap for karma-sourcemap-loader
module: {
rules: utils.styleLoaders()
},
devtool: '#inline-source-map',
resolveLoader: {
alias: {
// necessary to to make lang="scss" work in test when using vue-loader's ?inject option
// see discussion at https://github.com/vuejs/vue-loader/issues/724
'scss-loader': 'sass-loader'
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/test.env')
})
]
})
// no need for app entry during tests
delete webpackConfig.entry
module.exports = webpackConfig

View File

@@ -1,5 +1,6 @@
var merge = require('webpack-merge')
var prodEnv = require('./prod.env')
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'

View File

@@ -1,21 +1,42 @@
'use strict'
// Template version: 1.1.1
// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
const path = require('path')
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: '',
assetsSubDirectory: 'static',
assetsPublicPath: '/',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
dev: {
env: require('./dev.env'),
port: 8080,
proxyTable: {}
},
umd: {
assetsRoot: path.resolve(__dirname, '../umd'),
assetsPublicPath: '/'
port: process.env.PORT || 8080,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}
}

View File

@@ -1,3 +1,4 @@
'use strict'
module.exports = {
NODE_ENV: '"production"'
}

View File

@@ -1,5 +1,6 @@
var merge = require('webpack-merge')
var devEnv = require('./dev.env')
'use strict'
const merge = require('webpack-merge')
const devEnv = require('./dev.env')
module.exports = merge(devEnv, {
NODE_ENV: '"testing"'

3238
dist/vue-chartjs.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
dist/vue-chartjs.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,28 +1,28 @@
---
search: english
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.
**vue-chartjs** is a wrapper for [Chart.js](https://github.com/chartjs/Chart.js) in Vue. You can easily create reusable 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.
`vue-chartjs` lets 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.
It abstracts the basic logic but exposes the Chart.js object to give you maximal flexibility.
## Installation
If you are working with Vue.js 2+ simple run:
`yarn add vue-chartjs -S`
`yarn add vue-chartjs chart.js`
If you are using vue 1.x please use the `legancy` tag. However the vue 1 version is not maintained anymore.
If you are using vue 1.x please use the `legacy` tag. However the Vue 1 version is not maintained anymore.
`yarn add vue-chartjs@legacy -S`
`yarn add vue-chartjs@legacy`
## 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 need to import the base chart and extend it. This gives more flexibility when working with different data.
You can encapsulate your components and use props to pass data or you can input them directly inside the component. However your component is not reusable this way.
You can import the whole package or each module individual.
@@ -30,15 +30,16 @@ You can import the whole package or each module individual.
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default Bar.extend({
export default {
extends: Bar,
mounted () {
// Overwriting base render method with actual data.
this.renderChart(data, options)
}
})
}
```
You can pass the `renderChart()` method, two arguments:
You can pass two arguments to the `renderChart()` method:
- Data object
- Options object
@@ -70,27 +71,29 @@ There are some basic props defined in the BaseCharts. Because you `extend()` the
|---|---|
| width | chart width |
| height | chart height |
| id | id of the canvas |
| 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
Here are some examples
### Chart with props
You can create the data and options props to pass data to the chart.
You can create data and options props to pass data to the chart.
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
export default {
extends: Line,
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
})
}
```
After you add your component you can use it:
@@ -99,7 +102,7 @@ After you add your component you can use it:
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
```
If you want to overwrite the width and height:
If you want to overwrite width and height:
```html
<line-chart
@@ -112,7 +115,7 @@ If you want to overwrite the width and height:
```
<p class="warning">
Please keep in mind, that you have to set `responsive: false` to be able to set a fix `width` and `height.
Please keep in mind, that you have to set `responsive: false` to be able to set a fixed `width` and `height`.
</p>
### Chart with local data
@@ -120,7 +123,8 @@ If you want to overwrite the width and height:
```javascript
import {Bar} from 'vue-chartjs'
export default Bar.extend({
export default {
extends: Bar,
data () {
return {
datacollection: {
@@ -134,28 +138,27 @@ export default Bar.extend({
]
}
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
})
}
```
### Reusebale Components
### Reusable 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.
If you want to keep your chart components reusable, it's the best to add a wrapper to them. This way the chart component is only responsible for the pure data representation and the wrapper component for the logic behind it. There are many different use cases 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.
Chart.js does not provide a live update if you change the datasets. However `vue-chartjs` provides two mixins to achieve 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.
Both mixins do actually achieve the same. Most of the time you will use `reactiveProp`. It extends the logic of your chart component and automatically creates a prop named `chartData` and adds 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.
`reactiveData` simply creates a local chartData variable which is not a prop! and adds a watcher. This is only useful, if you need single purpose charts and make an API call inside your chart component.
```javascript
data () {
@@ -172,14 +175,16 @@ data () {
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default Line.extend({
export default {
extends: Line,
mixins: [reactiveProp],
props: ['options'],
mounted () {
// this.chartData is created in the mixin
// 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**
@@ -240,7 +245,7 @@ export default Line.extend({
```
<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.
⚠ Attention: If you mutate your data in a parent component and pass it to your child chart component keep the javascript limitations in mind.
More info in this [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
</p>
@@ -253,13 +258,33 @@ export default Line.extend({
## Chart.js object
Sometimes you need more control over chart.js. Thats why you can access the chart.js instance over `this._chart`
Sometimes you need more control over Chart.js. That's why you can access the Chart.js instance over `this.$data._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}`
There are two versions of the Bar chart: `{Bar}` and `{HorizontalBar}`
</p>
![Bar](assets/bar.png)
@@ -287,25 +312,48 @@ Sometimes you need more control over chart.js. Thats why you can access the char
![Bubble](assets/bubble.png)
## Webpack, Browserify and dist files.
### Scatter
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.
This chart has a different data structure then the others. Right now the reactive mixins are not working for this chart type.
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:
![Scatter](assets/scatter.png)
```
import { Line } from 'vue-chartjs/es'
```
### Browserify
## Explanation of Different Builds
There are three different entry points. It depends on your build setup. The dependencies are bundled or required as a peerDependency.
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:
- Browser
- Browserify / Webpack 1
- Webpack 2
```
{
"presets": ["es2015"]
}
```
| 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). In 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 is 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 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/)

BIN
docs/assets/bar.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 25 KiB

BIN
docs/assets/bubble.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 26 KiB

BIN
docs/assets/doughnut.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 41 KiB

BIN
docs/assets/line.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/assets/pie.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 76 KiB

BIN
docs/assets/polar.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 87 KiB

BIN
docs/assets/radar.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 75 KiB

BIN
docs/assets/scatter.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -1,12 +1,50 @@
self.$config = {
const langs = [
{title: 'English', path: '/home', matchPath: /^\/(home|changelog)/},
{title: 'Deutsch', path: '/de/', matchPath: /^\/de/},
{title: 'Français', path: '/fr-fr/', matchPath: /^\/fr-fr/},
{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/},
{title: 'Bahasa Indonesia', path: '/id/', matchPath: /^\/ru/}
]
docute.init({
title: 'vue-chartjs docs',
plugins: [
evanyou()
],
landing: true,
// or custom path
landing: '_landing.html',
repo: 'apertureless/vue-chartjs',
twitter: 'apertureless',
'edit-link': 'https://github.com/apertureless/vue-chartjs/blob/master/docs'
}
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', 'fr', 'ja', 'pt-br', 'ru'],
// this plugin does require a url too
// where docsearch fetches contents
url: 'https://vue-chartjs.org'
})
],
})

366
docs/fr-fr/README.md Normal file
View File

@@ -0,0 +1,366 @@
---
search: fr-fr
---
# 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` vous permet d'utiliser chart.js avec vue sans prise de tête. C'est la solution idéale pour ceux qui souhaitent créer des graphes simplement et rapidement.
La logique interne de chart.js est abstraite, mais l'objet sous-jacent est exposé, de sorte que vous puissiez bénéficier de la plus grande flexibilité possible.
## Installation
Si vous travaillez avec Vue.js 2+, exécutez simplement :
`yarn add vue-chartjs chart.js`
Avec vue 1.x, il vous faudra utiliser le marqueur `legacy`. Notez toutefois que la version 1 de vue n'est plus maintenue à l'heure actuelle.
`yarn add vue-chartjs@legacy`
## Démarrage rapide
Importez l'objet graphe de base afin de l'étendre. Cette façon de faire offre beaucoup plus de flexibilité lorsque plusieurs sources de données sont utilisées.
Il est possible d'encapsuler vos composants et d'utiliser les props pour transmettre les données, ou vous pouvez également les indiquer directement à l'intérieur du composant. Cependant, cette seconde méthode ne créera pas des composants réutilisables.
Vous pouvez choisir d'importer le package dans son intégralité, ou chaque composant individuellement.
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default {
extends: Bar,
mounted () {
// Surcharge de la méthode render avec les données.
this.renderChart(data, options)
}
}
```
La méthode `renderChart()` prend deux paramètres :
- un objet de données
- un objet d'options
### Objet de données
L'objet de données prend la structure suivante :
```javascript
{
labels: ['Janvier', 'Février'],
datasets: [
{
label: 'Commits sur GitHub',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
```
Pour plus d'informations, vous pouvez lire la documentation [Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data).
## Props
Certains props de base sont définis dans BaseCharts. Grâce à l'héritage de l'opération `extend()`, ceux-ci peuvent être surchargés, bien qu'ils soient *invisibles*.
| Prop | Description |
|---|---|
| width | largeur du graphe |
| height | hauteur du graphe |
| chart-id | id du canvas |
| css-classes | Chaîne de caractères avec les classes CSS à appliquer à l'élément div parent |
| styles | Object avec les styles CSS à appliquer à l'élément div parent |
## Exemples
Voici quelques exemples.
### Graphe avec props
Vous pouvez créer les props data et options à transmetttre au graphe.
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default {
extends: Line,
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
}
```
Vous pourrez les utiliser après avoir ajouté votre composant :
```html
<line-chart :data="{votre objet de données}" :options="{vos options}"></line-chart>
```
Si vous souhaitez modifier la hauteur ou la largeur :
```html
<line-chart
:data="{votre objet de données}"
:options="{responsive: false, maintainAspectRatio: false}"
:width="400"
:height="200"
>
</line-chart>
```
<p class="warning">
Vous devrez préciser `responsive: false` si vous souhaitez appliquer une taille fixe avec `width` et `height`.
</p>
### Graphe avec données locales
```javascript
import {Bar} from 'vue-chartjs'
export default {
extends: Bar,
data () {
return {
datacollection: {
labels: ['Janvier', 'Février'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
}
```
### Composants réutilisables
Si vous souhaitez faire en sorte que vos composants restent réutilisables, appliquez un wrapper. De cette manière, le composant graphique est seulement responsable de la représentation de la donnée, alors que le wrapper se charge de la logique derrière elle. Il y a de nombreux cas d'utilisations, et la manière de faire sera différente si vous êtes sur une Application Monopage (SPA) ou si vous intégrez sur du Laravel par exemple.
## Données en direct
Chart.js ne fournit pas de mécanisme de mise à jour automatique si jamais vous deviez modifier vos jeux de données. Cependant, `vue-chartjs` met à disposition deux mixins pour cela :
- `reactiveProp`
- `reactiveData`
Tous deux réalisent le même travail. La plupart du temps, c'est `reactiveProp` que vous utiliserez. Il reprend la logique de votre composant graphique, et crée automatiquement une prop `chartData` et ajoute une `vue watch` sur celle-ci. Lorsque la donnée change, `update()` sera appelée si c'est seulement le coeur de la donnée qui est modifié, et `renderChart()` si de nouveaux jeux de données ont été ajoutés.
`reactiveData` crée une variable locale chartData (pas une prop !), et lui ajoute un watcher.
Le seul cas d'utilisation est celui où vous souhaitez un graphe à usage unique, et que vous effectuez des appels API à l'intérieur même du composant.
```javascript
data () {
return {
chartData: null
}
}
```
### Exemple
**LineChart.js**
```javascript
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default {
extends: Line,
mixins: [reactiveProp],
props: ['options'],
mounted () {
// this.chartData est créé par le mixin.
// si vous voulez transmettre des options, il faudra créer une variable locale
this.renderChart(this.chartData, this.options)
}
}
```
**RandomChart.vue**
```javascript
<template>
<div class="small">
<line-chart :chart-data="datacollection"></line-chart>
<button @click="fillData()">Aléatoire</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 : si vous permutez vos données dans un composant parent puis les transmettez à un composant enfant, gardez à l'esprit les limitations de javascript.
Plus d'infos sur [issue#44](https://github.com/apertureless/vue-chartjs/issues/44).
</p>
### Limitations
<ul>
<li>[Mises en garde](https://vuejs.org/v2/guide/list.html#Caveats)</li>
<li>[Mise en garde sur la détection des modifications](https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats)</li>
<li>[vm.$watch](https://vuejs.org/v2/api/#vm-watch)</li>
</ul>
## Objet Chart.js
Il peut arriver d'avoir besoin de plus de contrôle sur l'objet chart.js. Vous pouvez, à cet effet, accéder à cet objet via `this.$data._chart`.
## Plugins inline
Avec Chart.js, vous pouvez définir des pugins globaux ou inline. Les plugins globaux fonctionnent sans souci avec `vue-chartjs`, comme décrit dans la [documentation chart.js](http://www.chartjs.org/docs/latest/developers/plugins.html).
Si vous désirez ajouter des plugins inline, `vue-chartjs` expose une méthode `addPlugin()`. L'appel à cette méthode doit se faire avant celui de `renderChart()`.
### Exemple
```javascript
mounted () {
this.addPlugin({
id: 'mon-plugin',
beforeInit: function (chart) {
....
}
})
}
```
## Diagrammes disponibles
### Colonnes
<p class="tip">
Il y a deux versions du diagramme colonnes : `{Bar}` et `{HorizontalBar}`
</p>
![Colonnes](../assets/bar.png)
### Ligne
![Ligne](../assets/line.png)
### Beignet
![Beignet](../assets/doughnut.png)
### Circulaire
![Circulaire](../assets/pie.png)
### Radar
![Radar](../assets/radar.png)
### Polaire
![Plaire](../assets/polar.png)
### Bulles
![Bulles](../assets/bubble.png)
### Nuages de points
Ce diagramme utilise une structure de données différente des autres. Pour le moment, les mixis de mise à jour de données ne fonctionnent pas avec ce type de graphique.
![Nuage de points](../assets/scatter.png)
## Explications sur les différents builds
Il y a trois builds différents. Le choix dépend de votre projet. Les dépendances sont soient intégrées, soit marquées comme peerDependency.
- Browser
- Browserify / Webpack 1
- Webpack 2
| Build | Chart.js | Vue.js |
|---|---|---|
| vue-chartjs.full.js | Intégré | Intégré |
| vue-chartjs.full.min.js | Intégré | Intégré |
| vue-chartjs.js | peerDependency | peerDependency |
| vue-chartjs.min.js | peerDependency | peerDependency |
| es/index* | peerDependency | peerDependency |
### Browser
Vous pouvez utiliser `vue-chartjs` directement depuis votre navigateur sans aucun pré-requis. Comme par exemple sur ce [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). Dans une telle situation, veuillez utiliser `vue-chartjs.full.min.js`, qui est la version compressée. Elle intègre Vue.js et Chart.js, et est bundlée à un module UMD. Donc ce fichier se suffit à lui-même.
### Browserify / Webpack 1
Si vous utilisez Gulp, Browserify ou Webpack 1, vous devrez prendre `vue-chartjs.js`, qui est __transpilé__ et __bundlé__ comme module UMD.
Toutefois, Vue.js et Chart.js sont des `peerDependencies`, vous devrez donc les installer séparemment. Dans la plupart des projets, `Vue.js` sera de toute façon déjà installé. De cette manière, vous pouvez utiliser des versions différentes de Vue.js et Chart.js dans un même package.
### Webpack 2
Si vous utilisez Webpack 2, `jsnext:main` / `module` sera automatiquement sélectionné. `es/index.js`est une version es __transpilée__ des sources, et n'est pas __bundlée__ à un module. Ainsi, rien ne devrait bloquer l'élimination de code mort. Comme dans la version bundlée précédente, `Vue.js` et `Chart.js` sont des `peerDependencies` et doivent être installés.
## Ressources
Voici une liste de ressources et tutoriels sur comment utiliser `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/)

363
docs/id/README.md Normal file
View File

@@ -0,0 +1,363 @@
---
search: id
---
# vue-chartjs
**vue-chartjs** adalah wrapper [Chart.js](https://github.com/chartjs/Chart.js) dalam vue. Kamu dapat dengan mudah membuat komponen chart reusable.
## Pengenalan
`vue-chartjs` memungkinkan kamu untuk menggunakan chart.js tanpa usaha lebih didalam vue. Sempurna untuk orang-orang yang membutuhkan bagan/chart simpel dengan cepat.
Flexibel karena langsung menampilkan objek chart.js.
## Instalasi
Jika kamu menggunakan Vue.js 2+:
`yarn add vue-chartjs chart.js`
Jika menggunakan vue 1.x gunakan tag `legacy`. versi vue 1 sudah tidak diurus lagi.
`yarn add vue-chartjs@legacy`
## Mulai Cepat
Kamu perlu untuk meng-import base chart dan meng-extend-nya. Dengan cara ini akan lebih fleksibel ketika bekerja dengan data yang berbeda.
Kamu dapat melakukan enkapsulasi komponen-komponen dan menggunakan props untuk menyampaikan data atau bisa juga dengan menginputkan langsung didalam komponen. Namun komponenmu tidak reuseable.
Kamu bisa meng-import seluruh package atau modul-modul terpisah.
```javascript
// CommitChart.js
import { Bar } from 'vue-chartjs'
export default {
extends: Bar,
mounted () {
// Overwriting base render method with actual data.
this.renderChart(data, options)
}
}
```
Kamu dapat melewatkan dua argumen pada `renderChart()`:
- Objek Data
- Objek Opsi
### Data object
Objek data:
```javascript
{
labels: ['January', 'February'],
datasets: [
{
label: 'GitHub Commits',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
```
Untuk keterangan lebih lanjut dapat dilihat di dokumentasi [Chart.js](http://www.chartjs.org/docs/#chart-configuration-chart-data).
## Props
Terdapat beberapa props standar yang didefinisikan didalam BaseChart. Karena menggunakan `extend()`, props-props tersebut *tidak terlihat*, Namun kamu tetap bisa menulis ulang:
| Prop | Description |
|---|---|
| width | lebar chart |
| height | tinggi chart |
| chart-id | id canvas |
| css-classes | String dengan kelas css mengelilingi div |
| styles | Objek dengan style css mengelilingi div |
## Contoh
Berikut adalah beberapa contoh penggunaan
### Chart dengan props
Kamu dapat membuat props data dan opsi untuk melewatkan data pada chart.
```javascript
// LineChart.js
import { Line } from 'vue-chartjs'
export default {
extends: Line,
props: ['data', 'options'],
mounted () {
this.renderChart(this.data, this.options)
}
}
```
Setelah kamu menambahkannya kamu dapat menggunakannya seperti biasa:
```html
<line-chart :data="{your data object}" :options="{your options}"></line-chart>
```
Jika kamu ingin mengatur tinggi dan lebar:
```html
<line-chart
:data="{your data object}"
:options="{responsive: false, maintainAspectRatio: false}"
:width="400"
:height="200"
>
</line-chart>
```
<p class="warning">
Perlu diingat, kamu perlu untuk mengatur `responsive: false` agaar dapat mengatur `width` dan `height`.
</p>
### Chart dengan data lokal
```javascript
import {Bar} from 'vue-chartjs'
export default {
extends: Bar,
data () {
return {
datacollection: {
labels: ['January', 'February'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20]
}
]
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}
}
```
### Reusable Komponen
Jika kamu ingin agar komponen chart reusable, cara paling baik adalah dengan menambahkan sebuah wrapper. Dengan cara ini komponen chart hanya bertanggung jawab dalam representasi data dan wrapper komponen bertanggung jawab dengan logika didalamnya. Banyak kasus-kasus yang berbeda dan juga berbeda jika kamu menjalankan Single Page Application atau mengintegrasikannya pada contoh laravel.
## Reactive Data
Chart.js tidak menyediakan live update jika kamu mengubah datasets. Akan tetapi `vue-chartjs` menyediakan 2 mixins untuk melakukannya.
- `reactiveProp`
- `reactiveData`
Kedua mixins tersebut sebenarnya sama. `reactiveProp` akan sering digunakan. `reactiveProp` meng-extend logika dari komponen chart dan secara otomatis membuat props `chartData` dan menambahkan `vue watch` dalam props ini. Pada saat data berubah, itu akan memanggil `update()` jika data memiliki datasets atau `renderChart()` jika datasets telah ada sebelumnya.
`reactiveData` secara sederhana membuat variabel lokal chartData dimana itu bukan sebuah props! dan watcher. Hal ini bisa berguna, jika kamu membutuhkan chart tertentu dan melakukan akses API didalam komponen chart.
```javascript
data () {
return {
chartData: null
}
}
```
### Contoh
**LineChart.js**
```javascript
import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
export default {
extends: Line,
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">
⚠ Perhatian: jika kamu memutasi data didalam komponen parent dan melewatkannya pada child komponen chart perlu diingat batasan javascript.
Info lebih lanjut [issue#44](https://github.com/apertureless/vue-chartjs/issues/44)
</p>
### Batasan
<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>
## Objek Chart.js
Suatu ketika kamu membutuhkan kontrol chart.js. Kamu dapat mengaksesnya dengan `this.$data._chart`
## Inline plugins
Di Chart.js kamu dapat mendefinisikan plugin global dan inline. Plugin global bekerja tanpa masalah dengan `vue-chartjs` seperti yang dijelaskan pada [chart.js docs](http://www.chartjs.org/docs/latest/developers/plugins.html)
If you want to add inline plugins, `vue-chartjs` exposes a helper method called `addPlugin()`
You should call `addPlugin()` before the `renderChart()` method.
Jika kamu ingin menambahkan plugin inline, `vue-chartjs` menyediakan method helper `addPlugin()` kamu harus memanggil `addPlugin()` sebelum method `renderChart()`.
### Contoh
```javascript
mounted () {
this.addPlugin({
id: 'my-plugin',
beforeInit: function (chart) {
....
}
})
}
```
## Charts yang Tersedia
### Bar Chart
<p class="tip">
Terdapat dua versi bar chart. `{Bar}` dan `{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.
Chart ini memiliki struktur data yang berbeda dengan yang lainnya. Untuk sekarang reactive mixins tidak dapat bekerja pada tipe chart ini.
![Scatter](assets/scatter.png)
## Penjelasan Build
Terdapat tiga jenis titik entri. Tergantung setup mana yang kamu gunakan. Dependensi-dependensi telah di-bundle atau require sebagai 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
Kamu dapat menggunakan `vue-chartjs` secara langsung didalam browser tanpa setup build. Seperti berikut [codepen](https://codepen.io/apertureless/pen/vxWbqB?editors=1010). Dalam kasus ini, mohon gunakan `vue-chartjs.full.min.js` yang telah di-minify. Didalamnya terdapat Vue.js dan Chart.js. Dan bundel modul UMD. Jadi kamu hanya membutuhkan satu file saja.
### Browserify / Webpack 1
Jika kamu menggunakan GUlp, Browserify atau Webpack 1 entri yang digunakan adalah `vue-chartjs.js` dimana telah di__transpile__ dan di__bundle__ UMD Module.
Bagaimanapun juga Vue.js dan Chart.js adalah `peerDependencies` jadi kamu harus meng-instalnya secara terpisah. Jika kamu telah memiliki `Vue.js` kamu dapat menggunakan versi Vue.js dan Chart.js yang terdapat di-package ini.
### Webpack 2
Jika kamu menggunakan Webpack 2 secara otomatis akan menggunakan titik entri `jsnext:main` / `module`. Di `es/index.js`
Di__transpile__ es sumber dari versi ini. Dan tidak di__bundle__ pada modul. Sehingga tree shaking akan bekerja. Sama seperti versi bundle, `Vue.js` dan `Chart.js` adalah `peerDependencies` dan butuh untuk diinstal.
## Sumber-sumber
Kamu dapat menemukan sumber-sumber seperti tutrial bagaimana cara untuk menggunakan `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

@@ -11,8 +11,9 @@
<!-- 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>
<script src="https://unpkg.com/docute@2/dist/docute.js"></script>
<!-- don't remove this part end -->
<!-- Google Analytics -->

322
docs/ja/README.md Normal file
View File

@@ -0,0 +1,322 @@
---
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 {
extends: Bar,
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 {
extends: Line,
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 {
extends: Bar,
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 {
extends: Line,
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.$data._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` はインストールする必要があります。

290
docs/pt-br/README.md Normal file
View File

@@ -0,0 +1,290 @@
<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 {
extends: Bar,
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 {
extends: Line,
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 {
extends: Line,
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 {
extends: VueCharts.Line,
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 {
extends: Line,
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 {
extends: Line,
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).

300
docs/ru/README.md Normal file
View File

@@ -0,0 +1,300 @@
---
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 {
extends: Bar,
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 {
extends: Line,
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 {
extends: Line,
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 {
extends: VueCharts.Line,
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 {
extends: Line,
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 {
extends: Line,
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).

362
docs/zh-cn/README.md Normal file
View File

@@ -0,0 +1,362 @@
---
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 {
extends: Bar,
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 {
extends: Line,
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 {
extends: Bar,
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 {
extends: Line,
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.$data._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/)

10646
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "vue-chartjs",
"version": "2.5.1",
"description": "vue.js wrapper for chart.js",
"version": "3.0.2",
"description": "Vue.js wrapper for chart.js for creating beautiful charts.",
"author": "Jakub Juszczak <jakub@posteo.de>",
"homepage": "http://vue-chartjs.org",
"license": "MIT",
@@ -37,7 +37,7 @@
"Charts"
],
"main": "dist/vue-chartjs.js",
"unpkg": "dist/vue-chartjs.js",
"unpkg": "dist/vue-chartjs.min.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"files": [
@@ -53,86 +53,97 @@
"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",
"prepublish": "yarn run lint && yarn run test && yarn run build"
"release": "webpack --progress --hide-modules --config ./build/webpack.release.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js",
"prepublishOnly": "yarn run lint && yarn run test && yarn run build"
},
"dependencies": {
"chart.js": "^2.5.0",
"lodash": "^4.17.4",
"vue": "^2.2.1"
"lodash.merge": "^4.6.0"
},
"peerDependencies": {
"chart.js": "2.7.x"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-core": "^6.23.1",
"babel-loader": "^6.3.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-stage-2": "^6.22.0",
"babel-runtime": "^6.23.0",
"@babel/cli": "^7.0.0-beta.31",
"@babel/core": "^7.0.0-beta.31",
"@babel/preset-env": "^7.0.0-beta.31",
"@babel/preset-stage-2": "^7.0.0-beta.31",
"babel-loader": "8.0.0-beta.0",
"chai": "^3.5.0",
"chromedriver": "^2.21.2",
"chart.js": "2.7.0",
"chromedriver": "^2.28.0",
"connect-history-api-fallback": "^1.1.0",
"cross-env": "^3.1.4",
"cross-spawn": "^5.0.1",
"css-loader": "^0.26.2",
"eslint": "^3.7.1",
"eslint-config-standard": "^6.2.0",
"eslint-friendly-formatter": "^2.0.5",
"eslint-loader": "^1.3.0",
"eslint-plugin-html": "^1.3.0",
"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": "^2.1.1",
"eslint-plugin-standard": "^3.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"express": "^4.15.2",
"extract-text-webpack-plugin": "^3.0.1",
"file-loader": "^0.10.1",
"friendly-errors-webpack-plugin": "^1.6.1",
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.2",
"inject-loader": "^3.0.0-beta2",
"isparta-loader": "^2.0.0",
"http-proxy-middleware": "^0.17.4",
"inject-loader": "^3.0.0",
"isparta": "^4.0.0",
"jasmine-core": "^2.5.2",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma": "^1.5.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^1.7.0",
"lolex": "^1.4.0",
"karma-spec-reporter": "0.0.30",
"karma-webpack": "2",
"lolex": "^1.6.0",
"mocha": "^3.1.0",
"nightwatch": "^0.9.8",
"ora": "^0.3.0",
"nightwatch": "^0.9.14",
"opn": "^5.1.0",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.13",
"selenium-server": "^3.0.1",
"shelljs": "^0.7.4",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"portfinder": "^1.0.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-hot-reload-api": "^2.0.11",
"vue": "2.5.2",
"vue-hot-reload-api": "2.1.0",
"vue-html-loader": "^1.2.4",
"vue-loader": "^11.1.4",
"vue-style-loader": "^2.0.3",
"vue-template-compiler": "^2.2.1",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0",
"webpack-merge": "^1.1.1"
"vue-loader": "^13.3.0",
"vue-style-loader": "3.0.1",
"vue-template-compiler": "2.5.2",
"webpack": "^3.7.1",
"webpack-dev-middleware": "^1.10.1",
"webpack-hot-middleware": "^2.17.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">=6.9.0"
},
"babel": {
"presets": [
"es2015"
]
"node": ">=6.9.0",
"npm": ">= 3.0.0"
},
"browserify": {
"transform": [
"babelify"
]
},
"greenkeeper": {
"ignore": [
"extract-text-webpack-plugin",
"karma-webpack",
"webpack",
"webpack-merge"
]
}
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -20,7 +22,6 @@ export default Vue.extend({
]
)
},
props: {
chartId: {
default: 'bar-chart',
@@ -33,11 +34,18 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
scales: {
yAxes: [{
@@ -56,24 +64,30 @@ export default Vue.extend({
barPercentage: 0.2
}]
}
}
},
plugins: []
}
},
methods: {
renderChart (data, options, type) {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'bar',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,11 +35,19 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
scales: {
yAxes: [{
@@ -56,25 +66,31 @@ export default Vue.extend({
barPercentage: 0.2
}]
}
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'bubble',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,31 +35,45 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'doughnut',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,11 +35,19 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
scales: {
yAxes: [{
@@ -56,24 +66,30 @@ export default Vue.extend({
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.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'horizontalBar',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,11 +35,19 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
scales: {
yAxes: [{
@@ -54,25 +64,31 @@ export default Vue.extend({
}
}]
}
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'line',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,31 +35,45 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'pie',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,31 +35,45 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'polarArea',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

View File

@@ -1,11 +1,13 @@
import Vue from 'vue'
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default Vue.extend({
export default {
render: function (createElement) {
return createElement(
'div',
'div', {
style: this.styles,
class: this.cssClasses
},
[
createElement(
'canvas', {
@@ -33,31 +35,45 @@ export default Vue.extend({
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this._chart = new Chart(
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'radar',
data: data,
options: chartOptions
options: chartOptions,
plugins: this.plugins
}
)
this._chart.generateLegend()
}
},
beforeDestroy () {
this._chart.destroy()
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
})
}

85
src/BaseCharts/Scatter.js Normal file
View File

@@ -0,0 +1,85 @@
import Chart from 'chart.js'
import { mergeOptions } from '../helpers/options'
export default {
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: 'scatter-chart',
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
}
},
data () {
return {
_chart: null,
defaultOptions: {
scales: {
xAxes: [{
type: 'linear',
position: 'bottom'
}]
}
},
plugins: []
}
},
methods: {
addPlugin (plugin) {
this.plugins.push(plugin)
},
renderChart (data, options) {
let chartOptions = mergeOptions(this.defaultOptions, options)
this.$data._chart = new Chart(
this.$refs.canvas.getContext('2d'), {
type: 'scatter',
data: data,
options: chartOptions,
plugins: this.plugins
}
)
}
},
beforeDestroy () {
if (this.$data._chart) {
this.$data._chart.destroy()
}
}
}

View File

@@ -1,21 +1,54 @@
<template>
<div class="container">
<h1 style="text-align:center;margin:40px 0;">Barchart</h1>
<bar-example></bar-example>
<h1 style="text-align:center;margin:40px 0;">Barchart with reactive mixing for live data</h1>
<reactive-example></reactive-example>
<h1 style="text-align:center;margin:40px 0;">Linechart</h1>
<line-example></line-example>
<h1 style="text-align:center;margin:40px 0;">Doughnutchart</h1>
<doughnut-example></doughnut-example>
<h1 style="text-align:center;margin:40px 0;">Piechart</h1>
<pie-example></pie-example>
<h1 style="text-align:center;margin:40px 0;">Radarchart</h1>
<radar-example></radar-example>
<h1 style="text-align:center;margin:40px 0;">Polararea</h1>
<polar-area-example></polar-area-example>
<h1 style="text-align:center;margin:40px 0;">Bubblechart</h1>
<bubble-example></bubble-example>
<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>
</div>
</template>
@@ -29,6 +62,7 @@
import BubbleExample from './BubbleExample'
import ReactiveExample from './ReactiveExample'
import ReactivePropExample from './ReactivePropExample'
import ScatterExample from './ScatterExample'
export default {
components: {
@@ -40,7 +74,47 @@
PolarAreaExample,
BubbleExample,
ReactiveExample,
ReactivePropExample
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'
}
}
}
}
</script>
@@ -50,4 +124,21 @@
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,6 +1,7 @@
import BarChart from '../BaseCharts/Bar'
import Bar from '../BaseCharts/Bar'
export default BarChart.extend({
export default {
extends: Bar,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
@@ -13,4 +14,4 @@ export default BarChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import BubbleChart from '../BaseCharts/Bubble'
import Bubble from '../BaseCharts/Bubble'
export default BubbleChart.extend({
export default {
extends: Bubble,
mounted () {
this.renderChart({
datasets: [
@@ -49,4 +50,4 @@ export default BubbleChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import DoughnutChart from '../BaseCharts/Doughnut'
import Doughnut from '../BaseCharts/Doughnut'
export default DoughnutChart.extend({
export default {
extends: Doughnut,
mounted () {
this.renderChart({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
@@ -17,4 +18,4 @@ export default DoughnutChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import HorizontalBarChart from '../BaseCharts/HorizontalBar'
import HorizontalBar from '../BaseCharts/HorizontalBar'
export default HorizontalBarChart.extend({
export default {
extends: HorizontalBar,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
@@ -13,4 +14,4 @@ export default HorizontalBarChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import LineChart from '../BaseCharts/Line'
import Line from '../BaseCharts/Line'
export default LineChart.extend({
export default {
extends: Line,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
@@ -13,4 +14,4 @@ export default LineChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import PieChart from '../BaseCharts/Pie'
import Pie from '../BaseCharts/Pie'
export default PieChart.extend({
export default {
extends: Pie,
mounted () {
this.renderChart({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
@@ -17,4 +18,4 @@ export default PieChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import PolarAreaChart from '../BaseCharts/PolarArea'
import PolarArea from '../BaseCharts/PolarArea'
export default PolarAreaChart.extend({
export default {
extends: PolarArea,
mounted () {
this.renderChart({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
@@ -26,4 +27,4 @@ export default PolarAreaChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,6 +1,7 @@
import RadarChart from '../BaseCharts/Radar'
import Radar from '../BaseCharts/Radar'
export default RadarChart.extend({
export default {
extends: Radar,
mounted () {
this.renderChart({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
@@ -28,4 +29,4 @@ export default RadarChart.extend({
]
}, {responsive: true, maintainAspectRatio: false})
}
})
}

View File

@@ -1,7 +1,8 @@
import BarChart from '../BaseCharts/Bar'
import Bar from '../BaseCharts/Bar'
import reactiveData from '../mixins/reactiveData'
export default BarChart.extend({
export default {
extends: Bar,
mixins: [reactiveData],
data () {
return {
@@ -38,4 +39,4 @@ export default BarChart.extend({
return Math.floor(Math.random() * (50 - 5 + 1)) + 5
}
}
})
}

View File

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

View File

@@ -0,0 +1,53 @@
import Scatter from '../BaseCharts/Scatter'
export default {
extends: Scatter,
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,4 +1,4 @@
import merge from 'lodash/fp/merge'
import merge from 'lodash.merge'
export function mergeOptions (obj, src) {
return merge(obj, src)

View File

@@ -6,9 +6,12 @@ import Pie from './BaseCharts/Pie'
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,
@@ -17,6 +20,7 @@ const VueCharts = {
PolarArea,
Radar,
Bubble,
Scatter,
mixins
}
@@ -32,5 +36,6 @@ export {
PolarArea,
Radar,
Bubble,
Scatter,
mixins
}

9
src/main.js Normal file
View File

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

@@ -8,7 +8,7 @@ module.exports = {
'chartData': {
handler (newData, oldData) {
if (oldData) {
let chart = this._chart
let chart = this.$data._chart
// Get new and old DataSet Labels
let newDatasetLabels = newData.datasets.map((dataset) => {
@@ -26,15 +26,44 @@ module.exports = {
// 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) => {
chart.data.datasets[i] = dataset
// 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]
}
}
})
chart.data.labels = newData.labels
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,12 +4,11 @@ module.exports = {
required: true
}
},
watch: {
'chartData': {
handler (newData, oldData) {
if (oldData) {
let chart = this._chart
let chart = this.$data._chart
// Get new and old DataSet Labels
let newDatasetLabels = newData.datasets.map((dataset) => {
@@ -27,15 +26,44 @@ module.exports = {
// 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) => {
chart.data.datasets[i] = dataset
// 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]
}
}
})
chart.data.labels = newData.labels
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

@@ -6,5 +6,8 @@
"expect": true,
"jasmine": true,
"sinon": true
},
"rules": {
"no-unused-expressions": 0
}
}

View File

@@ -16,11 +16,6 @@ var webpackConfig = merge(baseConfig, {
loaders: utils.styleLoaders()
},
devtool: '#inline-source-map',
vue: {
loaders: {
js: 'isparta'
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../../config/test.env')
@@ -31,15 +26,18 @@ var webpackConfig = merge(baseConfig, {
// no need for app entry during tests
delete webpackConfig.entry
// function resolve (dir) {
// return path.join(__dirname, '..', dir)
// }
// make sure isparta loader is applied before eslint
webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []
webpackConfig.module.preLoaders.unshift({
test: /\.js$/,
loader: 'isparta',
include: path.resolve(projectRoot, 'src')
})
// webpackConfig.module.rules = webpackConfig.module.rules || []
// webpackConfig.module.rules.unshift({
// test: /\.js$/,
// loader: 'babel-loader',
// include: [resolve('src'), resolve('test')]
// })
// only apply babel for test files when using isparta
// // only apply babel for test files when using isparta
webpackConfig.module.loaders.some(function (loader, i) {
if (loader.loader === 'babel') {
loader.include = path.resolve(projectRoot, 'test/unit')

View File

@@ -1,5 +1,5 @@
import Vue from 'vue'
import BarChart from 'src/examples/BarExample'
import BarChart from '@/examples/BarExample'
describe('BarChart', () => {
let el
@@ -51,14 +51,34 @@ describe('BarChart', () => {
components: { BarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -1,5 +1,5 @@
import Vue from 'vue'
import BubbleChart from 'src/examples/BubbleExample'
import BubbleChart from '@/examples/BubbleExample'
describe('BubbleChart', () => {
let el
@@ -51,14 +51,34 @@ describe('BubbleChart', () => {
components: { BubbleChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -1,5 +1,5 @@
import Vue from 'vue'
import DoughnutChart from 'src/examples/DoughnutExample'
import DoughnutChart from '@/examples/DoughnutExample'
describe('DoughnutChart', () => {
let el
@@ -51,14 +51,34 @@ describe('DoughnutChart', () => {
components: { DoughnutChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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,5 +1,5 @@
import Vue from 'vue'
import HorizontalBarChart from 'src/examples/HorizontalBarExample'
import HorizontalBarChart from '@/examples/HorizontalBarExample'
describe('HorizontalBarChart', () => {
let el
@@ -51,14 +51,34 @@ describe('HorizontalBarChart', () => {
components: { HorizontalBarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -1,5 +1,5 @@
import Vue from 'vue'
import LineChart from 'src/examples/LineExample'
import LineChart from '@/examples/LineExample'
describe('LineChart', () => {
let el
@@ -51,14 +51,34 @@ describe('LineChart', () => {
components: { LineChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -1,5 +1,5 @@
import Vue from 'vue'
import PieChart from 'src/examples/PieExample'
import PieChart from '@/examples/PieExample'
describe('PieChart', () => {
let el
@@ -50,14 +50,34 @@ describe('PieChart', () => {
components: { PieChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -1,5 +1,5 @@
import Vue from 'vue'
import PolarChart from 'src/examples/PolarAreaExample'
import PolarChart from '@/examples/PolarAreaExample'
describe('PolarChart', () => {
let el
@@ -51,14 +51,34 @@ describe('PolarChart', () => {
components: { PolarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -1,5 +1,5 @@
import Vue from 'vue'
import RadarChart from 'src/examples/RadarExample'
import RadarChart from '@/examples/RadarExample'
describe('RadarChart', () => {
let el
@@ -50,14 +50,34 @@ describe('RadarChart', () => {
components: { RadarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
expect(vm.$children[0].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
expect(vm.$children[0].$data._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

@@ -0,0 +1,84 @@
import Vue from 'vue'
import ScatterChart from '@/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].$data._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0].$data._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)
})
})

View File

@@ -1,4 +1,4 @@
import { mergeOptions } from 'src/helpers/options'
import { mergeOptions } from '@/helpers/options'
describe('mergeOptions.js', () => {
const a = {
@@ -15,16 +15,40 @@ describe('mergeOptions.js', () => {
c: 'c'
}
const an = {
a: {
a: 'a'
},
b: {
b: 'a'
}
}
const bn = {
a: {
a: 'a'
},
b: {
b: 'b'
}
}
it('should replace old a and b if a and b are new', () => {
let ab = mergeOptions(a, b)
const ab = mergeOptions(a, b)
expect(ab).to.have.property('a').and.to.equal('b')
expect(ab).to.have.property('b').and.to.equal('b')
})
it('should add c if c is new', () => {
let ac = mergeOptions(a, c)
expect(ac).to.have.property('a').and.to.equal('a')
expect(ac).to.have.property('b').and.to.equal('a')
const ac = mergeOptions(a, c)
expect(ac).to.have.property('a').and.to.equal('b')
expect(ac).to.have.property('b').and.to.equal('b')
expect(ac).to.have.property('c').and.to.equal('c')
})
it('should replace old a and b if a and b are new in nested objects', () => {
const ab = mergeOptions(an, bn)
expect(ab).to.have.deep.property('a.a').and.to.equal('a')
expect(ab).to.have.deep.property('b.b').and.to.equal('b')
})
})

5123
yarn.lock

File diff suppressed because it is too large Load Diff