JSFiddle - React, Tailwind, and code Playground
by Laurie
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="height: 400px; min-width: 310px; max-width: 600px; margin: 0 auto"></div>
JavaScript
$(function () {
function redrawLabels(e) {
var chart = this,
series = chart.series,
sLen = series.length;
for (var j = 0; j < sLen; j++) {
var s = series[j],
d = s.data,
dLen = d.length;
for (var i = 0; i < dLen; i++) {
var point = d[i],
label = point.dataLabel,
r = s.radii[i],
x = parseFloat(point.graphic.attr('cx')),
y = parseFloat(point.graphic.attr('cy'));
label.attr({
x: x + r / 2,
y: y - 11 - r / 2
});
}
}
}
$('#container').highcharts({
chart: {
type: 'bubble',
zoomType: 'xy',
events: {
load: redrawLabels
}
},
title: {
text: 'Bubble chart, cannot get labels to start in top right quadrant.'
},
plotOptions: {
bubble: {
dataLabels: {
enabled: true,
crop: false,
color: '#000000',
style: { textShadow: 'none' },
formatter: function() {
return this.point.name;
}
},
minSize: '10%',
maxSize: '30%'
}
},
series: [
{
name: 'Women',
marker: { fillColor: 'pink' },
data: [
{ name: 'Alice Pasternak', x: 3.5, y: 4, z: 5},
{ name: 'Eve Wild', x: 7, y: 7, z: 3},
{ name: 'Carol White', x: 4, y: 8, z: 6}
]
},
{
name: 'Men',
marker: { fillColor: 'lightblue' },
data: [
{ name: 'Dan', x: 4, y: 3, z: 4},
...