Skip to content

Commit cedbdc6

Browse files
authored
Merge pull request #8 from bruceyyu/main
updates for v0.1.2
2 parents d48a03b + 78b837c commit cedbdc6

File tree

10 files changed

+101
-110
lines changed

10 files changed

+101
-110
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: GWalkR
22
Title: Interactive Exploratory Data Analysis Tool
3-
Version: 0.1.1
3+
Version: 0.1.2
44
Authors@R: c(
55
person("Yue", "Yu", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-9302-0793")),

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[English](README.md) | [中文](docs/README.zh.md)
1+
[English](README.md) | [中文](https://github.com/Kanaries/GWalkR/blob/main/docs/README.zh.md)
22

33
<img src="docs/img/hex_logo.png" align="right" alt="logo" width="120" height = "139" style = "border: none; float: right;">
44

@@ -52,11 +52,8 @@ gwalkr(iris)
5252

5353
## Main Features
5454
1. 🧑‍🎨 Turn a data frame into charts through simple drag-and-drop operations.
55-
2. 🤖️ [coming soon] Work with AI copilot in R: Let AI generate explorable charts for you!
55+
2. ✨ Empower your RMarkdown: Showcase your data insights with editable and explorable charts on a webpage ([example](https://bruceyyu.github.io/show/tidytuesday_etymology.nb.html))!
56+
3. 🤖️ [coming soon] Work with AI copilot in R: Let AI generate explorable charts for you!
5657

5758

5859
https://github.com/Kanaries/GWalkR/assets/33870780/4a3a9f9c-ff17-484b-9503-af82bd609b99
59-
60-
61-
3.[coming soon] Integration with Shiny app: Showcase your data insights with editable and explorable charts on a webpage!
62-

web_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@kanaries/graphic-walker": "^0.3.9",
13+
"@kanaries/graphic-walker": "^0.4.3",
1414
"@rollup/plugin-commonjs": "^25.0.2",
1515
"@rollup/plugin-replace": "^5.0.2",
1616
"@rollup/plugin-terser": "^0.4.3",

web_app/src/components/codeExportModal/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import React, { useEffect, useState } from "react";
22
import Modal from "../modal";
33
import { observer } from "mobx-react-lite";
44
import DefaultButton from "../button/default";
5-
import { encodeSpec } from "../../utils/graphicWalkerParser";
65

76
import type { IGlobalStore } from "@kanaries/graphic-walker/dist/store";
8-
import type { IVisSpec } from "@kanaries/graphic-walker/dist/interfaces";
97

108
interface ICodeExport {
119
globalStore: React.MutableRefObject<IGlobalStore | null>;
@@ -14,12 +12,12 @@ interface ICodeExport {
1412
}
1513

1614
const CodeExport: React.FC<ICodeExport> = observer((props) => {
17-
const [code, setCode] = useState<IVisSpec[]>([]);
15+
const [code, setCode] = useState<string>("");
1816

1917
useEffect(() => {
2018
if (props.open) {
2119
const res = props.globalStore.current?.vizStore.exportViewSpec();
22-
if (res) setCode(res);
20+
if (res) setCode(JSON.stringify(res));
2321
}
2422
}, [props.open]);
2523

@@ -34,7 +32,7 @@ const CodeExport: React.FC<ICodeExport> = observer((props) => {
3432
<h1 className="mb-4 font-bold text-base">Config Export</h1>
3533
<div className="text-sm max-h-64 overflow-auto w-full">
3634
<code className="font-mono text-xs whitespace-nowrap w-full">
37-
visConfig &lt;- '{JSON.stringify(JSON.parse(encodeSpec(code)))}'
35+
visConfig &lt;- '{code}'
3836
<br />
3937
gwalkr(data="name of your data frame", visConfig=visConfig)
4038
</code>

web_app/src/components/modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const Modal: React.FC<ModalProps> = (props) => {
6363
>
6464
<Container
6565
role="dialog"
66-
className="bg-white dark:bg-zinc-900 shadow-lg rounded-md border border-gray-100 dark:border-gray-800"
66+
className="bg-white dark:bg-zinc-900 shadow-lg rounded-md border border-gray-100 dark:border-gray-800 fixed left-50 top-50 z-999"
6767
onMouseDown={(e) => e.stopPropagation()}
6868
>
6969
<div className="absolute top-0 right-0 hidden pt-4 pr-4 sm:block">

web_app/src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
@tailwind components;
33
@tailwind utilities;
44
:root {
5+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
56
font-size: 16px;
67
}

web_app/src/index.tsx

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import { observer } from "mobx-react-lite";
44
import { IAppProps } from "./interfaces";
55
import { GraphicWalker } from "@kanaries/graphic-walker";
66
import type { IGlobalStore } from "@kanaries/graphic-walker/dist/store";
7-
import type { IDataSetInfo, IVisSpec } from "@kanaries/graphic-walker/dist/interfaces";
7+
import type { IDataSetInfo, IMutField, IRow, IVisSpec } from "@kanaries/graphic-walker/dist/interfaces";
88
import type { IStoInfo } from "@kanaries/graphic-walker/dist/utils/save";
99
import { getExportTool } from "./tools/exportTool";
1010
import CodeExportModal from "./components/codeExportModal";
11-
import "./index.css";
11+
import { StyleSheetManager } from 'styled-components';
12+
import tailwindStyle from 'tailwindcss/tailwind.css?inline'
1213

1314
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1415
const App: React.FC<IAppProps> = observer((propsIn) => {
@@ -19,36 +20,40 @@ const App: React.FC<IAppProps> = observer((propsIn) => {
1920
}, []);
2021
const [exportOpen, setExportOpen] = useState(false);
2122

22-
React.useEffect(() => {
23+
const setData = (data?: IRow[], rawFields?: IMutField[]) => {
2324
if (specList.length !== 0) {
24-
storeRef?.current?.vizStore?.importStoInfo({
25-
dataSources: [
26-
{
27-
id: "dataSource-0",
28-
data: dataSource,
29-
},
30-
],
31-
datasets: [
32-
{
33-
id: "dataset-0",
34-
name: "DataSet",
35-
rawFields: props.rawFields,
36-
dsId: "dataSource-0",
37-
},
38-
],
39-
specList,
40-
} as IStoInfo);
25+
setTimeout(() => {
26+
storeRef?.current?.vizStore?.importStoInfo({
27+
dataSources: [
28+
{
29+
id: "dataSource-0",
30+
data: data,
31+
},
32+
],
33+
datasets: [
34+
{
35+
id: "dataset-0",
36+
name: "DataSet",
37+
rawFields: rawFields,
38+
dsId: "dataSource-0",
39+
},
40+
],
41+
specList,
42+
} as IStoInfo)
43+
}, 1);
4144
} else {
4245
storeRef?.current?.commonStore?.updateTempSTDDS({
4346
name: "Dataset",
44-
rawFields: props.rawFields,
45-
dataSource: dataSource,
47+
rawFields: rawFields,
48+
dataSource: data,
4649
} as IDataSetInfo);
4750
storeRef?.current?.commonStore?.commitTempDS();
4851
}
49-
}, [storeRef, dataSource, props.rawFields, props.visSpec, specList]);
52+
}
5053

51-
props.storeRef = storeRef;
54+
React.useEffect(() => {
55+
setData(dataSource, props.rawFields)
56+
}, []);
5257

5358
const exportTool = getExportTool(setExportOpen);
5459

@@ -60,9 +65,10 @@ const App: React.FC<IAppProps> = observer((propsIn) => {
6065
};
6166
return (
6267
<React.StrictMode>
63-
<div style={{ height: "100%", width: "100%", overflowY: "scroll" }}>
68+
<div className="h-full w-full overflow-y-scroll font-sans">
69+
{/* <div style={{ height: "100%", width: "100%", overflowY: "scroll" }}> */}
6470
<CodeExportModal open={exportOpen} setOpen={setExportOpen} globalStore={storeRef} />
65-
<GraphicWalker {...props} toolbar={toolbarConfig} />
71+
<GraphicWalker {...props} storeRef={storeRef} toolbar={toolbarConfig} />
6672
</div>
6773
</React.StrictMode>
6874
);
@@ -71,8 +77,19 @@ const App: React.FC<IAppProps> = observer((propsIn) => {
7177
const GWalker = (props: IAppProps, id: string) => {
7278
const container = document.getElementById(id);
7379
if (container) {
74-
const root = createRoot(container);
75-
root.render(<App {...props} />);
80+
const shadowRoot = container.attachShadow({ mode: 'open' });
81+
82+
// Add Tailwind CSS to the shadow root
83+
const styleElement = document.createElement('style');
84+
styleElement.textContent = tailwindStyle;
85+
shadowRoot.appendChild(styleElement);
86+
87+
const root = createRoot(shadowRoot);
88+
root.render(
89+
<StyleSheetManager target={shadowRoot}>
90+
<App {...props} />
91+
</StyleSheetManager>
92+
);
7693
}
7794
// If you want to execute GWalker after the document has loaded, you can do it here.
7895
// But remember, you will need to provide the 'props' and 'id' parameters.

web_app/src/tools/exportTool.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ToolbarButtonItem } from "@kanaries/graphic-walker/dist/components
66

77
export function getExportTool(setExportOpen: React.Dispatch<React.SetStateAction<boolean>>): ToolbarButtonItem {
88
return {
9-
key: "export_code",
9+
key: "export_gwalkr_code",
1010
label: "export config",
1111
icon: (iconProps?: any) => <CodeBracketSquareIcon {...iconProps} />,
1212
onClick: () => {

web_app/src/utils/graphicWalkerParser.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

web_app/yarn.lock

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,39 +481,45 @@
481481
"@jridgewell/resolve-uri" "3.1.0"
482482
"@jridgewell/sourcemap-codec" "1.4.14"
483483

484-
"@kanaries/graphic-walker@0.3.9", "@kanaries/graphic-walker@^0.3.9":
485-
version "0.3.9"
486-
resolved "https://registry.npmmirror.com/@kanaries/graphic-walker/-/graphic-walker-0.3.9.tgz#cd2d090503fae366769a95b86a92676a44ed1ad2"
487-
integrity sha512-ox7WE7bUX5M71L7DIRFWi8hrABthN0KET/f3ODOt8iMfJ7cHd8j+7hkzMkeyB2zCj1CV2vw7f4xnNhf8dTCt0g==
484+
"@kanaries/graphic-walker@^0.4.3":
485+
version "0.4.3"
486+
resolved "https://registry.npmmirror.com/@kanaries/graphic-walker/-/graphic-walker-0.4.3.tgz#e30e8a5ef85781433acadeada828726acf68fb27"
487+
integrity sha512-r+c2bipTqlzPGckrYYNDbYmYi8DxBRJrjA4J1uNsckeb0d047ZT9cmQwqawtJPdxDpuxWnkFK7+oFYX6LcSRew==
488488
dependencies:
489489
"@headlessui/react" "^1.7.12"
490490
"@heroicons/react" "^2.0.8"
491-
"@kanaries/graphic-walker" "0.3.9"
492-
"@kanaries/react-beautiful-dnd" "0.0.1"
491+
"@kanaries/react-beautiful-dnd" "^0.0.3"
493492
"@kanaries/web-data-loader" "^0.1.7"
493+
"@tailwindcss/forms" "^0.5.4"
494494
autoprefixer "^10.3.5"
495+
d3-format "^3.1.0"
496+
d3-scale "^4.0.2"
497+
d3-time-format "^4.1.0"
495498
i18next "^21.9.1"
496499
i18next-browser-languagedetector "^6.1.5"
497500
immer "^9.0.15"
501+
leaflet "^1.9.4"
498502
mobx "^6.3.3"
499503
mobx-react-lite "^3.2.1"
500504
nanoid "^4.0.2"
501505
postcss "^8.3.7"
502506
postinstall-postinstall "^2.1.0"
503507
re-resizable "^6.9.8"
504508
react-i18next "^11.18.6"
509+
react-leaflet "^4.2.1"
505510
react-shadow "^20.0.0"
506511
rxjs "^7.3.0"
507512
tailwindcss "^3.2.4"
513+
topojson-client "^3.1.0"
508514
uuid "^8.3.2"
509515
vega "^5.22.1"
510516
vega-embed "^6.21.0"
511517
vega-lite "^5.6.0"
512518

513-
"@kanaries/[email protected].1":
514-
version "0.0.1"
515-
resolved "https://registry.npmmirror.com/@kanaries/react-beautiful-dnd/-/react-beautiful-dnd-0.0.1.tgz#18369ecd87649ff3d939ef0559e0e38f848de0b3"
516-
integrity sha512-4gUYrpNXOU+mLZ/Dsl/rGkmEEdxZ70pq2d2vMLIbeuGo+qCJSHL2UC5sTXfS6bAZcjcjBsim1ZpCwVc/EO2PYg==
519+
"@kanaries/react-beautiful-dnd@^0.0.3":
520+
version "0.0.3"
521+
resolved "https://registry.npmmirror.com/@kanaries/react-beautiful-dnd/-/react-beautiful-dnd-0.0.3.tgz#fce3972ed34a55223866b259b0adbabe003c7ba4"
522+
integrity sha512-QKwQmmRDuYstNVvWJrdzCOs2FQAJSZFLdTe6iFZbqIlnGmZCGbRuajFJ2t+IFTV/vOelFKS9FOCJLVvRgB3Mmg==
517523
dependencies:
518524
"@babel/runtime" "^7.9.2"
519525
css-box-model "^1.2.0"
@@ -557,6 +563,11 @@
557563
"@nodelib/fs.scandir" "2.1.5"
558564
fastq "^1.6.0"
559565

566+
"@react-leaflet/core@^2.1.0":
567+
version "2.1.0"
568+
resolved "https://registry.npmmirror.com/@react-leaflet/core/-/core-2.1.0.tgz#383acd31259d7c9ae8fb1b02d5e18fe613c2a13d"
569+
integrity sha512-Qk7Pfu8BSarKGqILj4x7bCSZ1pjuAPZ+qmRwH5S7mDS91VSbVVsJSrW4qA+GPrro8t69gFYVMWb1Zc4yFmPiVg==
570+
560571
"@rollup/plugin-commonjs@^25.0.2":
561572
version "25.0.2"
562573
resolved "https://registry.npmmirror.com/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.2.tgz#7ed37d00a12fc7fdd3aadba5fa0de52f2372bbbb"
@@ -603,6 +614,13 @@
603614
estree-walker "^2.0.2"
604615
picomatch "^2.3.1"
605616

617+
"@tailwindcss/forms@^0.5.4":
618+
version "0.5.4"
619+
resolved "https://registry.npmmirror.com/@tailwindcss/forms/-/forms-0.5.4.tgz#5316a782fd95369eb5b6fd01d46323b3dce656a2"
620+
integrity sha512-YAm12D3R7/9Mh4jFbYSMnsd6jG++8KxogWgqs7hbdo/86aWjjlIEvL7+QYdVELmAI0InXTpZqFIg5e7aDVWI2Q==
621+
dependencies:
622+
mini-svg-data-uri "^1.2.3"
623+
606624
"@types/clone@~2.1.1":
607625
version "2.1.1"
608626
resolved "https://registry.npmmirror.com/@types/clone/-/clone-2.1.1.tgz#9b880d0ce9b1f209b5e0bd6d9caa38209db34024"
@@ -1807,6 +1825,11 @@ json5@^2.2.2:
18071825
resolved "https://registry.npmmirror.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
18081826
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
18091827

1828+
leaflet@^1.9.4:
1829+
version "1.9.4"
1830+
resolved "https://registry.npmmirror.com/leaflet/-/leaflet-1.9.4.tgz#23fae724e282fa25745aff82ca4d394748db7d8d"
1831+
integrity sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==
1832+
18101833
levn@^0.4.1:
18111834
version "0.4.1"
18121835
resolved "https://registry.npmmirror.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
@@ -1888,6 +1911,11 @@ micromatch@^4.0.4, micromatch@^4.0.5:
18881911
braces "^3.0.2"
18891912
picomatch "^2.3.1"
18901913

1914+
mini-svg-data-uri@^1.2.3:
1915+
version "1.4.4"
1916+
resolved "https://registry.npmmirror.com/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz#8ab0aabcdf8c29ad5693ca595af19dd2ead09939"
1917+
integrity sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==
1918+
18911919
minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
18921920
version "3.1.2"
18931921
resolved "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
@@ -2202,6 +2230,13 @@ react-is@^17.0.2:
22022230
resolved "https://registry.npmmirror.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
22032231
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
22042232

2233+
react-leaflet@^4.2.1:
2234+
version "4.2.1"
2235+
resolved "https://registry.npmmirror.com/react-leaflet/-/react-leaflet-4.2.1.tgz#c300e9eccaf15cb40757552e181200aa10b94780"
2236+
integrity sha512-p9chkvhcKrWn/H/1FFeVSqLdReGwn2qmiobOQGO3BifX+/vV/39qhY8dGqbdcPh1e6jxh/QHriLXr7a4eLFK4Q==
2237+
dependencies:
2238+
"@react-leaflet/core" "^2.1.0"
2239+
22052240
react-redux@^7.2.0:
22062241
version "7.2.9"
22072242
resolved "https://registry.npmmirror.com/react-redux/-/react-redux-7.2.9.tgz#09488fbb9416a4efe3735b7235055442b042481d"

0 commit comments

Comments
 (0)