Skip to content

Commit

Permalink
Fix 0807 (#136)
Browse files Browse the repository at this point in the history
* fix: create dataset table

* fix: cannot save resolve key

* fix: transform gw filter from server
  • Loading branch information
islxyqwe authored Aug 7, 2023
1 parent f868b7a commit ace0ef2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/graphic-walker/src/components/askViz/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -51,7 +52,7 @@ const AskViz: React.FC<{api?: string; headers?: Record<string, string>}> = (prop
setLoading(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);
Expand Down
12 changes: 7 additions & 5 deletions packages/graphic-walker/src/components/dataTable/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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);
Expand All @@ -164,7 +166,7 @@ const DataTable: React.FC<DataTableProps> = (props) => {
return () => {
taskIdRef.current++;
};
}, [computationFuction, pageIndex, size]);
}, [computationFunction, pageIndex, size]);

const loading = statLoading || dataLoading;

Expand Down
2 changes: 1 addition & 1 deletion packages/graphic-walker/src/dataSource/config.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/graphic-walker/src/dataSource/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 (
<DataTable
size={size}
dataset={tempDataset}
computation={computation}
total={tmpDataSource.length}
onMetaChange={(fid, fIndex, diffMeta) => {
commonStore.updateTempDatasetMetas(fid, diffMeta);
Expand Down
1 change: 1 addition & 0 deletions packages/graphic-walker/src/store/visualSpecStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

1 comment on commit ace0ef2

@vercel
Copy link

@vercel vercel bot commented on ace0ef2 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.