From eda21d27eb43dc4f8367dfb68c5293b1b746fba7 Mon Sep 17 00:00:00 2001 From: islxyqwe Date: Tue, 27 Feb 2024 12:30:06 +0800 Subject: [PATCH] feat: add table walker example --- README.md | 19 ++++++++++++++++++- packages/playground/src/examples/nav.tsx | 4 ++++ .../src/examples/pages/table.stories.tsx | 11 +++++++++++ .../playground/src/examples/pages/table.tsx | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 packages/playground/src/examples/pages/table.stories.tsx create mode 100644 packages/playground/src/examples/pages/table.tsx diff --git a/README.md b/README.md index 5ebc7149f..fe1371ec6 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ If you want to use Graphic Walker as a data exploration tool without thinking ab Use it here: [Graphic Walker Online](https://graphic-walker.kanaries.net) -Examples here: [Graphic Walker Examples](https://graphic-walker.kanaries.net/examples) +Examples here: [Graphic Walker Examples](https://graphic-walker.kanaries.net/examples/) ### Method 1: use as an independent app. ```bash @@ -156,6 +156,23 @@ const YourChart: React.FC = props => { export default YourChart; ``` +You can use `TableWalker` component to make a single table view with your data. it accepts same props as `GraphicWalker`, but you don't need to pass the chart prop, and you can control the page size by pageSize prop(default value is 20). + +```typescript +import { TableWalker } from '@kanaries/graphic-walker'; + +const YourChart: React.FC = props => { + const { dataSource, fields, spec } = props; + return ; +} + +export default YourChart; +``` + ### try local (dev mode) ```bash # packages/graphic-walker diff --git a/packages/playground/src/examples/nav.tsx b/packages/playground/src/examples/nav.tsx index 502a225d3..73b246d0b 100644 --- a/packages/playground/src/examples/nav.tsx +++ b/packages/playground/src/examples/nav.tsx @@ -23,6 +23,10 @@ export const pages = [ comp: () => import('./pages/cc'), name: 'CustomColor', }, + { + comp: () => import('./pages/table'), + name: 'TableWalker', + }, ].map((Component) => ({ name: Component.name, path: Component.name.replace(/\s/g, '_'), diff --git a/packages/playground/src/examples/pages/table.stories.tsx b/packages/playground/src/examples/pages/table.stories.tsx new file mode 100644 index 000000000..0c8b4e8b7 --- /dev/null +++ b/packages/playground/src/examples/pages/table.stories.tsx @@ -0,0 +1,11 @@ +import { useContext } from 'react'; +import { 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('https://pub-2422ed4100b443659f588f2382cfc7b1.r2.dev/datasets/ds-students-service.json'); + + return ; +} diff --git a/packages/playground/src/examples/pages/table.tsx b/packages/playground/src/examples/pages/table.tsx new file mode 100644 index 000000000..f5c343519 --- /dev/null +++ b/packages/playground/src/examples/pages/table.tsx @@ -0,0 +1,11 @@ +import Example from '../components/examplePage'; +import code from './table.stories?raw'; +import Comp from './table.stories'; + +export default function GraphicWalkerComponent() { + return ( + + + + ); +}