Open wenerme opened 2 years ago
@wenerme Could you please elaborate on your use case a little bit? Do you want to have some type of generic result set handler in place?
Tring to build a dashboard based on json, choose the panel based on resultset type
const s = resultSet.seriesNames()[0];
if (queryType === 'regularQuery') {
const value = resultSet.totalRow()[s.key];
const { icon } = meta.count || {};
return <StatisticPanel title={title} value={value} icon={icon} />;
}
if (queryType === 'compareDateRangeQuery') {
const [a, b] = resultSet.decompose().map((v) => v.totalRow()[s.key]);
const { icon } = meta.count || {};
return <StatisticPanel title={title} value={a} compare={b} icon={icon} />;
}
if (queryType === 'blendingQuery') {
const [rsa, rsb, trend] = resultSet.decompose();
const { icon } = meta.count || {};
const key = rsa.seriesNames()[0].key;
const a = rsa.totalRow()[key];
const b = rsb.totalRow()[key];
const series = trend.series()[0]?.series || [];
return (
<StatisticPanel title={title} value={a} compare={b} icon={icon}>
<ResizeObserverRender
className={'flex items-center justify-center'}
render={({ width, height }) => {
return (
<VegaLite
actions={false}
data={{ series: series }}
spec={{ ...defaultCountLineChart, width, height }}
/>
);
}}
/>
</StatisticPanel>
);
}
@wenerme I see. Yeah. Makes sense to add that. Looking forward to contributions here!
If you are interested in working on this issue, please leave a comment below and we will be happy to assign the issue to you. If this is the first time you are contributing a Pull Request to Cube.js, please check our contribution guidelines. You can also post any questions while contributing in the #contributors channel in the Cube.js Slack.
Is your feature request related to a problem? Please describe.
https://github.com/cube-js/cube.js/blob/master/packages/cubejs-client-core/index.d.ts#L131
need a way to check ResultSet content type, non regular result set have to decompose first, use different chart