File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,27 @@ There are some basic props defined in the BaseCharts. Because you `extend()` the
75
75
| chart-id | id of the canvas |
76
76
| css-classes | String with css classes for the surrounding div |
77
77
| styles | Object with css styles for the surrounding div container |
78
+ | plugins | Array with chartjs plugins |
79
+
80
+ ## Legend Generation
81
+
82
+ ` vue-chartjs ` provides a small helper to generate a HTML legend.
83
+
84
+ ``` js
85
+ import { Line } from ' vue-chartjs'
86
+
87
+ export default {
88
+ extends: Line,
89
+ props: [' datasets' , ' options' ]
90
+ data : () => ({
91
+ htmlLegend: null
92
+ })
93
+ mounted () {
94
+ this .renderChart (this .datasets , this .options )
95
+ this .htmlLegend = this .generateLegend ()
96
+ }
97
+ }
98
+ ```
78
99
79
100
## Examples
80
101
Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ export function generateChart (chartId, chartType) {
62
62
addPlugin ( plugin ) {
63
63
this . $data . _plugins . push ( plugin )
64
64
} ,
65
+ generateLegend ( ) {
66
+ if ( this . $data . _chart ) {
67
+ return this . $data . _chart . generateLegend ( )
68
+ }
69
+ } ,
65
70
renderChart ( data , options ) {
66
71
if ( this . $data . _chart ) this . $data . _chart . destroy ( )
67
72
this . $data . _chart = new Chart (
You can’t perform that action at this time.
0 commit comments