I'm having trouble creating graphical components with Highcharts and Vue.js because I can't figure out how to dynamically set the id attribute that Highcharts needs to render properly.
Does anyone know how to set the id dynamically?
This is the HTML code snippet:
<objective-chart :element="'brick-chart'"></objective-chart>
And here's the JavaScript code snippet:
<template>
<div id="{{element}}"></div>
</template>
<script>
import Highcharts from 'highcharts';
export default{
props: ['element'],
created(){
$(function () {
new Highcharts.Chart({
chart: {
renderTo: this.element,
type: 'bar',
height: 200,
margin: [0, 20, 0, 40]
},
title: {
text: null
},
xAxis: {
lineColor: null,
labels: {
rotation: -90
},
categories: [
'Brick'
]
},
yAxis: [{
min: 0,
max:100,
endOnTick: true,
maxPadding: 0.02,
gridLineColor: null,
title: {
text: null
},
labels: {
y: -50
},
}],
legend: {
shadow: false,
verticalAlign: 'bottom'
},
tooltip: {
shared: true,
followPointer: true
},
plotOptions: {
column: {
grouping: true,
shadow: false,
borderWidth: 0
}
},
credits: {
enabled: false
},
series: [{
name: 'Objective',
color: 'rgba(224,224,224,1)',
data: [100],
pointPadding: 0.3,
pointPlacement: -0.2
}, {
name: 'Actual',
color: 'rgba(106,166,46,.9)',
data: [76],
pointPadding: 0.4,
pointPlacement: 0.1
}, {
type:'spline',
name: 'Projection',
color: 'rgba(106,166,46,.9)',
top: 10,
pointPlacement: -0.05,
data: [95],
marker: {
radius: 8,
lineColor: '#666666',
lineWidth: 1
}
}]
});
});
}
}
</script>