JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<body>
<div id="myDiv" style="width: 480px; height: 400px;"><!-- Plotly chart will be drawn inside this DIV --></div>
</body>
JavaScript
var data = [
{
x: ['January', 'February', 'March'],
y: [5, 10, 9],
name: 'Orange',
type: 'bar'
}, {
x: ['January', 'February', 'March'],
y: [8, 4, 7],
name: 'Blue',
type: 'bar'
}, {
x: ['January', 'February', 'March'],
y: [9, 14, 2],
name: 'Red',
type: 'bar'
}
]
var annotations = [
{
x: 'January',
y: 22,
text: 22,
xanchor: 'center',
yanchor: 'bottom',
showarrow: false
}, {
x: 'February',
y: 28,
text: 28,
xanchor: 'center',
yanchor: 'bottom',
showarrow: false
}, {
x: 'March',
y: 18,
text: 18,
xanchor: 'center',
yanchor: 'bottom',
showarrow: false
}
];
var layout = {
title: 'Attempt at Plotly.js Stacked Bar Chart Totals',
annotations: annotations,
showlegend: true,
barmode: 'stack'
};
Plotly.newPlot('myDiv', data, layout);