Skip to content

An open source alternative to Tableau. Embeddable visual analytic

fix: renderSpec issue (#310)

islxyqwe472aa1e04df3
diff --git a/packages/graphic-walker/src/index.tsx b/packages/graphic-walker/src/index.tsx
index cd5aa369..659e5eed 100644
--- a/packages/graphic-walker/src/index.tsx
+++ b/packages/graphic-walker/src/index.tsx
@@ -121,9 +121,9 @@ export { default as PureRenderer } from './renderer/pureRenderer';
export type { ILocalPureRendererProps, IRemotePureRendererProps } from './renderer/pureRenderer';
export { embedGraphicWalker } from './vanilla';
export type { IGWProps, ITableProps, IVizAppProps, IDataSourceProvider, IMutField, IRow, IDataSourceListener, IChart, IChartForExport, IVisSpecForExport };
-export { VizSpecStore } from './store/visualSpecStore';
+export * from './store/visualSpecStore';
export { ISegmentKey, ColorSchemes, IDataSourceEventType } from './interfaces';
-export { resolveChart, convertChart } from './models/visSpecHistory';
+export { resolveChart, convertChart, parseChart } from './models/visSpecHistory';
export { getGlobalConfig } from './config';
export { DataSourceSegmentComponent } from './dataSource';
export * from './models/visSpecHistory';
diff --git a/packages/graphic-walker/src/store/visualSpecStore.ts b/packages/graphic-walker/src/store/visualSpecStore.ts
index af87303a..59d3d621 100644
--- a/packages/graphic-walker/src/store/visualSpecStore.ts
+++ b/packages/graphic-walker/src/store/visualSpecStore.ts
@@ -114,7 +114,7 @@ export class VizSpecStore {
options?: {
empty?: boolean;
onMetaChange?: (fid: string, diffMeta: Partial<IMutField>) => void;
- defaultConfig?: IDefaultConfig
+ defaultConfig?: IDefaultConfig;
}
) {
this.meta = meta;
@@ -766,34 +766,34 @@ export function renderSpec(spec: Specification, meta: IMutField[], name: string,
const facets = (spec.facets || []).concat(spec.highFacets || []);
for (let facet of facets) {
const f = fields.find((f) => f.fid === facet);
- f && chart.encodings.rows.push(f);
+ f && (chart.encodings.rows = chart.encodings.rows.concat([f]));
}
}
if (spec.position) {
const [cols, rows] = spec.position;
if (cols) {
const f = fields.find((f) => f.fid === cols);
- f && chart.encodings.columns.push(f);
+ f && (chart.encodings.columns = chart.encodings.columns.concat([f]));
}
if (rows) {
const f = fields.find((f) => f.fid === rows);
- f && chart.encodings.rows.push(f);
+ f && (chart.encodings.rows = chart.encodings.rows.concat([f]));
}
}
if (spec.color && spec.color.length > 0) {
const color = spec.color[0];
const f = fields.find((f) => f.fid === color);
- f && chart.encodings.color.push(f);
+ f && (chart.encodings.color = chart.encodings.color.concat([f]));
}
if (spec.size && spec.size.length > 0) {
const size = spec.size[0];
const f = fields.find((f) => f.fid === size);
- f && chart.encodings.size.push(f);
+ f && (chart.encodings.size = chart.encodings.size.concat([f]));
}
if (spec.opacity && spec.opacity.length > 0) {
const opacity = spec.opacity[0];
const f = fields.find((f) => f.fid === opacity);
- f && chart.encodings.opacity.push(f);
+ f && (chart.encodings.opacity = chart.encodings.opacity.concat([f]));
}
return chart;
}