Install & Download:
# NPM
$ npm i vue3-highchartsDescription:
A Vue.js 3 component to render Highcharts.js charts using the composition API.
Basic usage:
1. Import the vue3-highcharts component.
import { createApp } from 'vue';
import VueHighcharts from 'vue3-highcharts';2. Register the component.
// local
export default {
name: 'MyChart',
components: {
VueHighcharts,
},
};
// global
const app = createApp(..options);
app.use(VueHighcharts);3. Create a basic highcharts.js chart.
<template>
<vue-highcharts
type="chart"
:options="chartOptions"
:redrawOnUpdate="true"
:oneToOneUpdate="false"
:animateOnUpdate="true"
@rendered="onRender" />
<template>import { ref } from 'vue';
export default {
name: 'chart'
setup() {
const data = ref([1, 2, 3])
const chartData = computed(() =>{
return {
series: [{
name: 'Test Series',
data: data.value,
}],
}
});
const onRender = () => {
console.log('Chart rendered');
};
return {
chartData,
onRender
};
}
}4. Available props.
type: { // chart type
type: String,
default: 'chart',
},
options: { // Highcharts chart options
type: Object,
required: true,
},
redrawOnUpdate: {
type: Boolean,
default: true,
},
oneToOneUpdate: {
type: Boolean,
default: false,
},
animateOnUpdate: {
type: Boolean,
default: true,
},5. Events.
- @rendered: emitted when the chart has been rendered
- @updated: emitted when the chart options have been updated and the chart has been updated
- @destroyed: Emitted when the chart instance has been destroyed
Preview: