Highcharts Demo
author(s): Torstein Hønsi
by koh_edwin
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
CSS
@import url("https://code.highcharts.com/css/highcharts.css");
#container {
height: 400px;
min-width: 300px;
max-width: 800px;
margin: 0 auto;
}
.highcharts-data-label {
font-weight: normal;
}
/*
.highcharts-data-label-box {
fill: #a4edba;
stroke: gray;
stroke-width: 1px;
display: hidden !important;
}
.highlight .highcharts-data-label-box {
fill: red;
stroke-width: 2px;
stroke: black;
}
.highlight.highcharts-data-label text {
font-weight: bold;
fill: white;
}
*/
JavaScript
Highcharts.chart('container', {
chart: {
styledMode: true
},
title: {
text: 'Styling data labels by CSS'
},
xAxis: {
visble: false,
//categories: ['Jan', 'Feb', 'Mar', 'Apr']
},
plotOptions: {
series: {
name:'this is series 1',
dataLabels: {
enabled: true,
borderRadius: 2,
y:9,
x:200,
shape: 'callout'
}
}
},
series: [{
data: [{
y: 100,
dataLabels: {enabled: false}
}, {
y: 300,
dataLabels: {enabled: false}
}, {
y: 500,
dataLabels: {enabled: false,}
}, {
y: 400,
dataLabels: {
//className: 'highlight',
position: 'right',
formatter() {
if (this.point.index == this.series.points.length - 1) {
return `<div><span style="align:right; color:${this.color}">${this.series.name} long test</span></div>`
}
}
}
}]
},
{
data: [{
y: 100,
dataLabels: {enabled: false}
}, {
y: 300,
dataLabels: {enabled: false}
}, {
y: 500,
dataLabels: {enabled: false,}
}, {
y: 400,
dataLabels: {
//className: 'highlight',
position: 'right',
formatter() {
if (this.point.index == this.series.points.length - 1) {
return `<div><span style="align:right; color:${this.color}">${this.series.name} long test</span></div>`
}
}
}
}]
},
]
});