JSFiddle - React, Tailwind, and code Playground
by Sasha Morozov
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
JavaScript
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Fruit Info'
},
xAxis: {
lineWidth: 0,
tickWidth: 0,
labels: {
enabled: false,
}
},
tooltip: {
formatter: function() {
return '<b>' + this.y + '</b>'
}
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
gridLineWidth: 0,
lineWidth: 0,
labels: {
enabled: false,
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
},
bar: {
dataLabels: {
enabled: true,
distance : -50,
formatter: function() {
var dlabel = this.series.name + '<br/>';
dlabel += Math.round(this.percentage*100)/100 + ' %';
return dlabel
},
style: {
color: 'white',
},
},
},
},
series: [{
name: 'pear',
data: [15]
}, {
name: 'apple',
data: [15]
}]
});
});