Compare commits

...

13 Commits

Author SHA1 Message Date
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
8 changed files with 347 additions and 20 deletions

View File

@@ -1,5 +1,12 @@
# Change Log
## [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)

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

View File

@@ -316,4 +316,4 @@ However Vue.js and Chart.js are `deerDependencies` so you have to install them s
### Webpack 2
If you're using Webpack 2 it will automatically use the `jsnext:main` / `module` entry point. Which is `es/index.js`
It is a __transpiled__ es version of the source. And is not __bundled__ to a module. This way you three shaking will work. Like in the bundled version, `Vue.js` and `Chart.js` are `peerDependencies` and need to be installed.
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.

View File

@@ -1,6 +1,7 @@
const langs = [
{title: 'English', path: '/home', matchPath: /^\/(home|changelog)/},
{title: 'Deutsch', path: '/de/', matchPath: /^\/de/}
{title: 'Deutsch', path: '/de/', matchPath: /^\/de/},
{title: '日本語', path: '/ja/', matchPath: /^\/ja/}
]
docute.init({

View File

@@ -134,7 +134,7 @@ export default Bar.extend({
]
}
}
}
},
mounted () {
this.renderChart(this.datacollection, {responsive: true, maintainAspectRatio: false})
}

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

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

View File

@@ -1,6 +1,6 @@
{
"name": "vue-chartjs",
"version": "2.6.2",
"version": "2.6.3",
"description": "vue.js wrapper for chart.js",
"author": "Jakub Juszczak <jakub@posteo.de>",
"homepage": "http://vue-chartjs.org",
@@ -61,7 +61,7 @@
},
"peerDependencies": {
"chart.js": "^2.5.0",
"vue": "^2.3.0"
"vue": "^2.3.3"
},
"devDependencies": {
"babel-cli": "^6.24.1",
@@ -117,12 +117,12 @@
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"url-loader": "^0.5.8",
"vue": "^2.3.0",
"vue": "^2.3.3",
"vue-hot-reload-api": "^2.1.0",
"vue-html-loader": "^1.2.4",
"vue-loader": "^12.0.2",
"vue-loader": "^12.0.4",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.3.0",
"vue-template-compiler": "^2.3.3",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.10.1",
"webpack-hot-middleware": "^2.17.1",

View File

@@ -5670,9 +5670,9 @@ vue-html-loader@^1.2.4:
loader-utils "^1.0.2"
object-assign "^4.1.0"
vue-loader@^12.0.2:
version "12.0.2"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-12.0.2.tgz#f539036b1e0e9516b474a8fd1b5f533145248406"
vue-loader@^12.0.4:
version "12.0.4"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-12.0.4.tgz#bc9385326e3fd6538606454977baa91eacc6e6fd"
dependencies:
consolidate "^0.14.0"
hash-sum "^1.0.2"
@@ -5695,9 +5695,9 @@ vue-style-loader@^3.0.0, vue-style-loader@^3.0.1:
hash-sum "^1.0.2"
loader-utils "^1.0.2"
vue-template-compiler@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.3.0.tgz#a89a17064b68e182569da51ebbedd71ce57f93bf"
vue-template-compiler@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.3.3.tgz#b5bab9ec57309c906b82a78c81a02179dbc2f470"
dependencies:
de-indent "^1.0.2"
he "^1.1.0"
@@ -5706,9 +5706,9 @@ vue-template-es2015-compiler@^1.2.2:
version "1.4.0"
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.4.0.tgz#7b88853ca4bf8d84ae54ab9e56771de271e60198"
vue@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.3.0.tgz#bc44db0488c5245c788304c7683efe7b4c862d82"
vue@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.3.3.tgz#d1eaa8fde5240735a4563e74f2c7fead9cbb064c"
watchpack@^0.2.1:
version "0.2.9"