time-series-comp
time
by azeq
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SquashQL</title>
</head>
<body>
<div id="container" />
</body>
<script src="https://unpkg.com/@antv/s2/dist/s2.min.js"></script>
</html>
JavaScript
const squashQLResponse = {
"cells":[
{
"Month-over-Month (MoM) Growth":null,
"sales":33003.0
},
{
"year":2022,
"Month-over-Month (MoM) Growth":null,
"sales":18701.75
},
{
"month":8,
"year":2022,
"Month-over-Month (MoM) Growth":null,
"sales":3200.25
},
{
"month":9,
"year":2022,
"Month-over-Month (MoM) Growth":300.25,
"sales":3500.5
},
{
"month":10,
"year":2022,
"Month-over-Month (MoM) Growth":300.25,
"sales":3800.75
},
{
"month":11,
"year":2022,
"Month-over-Month (MoM) Growth":199.25,
"sales":4000.0
},
{
"month":12,
"year":2022,
"Month-over-Month (MoM) Growth":200.25,
"sales":4200.25
},
{
"year":2023,
"Month-over-Month (MoM) Growth":null,
"sales":14301.25
},
{
"month":1,
"year":2023,
"Month-over-Month (MoM) Growth":300.25,
"sales":4500.5
},
{
"month":2,
"year":2023,
"Month-over-Month (MoM) Growth":300.25,
"sales":4800.75
},
{
"month":3,
"year":2023,
"Month-over-Month (MoM) Growth":199.25,
"sales":5000.0
}
],
"rows":[
"year",
"month"
],
"columns":[
],
"values":[
"sales",
"Month-over-Month (MoM) Growth"
]
}
function transformData(rawData) {
return {
fields: {
rows: rawData["rows"],
columns: rawData["columns"],
values: rawData["values"],
valueInCols: true,
},
data: rawData["cells"]
}
}
const s2Options = {
width: 600,
height: 480,
showDefaultHeaderActionIcon: false,
hierarchyType: "tree",
...