Skip to content

An open source alternative to Tableau. Embeddable visual analytic

chore: add props of hide profiling in the main component (#484)

islxyqwe506429487a33
diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml
index f1cffbb7..63df11e3 100644
--- a/.github/workflows/auto-build.yml
+++ b/.github/workflows/auto-build.yml
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- node-version: [18.x, 20.x]
+ node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
diff --git a/packages/graphic-walker/src/App.tsx b/packages/graphic-walker/src/App.tsx
index 24eaa543..e730cccf 100644
--- a/packages/graphic-walker/src/App.tsx
+++ b/packages/graphic-walker/src/App.tsx
@@ -80,6 +80,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
vlSpec,
onError,
hideSegmentNav,
+ hideProfiling,
} = props;
const { t, i18n } = useTranslation();
@@ -189,7 +190,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
)}
<TabsContent value={ISegmentKey.data}>
<div className="mx-4 -mt-px p-4 border rounded-md rounded-t-none">
- <DatasetConfig />
+ <DatasetConfig hideProfiling={hideProfiling} />
</div>
</TabsContent>
<TabsContent value={ISegmentKey.vis} className='flex-1 min-h-0 flex flex-col'>
@@ -224,7 +225,7 @@ export const VizApp = observer(function VizApp(props: BaseVizProps) {
/>
<CodeExport />
<ExplainData themeKey={appliedThemeKey} />
- {vizStore.showDataBoard && <DataBoard />}
+ {vizStore.showDataBoard && <DataBoard hideProfiling={hideProfiling} />}
<VisualConfig />
<LogPanel />
<BinPanel />
diff --git a/packages/graphic-walker/src/components/dataBoard.tsx b/packages/graphic-walker/src/components/dataBoard.tsx
index dafa630f..c0a9012d 100644
--- a/packages/graphic-walker/src/components/dataBoard.tsx
+++ b/packages/graphic-walker/src/components/dataBoard.tsx
@@ -9,7 +9,7 @@ import { isNotEmpty } from '../utils';
import { Dialog, DialogContent } from './ui/dialog';
import { toJS } from "mobx";
-const DataBoard = observer(function DataBoardModal() {
+const DataBoard = observer(function DataBoardModal({hideProfiling}: {hideProfiling?: boolean}) {
const vizStore = useVizStore();
const computation = useCompututaion();
const { showDataBoard, selectedMarkObject, allFields, config, viewFilters } = vizStore;
@@ -57,7 +57,7 @@ const DataBoard = observer(function DataBoardModal() {
>
<DialogContent>
<div className="mt-4">
- <DataTable size={100} computation={filteredComputation} metas={metas} disableFilter displayOffset={config.timezoneDisplayOffset} />
+ <DataTable hideProfiling={hideProfiling} size={100} computation={filteredComputation} metas={metas} disableFilter displayOffset={config.timezoneDisplayOffset} />
</div>
</DialogContent>
</Dialog>
diff --git a/packages/graphic-walker/src/dataSource/datasetConfig/index.tsx b/packages/graphic-walker/src/dataSource/datasetConfig/index.tsx
index fcd19924..e06fc912 100644
--- a/packages/graphic-walker/src/dataSource/datasetConfig/index.tsx
+++ b/packages/graphic-walker/src/dataSource/datasetConfig/index.tsx
@@ -4,7 +4,7 @@ import { observer } from 'mobx-react-lite';
import { useCompututaion, useVizStore } from '../../store';
import { toJS } from 'mobx';
-const DatasetConfig: React.FC = () => {
+const DatasetConfig = ({ hideProfiling }: { hideProfiling?: boolean }) => {
const vizStore = useVizStore();
const computation = useCompututaion();
const metas = toJS(vizStore.meta);
@@ -19,6 +19,7 @@ const DatasetConfig: React.FC = () => {
onMetaChange={(fid, fIndex, diffMeta) => {
vizStore.updateCurrentDatasetMetas(fid, diffMeta);
}}
+ hideProfiling={hideProfiling}
/>
</div>
);
diff --git a/packages/graphic-walker/src/interfaces.ts b/packages/graphic-walker/src/interfaces.ts
index ff38a151..b74852a5 100644
--- a/packages/graphic-walker/src/interfaces.ts
+++ b/packages/graphic-walker/src/interfaces.ts
@@ -930,6 +930,7 @@ export interface IVizProps {
channelScales?: IChannelScales;
scales?: IChannelScales;
experimentalFeatures?: IExperimentalFeatures;
+ hideProfiling?: boolean;
}
export interface IExperimentalFeatures {
diff --git a/packages/playground/src/examples/nav.tsx b/packages/playground/src/examples/nav.tsx
index 9266e7cf..a9c31c51 100644
--- a/packages/playground/src/examples/nav.tsx
+++ b/packages/playground/src/examples/nav.tsx
@@ -47,6 +47,10 @@ export const pages = [
comp: () => import('./pages/themeBuilder'),
name: 'ThemeBuilder',
},
+ {
+ comp: () => import('./pages/hideProfiling'),
+ name: 'HideProfiling',
+ },
].map((Component) => ({
name: Component.name,
path: Component.name.replace(/\s/g, '_'),
diff --git a/packages/playground/src/examples/pages/hideProfiling.stories.tsx b/packages/playground/src/examples/pages/hideProfiling.stories.tsx
new file mode 100644
index 00000000..7d92d9b9
--- /dev/null
+++ b/packages/playground/src/examples/pages/hideProfiling.stories.tsx
@@ -0,0 +1,39 @@
+import { useContext, useState } from 'react';
+import { GraphicWalker, TableWalker } from '@kanaries/graphic-walker';
+import { themeContext } from '../context';
+import { useFetch, IDataSource } from '../util';
+
+export default function GraphicWalkerComponent() {
+ const { theme } = useContext(themeContext);
+ const { dataSource, fields } = useFetch<IDataSource>('https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-students-service.json');
+
+ const [tab, setTab] = useState('chart');
+ const [hideProfiling, setHideProfiling] = useState(true);
+
+ return (
+ <div className="flex flex-col gap-2">
+ <div className="flex gap-2">
+ <button className="bg-slate-900 text-white px-4 py-2 rounded m-4" onClick={() => setHideProfiling(!hideProfiling)}>
+ Toggle Profiling {hideProfiling ? 'On' : 'Off'}
+ </button>
+ <button
+ className={tab === 'chart' ? 'bg-slate-900 text-white px-4 py-2 rounded m-4' : 'bg-gray-200 text-gray-800 px-4 py-2 rounded m-4'}
+ onClick={() => setTab('chart')}
+ >
+ Graphic Walker
+ </button>
+ <button
+ className={tab === 'table' ? 'bg-slate-900 text-white px-4 py-2 rounded m-4' : 'bg-gray-200 text-gray-800 px-4 py-2 rounded m-4'}
+ onClick={() => setTab('table')}
+ >
+ Table
+ </button>
+ </div>
+ {tab === 'chart' ? (
+ <GraphicWalker hideProfiling={hideProfiling} fields={fields} data={dataSource} appearance={theme} vizThemeConfig="g2" />
+ ) : (
+ <TableWalker hideProfiling={hideProfiling} fields={fields} data={dataSource} appearance={theme} />
+ )}
+ </div>
+ );
+}
diff --git a/packages/playground/src/examples/pages/hideProfiling.tsx b/packages/playground/src/examples/pages/hideProfiling.tsx
new file mode 100644
index 00000000..0b409394
--- /dev/null
+++ b/packages/playground/src/examples/pages/hideProfiling.tsx
@@ -0,0 +1,11 @@
+import Example from '../components/examplePage';
+import code from './hideProfiling.stories?raw';
+import Comp from './hideProfiling.stories';
+
+export default function GraphicWalkerComponent() {
+ return (
+ <Example name="Hide Profiling" code={code}>
+ <Comp />
+ </Example>
+ );
+}