diff --git a/README.md b/README.md index f526b99..4ff28ba 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,11 @@ export default { ### Line Chart -![Bar](src/assets/line.png) +![Line](src/assets/line.png) + +### Doughnut + +![Doughnut](src/assets/doughnut.png) ## Todo @@ -85,7 +89,7 @@ export default { - [ ] Implement Radar Chart - [ ] Implement Polar Area Chart - [ ] Implement Pie Chart -- [ ] Implement Doughnut Chart +- [x] Implement Doughnut Chart - [ ] Make npm module - [ ] Add tests diff --git a/src/App.vue b/src/App.vue index 784933f..45e7a0d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,16 +1,18 @@ diff --git a/src/BaseCharts/Doughnut.js b/src/BaseCharts/Doughnut.js index e69de29..4f421d6 100644 --- a/src/BaseCharts/Doughnut.js +++ b/src/BaseCharts/Doughnut.js @@ -0,0 +1,41 @@ +import Vue from 'vue' +import Chart from 'chart.js' + +export default Vue.extend({ + template: ` +
+ +
+ `, + + props: { + width: { + default: 400, + type: Number + }, + height: { + default: 400, + type: Number + } + }, + + data () { + return { + options: { + } + } + }, + + methods: { + render (data, options = this.options) { + const chart = new Chart( + this.$els.canvas.getContext('2d'), { + type: 'doughnut', + data: data, + options: options + } + ) + chart.generateLegend() + } + } +}) diff --git a/src/assets/doughnut.png b/src/assets/doughnut.png new file mode 100644 index 0000000..eecc61b Binary files /dev/null and b/src/assets/doughnut.png differ diff --git a/src/examples/DoughnutExample.js b/src/examples/DoughnutExample.js new file mode 100644 index 0000000..e13ffac --- /dev/null +++ b/src/examples/DoughnutExample.js @@ -0,0 +1,20 @@ +import DoughnutChart from '../BaseCharts/Doughnut' + +export default DoughnutChart.extend({ + ready () { + this.render({ + labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'], + datasets: [ + { + backgroundColor: [ + '#41B883', + '#E46651', + '#00D8FF', + '#DD1B16' + ], + data: [40, 20, 80, 10] + } + ] + }) + } +})