An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
Fix 0807 (#136)
islxyqweace0ef22d19a
diff --git a/packages/graphic-walker/src/components/askViz/index.tsx b/packages/graphic-walker/src/components/askViz/index.tsxindex c5650234..f09ebbe2 100644--- a/packages/graphic-walker/src/components/askViz/index.tsx+++ b/packages/graphic-walker/src/components/askViz/index.tsx@@ -3,8 +3,9 @@ import React, { useCallback, useState } from 'react';import { useGlobalStore } from '../../store';import { PaperAirplaneIcon } from '@heroicons/react/24/outline';import Spinner from '../spinner';-import { IViewField } from '../../interfaces';+import { IViewField, IVisSpec } from '../../interfaces';import { VisSpecWithHistory } from '../../models/visSpecHistory';+import { visSpecDecoder } from '../../utils/save';type VEGALite = any;@@ -51,7 +52,7 @@ const AskViz: React.FC<{api?: string; headers?: Record<string, string>}> = (propsetLoading(true);vizQuery(props.api ?? api, allFields, query, props.headers ?? {}).then((data) => {- vizStore.visList.push(new VisSpecWithHistory(data));+ vizStore.visList.push(new VisSpecWithHistory(visSpecDecoder([data])[0]));vizStore.selectVisualization(vizStore.visList.length - 1);// const liteGW = parseGW(spec);// vizStore.renderSpec(liteGW);diff --git a/packages/graphic-walker/src/components/dataTable/index.tsx b/packages/graphic-walker/src/components/dataTable/index.tsxindex 532ab686..aa1568a9 100644--- a/packages/graphic-walker/src/components/dataTable/index.tsx+++ b/packages/graphic-walker/src/components/dataTable/index.tsx@@ -1,7 +1,7 @@import React, { useMemo, useState, useRef, useEffect } from 'react';import styled from 'styled-components';import { observer } from 'mobx-react-lite';-import type { IMutField, IRow, DataSet } from '../../interfaces';+import type { IMutField, IRow, DataSet, IComputationFunction } from '../../interfaces';import { useTranslation } from 'react-i18next';import LoadingLayer from "../loadingLayer";import { useComputationFunc } from "../../renderer/hooks";@@ -16,6 +16,7 @@ interface DataTableProps {/** total count of rows */total: number;dataset: DataSet;+ computation?: IComputationFunction;onMetaChange: (fid: string, fIndex: number, meta: Partial<IMutField>) => void;loading?: boolean;}@@ -117,10 +118,11 @@ const getHeaderKey = (f: wrapMutField) => {};const DataTable: React.FC<DataTableProps> = (props) => {- const { size = 10, onMetaChange, dataset, total, loading: statLoading } = props;+ const { size = 10, onMetaChange, dataset, computation, total, loading: statLoading } = props;const [pageIndex, setPageIndex] = useState(0);const { t } = useTranslation();- const computationFuction = useComputationFunc();+ const defaultComputation = useComputationFunc();+ const computationFunction = computation ?? defaultComputation;const analyticTypeList = useMemo<{ value: string; label: string }[]>(() => {return ANALYTIC_TYPE_LIST.map((at) => ({@@ -149,7 +151,7 @@ const DataTable: React.FC<DataTableProps> = (props) => {}setDataLoading(true);const taskId = ++taskIdRef.current;- dataReadRawServer(computationFuction, size, pageIndex).then(data => {+ dataReadRawServer(computationFunction, size, pageIndex).then(data => {if (taskId === taskIdRef.current) {setDataLoading(false);setRows(data);@@ -164,7 +166,7 @@ const DataTable: React.FC<DataTableProps> = (props) => {return () => {taskIdRef.current++;};- }, [computationFuction, pageIndex, size]);+ }, [computationFunction, pageIndex, size]);const loading = statLoading || dataLoading;diff --git a/packages/graphic-walker/src/dataSource/config.ts b/packages/graphic-walker/src/dataSource/config.tsindex 41c23070..f9308159 100644--- a/packages/graphic-walker/src/dataSource/config.ts+++ b/packages/graphic-walker/src/dataSource/config.ts@@ -1,4 +1,4 @@-export const DemoDataAssets = process.env.NODE_ENV === 'production' ? {+export const DemoDataAssets = true ? {CARS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-cars-service.json",STUDENTS: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds-students-service.json",BTC_GOLD: "https://chspace.oss-cn-hongkong.aliyuncs.com/api/ds_btc_gold_service.json",diff --git a/packages/graphic-walker/src/dataSource/table.tsx b/packages/graphic-walker/src/dataSource/table.tsxindex ea4890e6..c6714b7f 100644--- a/packages/graphic-walker/src/dataSource/table.tsx+++ b/packages/graphic-walker/src/dataSource/table.tsx@@ -3,6 +3,7 @@ import { observer } from "mobx-react-lite";import { useGlobalStore } from "../store";import DataTable from "../components/dataTable";import { toJS } from "mobx";+import { getComputation } from "../computation/clientComputation";interface TableProps {size?: number;@@ -21,11 +22,14 @@ const Table: React.FC<TableProps> = (props) => {rawFields: toJS(tmpDSRawFields),};}, [tmpDataSource, tmpDSRawFields]);+9+ const computation = React.useMemo(() => getComputation(tempDataset.dataSource), [tempDataset])return (<DataTablesize={size}dataset={tempDataset}+ computation={computation}total={tmpDataSource.length}onMetaChange={(fid, fIndex, diffMeta) => {commonStore.updateTempDatasetMetas(fid, diffMeta);diff --git a/packages/graphic-walker/src/store/visualSpecStore.ts b/packages/graphic-walker/src/store/visualSpecStore.tsindex abb38fa5..6a31599f 100644--- a/packages/graphic-walker/src/store/visualSpecStore.ts+++ b/packages/graphic-walker/src/store/visualSpecStore.ts@@ -395,6 +395,7 @@ export class VizSpecStore {case configKey === 'sorted':case configKey === 'zeroScale':case configKey === 'background':+ case configKey === 'resolve':case configKey === 'limit':case configKey === 'stack': {return (config[configKey] = value);