From 649b16e9c9db2859514dca3b679b8a8157c96529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Peer=20St=C3=B6cklmair?= Date: Wed, 6 Mar 2019 11:55:38 +0100 Subject: [PATCH] Docs: add typescript usage (#484) Closes #313 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 14598ffd..c4cb71e1 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,33 @@ export default { } ``` +or in TypeScript + +```ts +// CommitChart.ts +import { Bar } from 'vue-chartjs'; +import { Component } from 'vue-property-decorator'; + +@Component({ + extends: Bar, // this is important to add the functionality to your component +}) +export default class CommitChart extends Vue { + 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] + } + ] + }) + } +} +``` + Then simply import and use your own extended component and use it like a normal vue component ```javascript