An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
chore: ability to change facet chart fixed size (#372)
islxyqwedc5c24c38264
diff --git a/packages/graphic-walker/src/lib/vega.ts b/packages/graphic-walker/src/lib/vega.tsindex b22ee8b9..f581ed01 100644--- a/packages/graphic-walker/src/lib/vega.ts+++ b/packages/graphic-walker/src/lib/vega.ts@@ -103,8 +103,8 @@ export function toVegaSpec({} else {const rowNums = rowFacetField !== NULL_FIELD ? new Set(dataSource.map((x) => x[rowFacetField.fid])).size : 1;const colNums = colFacetField !== NULL_FIELD ? new Set(dataSource.map((x) => x[colFacetField.fid])).size : 1;- spec.width = Math.floor((width - (rowFacetField === NULL_FIELD ? 40 : 94)) / colNums - 23);- spec.height = Math.floor((height - (colFacetField === NULL_FIELD ? 24 : 94)) / rowNums - 23);+ spec.width = Math.floor(width / colNums);+ spec.height = Math.floor(height / rowNums);}const v = getSingleView({@@ -127,7 +127,7 @@ export function toVegaSpec({geomType,displayOffset,dataSource,- vegaConfig+ vegaConfig,});const singleView = scales ? resolveScales(scales, v, dataSource, mediaTheme) : v;@@ -160,8 +160,8 @@ export function toVegaSpec({} else {const rowNums = rowFacetField !== NULL_FIELD ? new Set(dataSource.map((x) => x[rowFacetField.fid])).size : 1;const colNums = colFacetField !== NULL_FIELD ? new Set(dataSource.map((x) => x[colFacetField.fid])).size : 1;- spec.width = Math.floor((width / colRepeatFields.length - (rowFacetField === NULL_FIELD ? 40 : 94)) / colNums - 23);- spec.height = Math.floor((height / rowRepeatFields.length - (colFacetField === NULL_FIELD ? 24 : 94)) / rowNums - 23);+ spec.width = Math.floor(width / colRepeatFields.length / colNums);+ spec.height = Math.floor(height / rowRepeatFields.length / rowNums);}let index = 0;diff --git a/packages/graphic-walker/src/renderer/specRenderer.tsx b/packages/graphic-walker/src/renderer/specRenderer.tsxindex 2a85652c..e4eaaf36 100644--- a/packages/graphic-walker/src/renderer/specRenderer.tsx+++ b/packages/graphic-walker/src/renderer/specRenderer.tsx@@ -74,14 +74,9 @@ const SpecRenderer = forwardRef<IReactVegaHandler, SpecRendererProps>(function (const text = draggableFieldState.text;const format = _format;- const rowLeftFacetFields = useMemo(() => rows.slice(0, -1).filter((f) => f.analyticType === 'dimension'), [rows]);- const colLeftFacetFields = useMemo(() => columns.slice(0, -1).filter((f) => f.analyticType === 'dimension'), [columns]);-const isPivotTable = geoms[0] === 'table';- const hasFacet = rowLeftFacetFields.length > 0 || colLeftFacetFields.length > 0;-- const enableResize = size.mode === 'fixed' && !hasFacet && Boolean(onChartResize);+ const enableResize = size.mode === 'fixed' && Boolean(onChartResize);const mediaTheme = useContext(themeContext);const uiTheme = useContext(uiThemeContext);const themeConfig = getTheme({diff --git a/packages/graphic-walker/src/vis/react-vega.tsx b/packages/graphic-walker/src/vis/react-vega.tsxindex b1704972..59454439 100644--- a/packages/graphic-walker/src/vis/react-vega.tsx+++ b/packages/graphic-walker/src/vis/react-vega.tsx@@ -417,7 +417,6 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe};if (res.view.width() === 0) {if (res.view.signal('child_width') !== undefined) {- // is faceted viewres.view.signal('child_width',specs[0].width - modifier.width / Math.round((areaWidth || width) / colRepeatFields.length / specs[0].width)@@ -527,7 +526,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe<div ref={areaRef} className="inset-0 absolute" /><CanvaContainerstyle={{- ...(layoutMode === 'full' ? { width: '100%', height: '100%' } : {}),+ ...(layoutMode === 'auto' ? {} : { width: '100%', height: '100%' }),}}rowSize={Math.max(rowRepeatFields.length, 1)}colSize={Math.max(colRepeatFields.length, 1)}@@ -535,7 +534,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe>{/* <div ref={container}></div> */}{viewPlaceholders.map((view, i) => (- <div key={i} ref={view}></div>+ <div key={i} ref={view} className={layoutMode === 'auto' ? '' : 'overflow-hidden'}></div>))}</CanvaContainer></div>