For some reason, my stacked bar chart doesn't display the numbers correctly on Y axis. I checked data format, tries different ones, but they are all rounded up as 0.0, 0.1 etc My min value is 500,000 and max value is 272M.
Where to look for a bug?
Here is my code:
vegalite({
width: 600,
height: 300,
data: { values: TrafficAp },
mark: {
type: "bar",
size: 35,
cornerRadiusEnd: 4
},
encoding: {
x: {
timeUnit: "year_month_day",
field: "month",
type: "temporal",
title: "Month",
sort: {
field: "month",
order: [
"2022-01",
"2022-02",
"2022-03",
"2022-04",
"2022-05",
"2022-06",
"2023-07",
"2023-08",
"2023-09",
"2023-10",
"2023-11",
"2023-12"
]
},
scale: {
bandPaddingInner: 0.2 // Adjust the bandPaddingInner value to change the spacing between bars
}
},
y: {
aggregate: "sum",
type: "quantitative",
field: "sessions",
title: "Sessions",
axis: {
format: "s",
labelExpr:
"datum.value === 0 ? '0' : format(datum.value, '.1s').replace(/G/,'B')"
}
},
color: {
field: "traffic_type",
type: "nominal",
title: "Traffic Type"
}
},
config: {
stack: "normalize" // Stack bars vertically and normalize the values
}
})
Those are percentages caused by this line:
config: {
stack: "normalize" // Stack bars vertically and normalize the values
}