Skip to content

Commit

Permalink
Docs: add typescript usage (apertureless#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 authored and apertureless committed Mar 6, 2019
1 parent 93aab32 commit 649b16e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<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]
}
]
})
}
}
```

Then simply import and use your own extended component and use it like a normal vue component

```javascript
Expand Down

0 comments on commit 649b16e

Please sign in to comment.