Stacked Stream
Info - How to setup Vizzu
In HTML
, create a placeholder element that will contain the rendered
chart.
<html>
<body>
<div id="myVizzu">
</div>
</body>
</html>
In JavaScript
, initialize and configure the chart:
import Vizzu from 'https://cdn.jsdelivr.net/npm/vizzu@0.9/dist/vizzu.min.js'
import {
data
} from 'https://lib.vizzuhq.com/0.9/assets/data/music_industry_history_1.js'
let chart = new Vizzu('myVizzu')
chart.initializing
chart.animate({
data
})
This is a 2-step animation:
1st:
- set the Split parameter to true
- set the Align parameter to 'min'
2nd:
- move the Dimension from the Y-axis to the X-axis (before the other)
- set the Split parameter to false
chart.on('plot-axis-label-draw', (event) => {
const year = parseFloat(event.detail.text)
if (!event.detail.text.includes('$') && !isNaN(year) && year % 5 !== 0)
event.preventDefault()
});
chart.animate({
config: {
"channels": {
"x": "Year",
"y": [
"Revenue",
"Format"
],
"color": "Format"
},
"geometry": "area",
"align": "center"
},
style: {
"plot": {
"yAxis": {
"label": {
"numberScale": "K, M, B, T"
}
}
}
}
});
chart.animate({
config: {
"align": "min",
"split": true
}
});
chart.animate({
config: {
"channels": {
"x": [
"Format",
"Year"
],
"y": "Revenue"
},
"split": false
}
});
chart.feature('tooltip', true);