// Raw observations per group (Box-Muller Gaussian; Math.random is seeded by
// the sample template). One group is deliberately bimodal: the cloud shows
// the two modes that the box alone would hide, which is the whole point of
// stacking all three layers.
function sample(mean, sd, n) {
var points = []
for (var k = 0; k < n; k++) {
var u1 = Math.random(),
u2 = Math.random()
var g = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2)
points.push(Math.round((mean + g * sd) * 100) / 100)
}
return points
}
var options = {
series: [
{
name: 'Bill ratio',
data: [
{ x: 'Adelie', points: sample(2.12, 0.16, 150) },
{ x: 'Chinstrap', points: sample(2.65, 0.14, 70) },
{
x: 'Gentoo',
points: sample(3.08, 0.1, 60).concat(sample(3.28, 0.09, 60)),
},
],
},
],
chart: {
type: 'raincloud',
height: 420,
},
colors: ['#FE9C64', '#00A29B', '#2E93fA'],
title: {
text: 'Bill ratios of three penguin species',
},
subtitle: {
text: 'Horizontal layout: cloud above the axis line, box and rain below',
},
plotOptions: {
bar: {
horizontal: true,
distributed: true,
},
},
legend: {
show: false,
},
xaxis: {
title: {
text: 'Bill ratio (length / depth)',
},
},
}
var chart = new ApexCharts(document.querySelector('#chart'), options)
chart.render()