I am trying to include the library chartjs-chart-error-bars ( https://github.com/sgratzl/chartjs-chart-error-bars ) in my application built in Vue (Clean project, created just to test the library), but when I try to add the graphic with type: "barWithErrorBars" I get the mentioned error.
The project was created with :
npm install -g @vue/cli-init
vue init webpack my-project
I have these versions in my package.json:
This is my component:
<template>
<canvas id="canvas"></canvas>
</template>
<script>
import Chart from 'chart.js'
export default {
name: 'ErrorBar',
mounted () {
let chart = new Chart(document.getElementById('canvas').getContext('2d'), {
type: 'barWithErrorBars',
data: {
labels: ['A', 'B'],
datasets: [
{
data: [
{
y: 4,
yMin: 1,
yMax: 6
},
{
y: 2,
yMin: 1,
yMax: 4
}
]
}
]
},
options: {
scales: {
yAxes: [
{
ticks: {
beginAtZero: true
}
}
]
}
}
})
return chart
}
}
</script>
<style scoped>
canvas {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
You're missing the import for the library:
import Chart from 'chart.js'
import 'chartjs-chart-error-bars'👈
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.