Fixed #1840 - Provide chartjs object when Chart component is totally instantiated
parent
dc5783ed5a
commit
2b3cb64f8f
|
@ -17,6 +17,12 @@ const ChartProps = [
|
||||||
default: "null",
|
default: "null",
|
||||||
description: "Options to customize the chart."
|
description: "Options to customize the chart."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "plugins",
|
||||||
|
type: "any",
|
||||||
|
default: "null",
|
||||||
|
description: "Used to custom plugins of the chart."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "width",
|
name: "width",
|
||||||
type: "number",
|
type: "number",
|
||||||
|
@ -62,6 +68,17 @@ const ChartEvents = [
|
||||||
description: "Index of the data in dataset"
|
description: "Index of the data in dataset"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "loaded",
|
||||||
|
description: "Callback to invoke when chart is loaded.",
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: "chart",
|
||||||
|
type: "object",
|
||||||
|
description: "Chart instance."
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,10 @@ export interface ChartProps {
|
||||||
* Options to customize the chart.
|
* Options to customize the chart.
|
||||||
*/
|
*/
|
||||||
options?: object | undefined;
|
options?: object | undefined;
|
||||||
|
/**
|
||||||
|
* Used to custom plugins of the chart.
|
||||||
|
*/
|
||||||
|
plugins?: any;
|
||||||
/**
|
/**
|
||||||
* Width of the chart in non-responsive mode.
|
* Width of the chart in non-responsive mode.
|
||||||
* Default value is 300.
|
* Default value is 300.
|
||||||
|
@ -49,6 +53,11 @@ export declare type ChartEmits = {
|
||||||
* @param {ChartSelectEvent} event - Custom select event.
|
* @param {ChartSelectEvent} event - Custom select event.
|
||||||
*/
|
*/
|
||||||
'select': (event: ChartSelectEvent) => void;
|
'select': (event: ChartSelectEvent) => void;
|
||||||
|
/**
|
||||||
|
* Callback to invoke when chart is loaded.
|
||||||
|
* @param {*} chart - Chart instance.
|
||||||
|
*/
|
||||||
|
'loaded': (chart: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class Chart extends ClassComponent<ChartProps, ChartSlots, ChartEmits> {
|
declare class Chart extends ClassComponent<ChartProps, ChartSlots, ChartEmits> {
|
||||||
|
@ -70,6 +79,12 @@ declare class Chart extends ClassComponent<ChartProps, ChartSlots, ChartEmits> {
|
||||||
* @memberof Chart
|
* @memberof Chart
|
||||||
*/
|
*/
|
||||||
generateLegend: () => string | any;
|
generateLegend: () => string | any;
|
||||||
|
/**
|
||||||
|
* Returns Chart instance.
|
||||||
|
*
|
||||||
|
* @memberof Chart
|
||||||
|
*/
|
||||||
|
getChart: () => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '@vue/runtime-core' {
|
declare module '@vue/runtime-core' {
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'Chart',
|
name: 'Chart',
|
||||||
emits: ['select'],
|
emits: ['select', 'loaded'],
|
||||||
props: {
|
props: {
|
||||||
type: String,
|
type: String,
|
||||||
data: null,
|
data: null,
|
||||||
options: null,
|
options: null,
|
||||||
|
plugins: null,
|
||||||
width: {
|
width: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 300
|
default: 300
|
||||||
|
@ -61,14 +62,20 @@ export default {
|
||||||
this.chart = new module.default(this.$refs.canvas, {
|
this.chart = new module.default(this.$refs.canvas, {
|
||||||
type: this.type,
|
type: this.type,
|
||||||
data: this.data,
|
data: this.data,
|
||||||
options: this.options
|
options: this.options,
|
||||||
|
plugins: this.plugins
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$emit('loaded', this.chart);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCanvas() {
|
getCanvas() {
|
||||||
return this.$canvas;
|
return this.$canvas;
|
||||||
},
|
},
|
||||||
|
getChart() {
|
||||||
|
return this.chart;
|
||||||
|
},
|
||||||
getBase64Image() {
|
getBase64Image() {
|
||||||
return this.chart.toBase64Image();
|
return this.chart.toBase64Image();
|
||||||
},
|
},
|
||||||
|
|
|
@ -124,6 +124,12 @@ options: {
|
||||||
<td>null</td>
|
<td>null</td>
|
||||||
<td>Options to customize the chart.</td>
|
<td>Options to customize the chart.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>plugins</td>
|
||||||
|
<td>any</td>
|
||||||
|
<td>null</td>
|
||||||
|
<td>Used to custom plugins of the chart.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>width</td>
|
<td>width</td>
|
||||||
<td>number</td>
|
<td>number</td>
|
||||||
|
|
Loading…
Reference in New Issue