<template>
<div>
<div id="chart">
<apexchart
type="raincloud"
height="440"
:options="chartOptions"
:series="series"
></apexchart>
</div>
</div>
</template>
<script>
import VueApexCharts from 'vue-apexcharts'
import 'apexcharts/features/raincloud'
// Raw observations per group (Box-Muller Gaussian; Math.random is seeded by
// the sample template).
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) * 10) / 10)
}
return points
}
export default {
components: {
apexchart: VueApexCharts,
},
data: function () {
return {
series: [
{
name: 'Response time',
data: [
{ x: 'Control', points: sample(340, 55, 180) },
{ x: 'Variant A', points: sample(305, 40, 180) },
{ x: 'Variant B', points: sample(285, 62, 180) },
],
},
],
chartOptions: {
chart: {
type: 'raincloud',
height: 440,
},
title: {
text: 'Response times by cohort',
},
subtitle: {
text: 'Half-density cloud + raw observations; box lane turned off',
},
plotOptions: {
bar: {
distributed: true,
},
violin: {
// Hide the five-number box: its lane reflows to the cloud, so the rain
// sits directly against the density baseline (no dead strip).
box: {
show: false,
},
},
},
legend: {
show: false,
},
yaxis: {
title: {
text: 'Response time (ms)',
},
},
},
}
},
}
</script>
<style>
#chart {
max-width: 820px;
margin: 35px auto;
}
</style>