When using the m4 optimization for stacked area charts with more than a cetain number of data points the stack breaks with gaps between segements. Take this minimum example:
import * as vg from "@uwdata/vgplot";
const coord = vg.coordinator();
coord.databaseConnector(vg.wasmConnector());
const parquetUrl = "https://raw.githubusercontent.com/kgoodrick-uu/mosaic-test/main/fake_data.parquet";
await vg.coordinator().exec(vg.loadParquet(
"profile", parquetUrl,
));
const zoom = vg.Selection.crossfilter();
const baseEncoding = {
x: "time_stamp",
y: "power",
fill: "charger_id",
}
const optimize = true;
const mainPlot = vg.plot(
vg.areaY(vg.from("profile", {filterBy: zoom, optimize: optimize}), baseEncoding),
vg.yTickFormat("~s"),
);
const zoomPlot = vg.plot(
vg.areaY(vg.from("profile", {optimize: optimize}), baseEncoding),
vg.intervalX({as: zoom}),
vg.yTickFormat("~s"),
vg.height(100)
);
vg.vconcat(
mainPlot,
zoomPlot,
);
Broken stacking is clearly visible when zoomed into a few hours of data.
If optimize is changed to false stacking behaves as expected
I was not able to recreate this without the zoom (I think it is still there, but once the data is large enough I can no longer see if the stacking is broken). I think there needs to be a certain amount of data before the error is triggered.
My guess is that the optimization is not getting data for each of the groups at each timestamp it is sampling and that causes the strange behavior as some timesteps do not have data for each group.
Expected Behaivor: Stacked areas should remain contiguous and correctly layered when optimize: true is enabled.
When using the m4 optimization for stacked area charts with more than a cetain number of data points the stack breaks with gaps between segements. Take this minimum example:
Broken stacking is clearly visible when zoomed into a few hours of data.
If
optimizeis changed to false stacking behaves as expectedI was not able to recreate this without the zoom (I think it is still there, but once the data is large enough I can no longer see if the stacking is broken). I think there needs to be a certain amount of data before the error is triggered.
My guess is that the optimization is not getting data for each of the groups at each timestamp it is sampling and that causes the strange behavior as some timesteps do not have data for each group.
Expected Behaivor: Stacked areas should remain contiguous and correctly layered when
optimize: trueis enabled.