Skip to content

An open source alternative to Tableau. Embeddable visual analytic

feat: redesign playground data source dialog with drag-and-drop and demo dataset cards

Elwynn Chen5f9fabeb8e0d
diff --git a/packages/graphic-walker/src/dataSource/config.ts b/packages/graphic-walker/src/dataSource/config.ts
index f271bc43..d123c946 100644
--- a/packages/graphic-walker/src/dataSource/config.ts
+++ b/packages/graphic-walker/src/dataSource/config.ts
@@ -26,43 +26,73 @@ export interface IPublicData {
key: string;
title: string;
desc?: string;
+ icon?: string;
+ rows?: number;
+ columns?: number;
}
export const PUBLIC_DATA_LIST: IPublicData[] = [
{
key: "CARS",
title: "Cars",
+ icon: "🚗",
+ rows: 406,
+ columns: 9
},
{
key: "STUDENTS",
- title: "Students' Performance"
+ title: "Students' Performance",
+ icon: "🎓",
+ rows: 1000,
+ columns: 8
},
{
key: "BIKE_SHARING",
- title: "Bike Sharing"
+ title: "Bike Sharing",
+ icon: "🚲",
+ rows: 17379,
+ columns: 16
},
{
key: "EARTHQUAKE",
- title: "Earthquakes"
+ title: "Earthquakes",
+ icon: "🌋",
+ rows: 23412,
+ columns: 4
},
{
key: "CAR_SALES",
- title: "Car Sales"
+ title: "Car Sales",
+ icon: "🚙",
+ rows: 157,
+ columns: 16
},
{
key: "COLLAGE",
- title: "Collage"
+ title: "Colleges",
+ icon: "🏫",
+ rows: 1294,
+ columns: 16
},
{
key: "KELPER",
- title: "NASA Kelper"
+ title: "NASA Kepler",
+ icon: "🪐",
+ rows: 9218,
+ columns: 44
},
{
key: 'BTC_GOLD',
- title: "2022MCM Problem C: Trading Strategies"
+ title: "Bitcoin vs. Gold",
+ icon: "📈",
+ rows: 464,
+ columns: 7
},
{
key: "TITANIC",
- title: "Titanic"
+ title: "Titanic",
+ icon: "🚢",
+ rows: 712,
+ columns: 11
}
]
diff --git a/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsx b/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsx
deleted file mode 100644
index 5fc62b43..00000000
--- a/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import React, { useRef, useCallback, useState } from 'react';
-import { FileReader } from '@kanaries/web-data-loader';
-import { IRow } from '../../interfaces';
-import Table from '../table';
-import { observer } from 'mobx-react-lite';
-import { useTranslation } from 'react-i18next';
-import DropdownSelect from '../../components/dropdownSelect';
-import { charsetOptions } from './config';
-import { jsonReader } from './utils';
-import { CommonStore } from '../../store/commonStore';
-import { Button } from '@/components/ui/button';
-import { Input } from '@/components/ui/input';
-
-interface ICSVData {
- commonStore: CommonStore;
-}
-const CSVData: React.FC<ICSVData> = ({ commonStore }) => {
- const fileRef = useRef<HTMLInputElement>(null);
- const { tmpDSName, tmpDataSource, tmpDSRawFields } = commonStore;
- const [encoding, setEncoding] = useState<string>('utf-8');
-
- const onSubmitData = useCallback(() => {
- commonStore.commitTempDS();
- }, [commonStore]);
-
- const { t } = useTranslation('translation', { keyPrefix: 'DataSource.dialog.file' });
- const fileLoaded = tmpDataSource.length > 0 && tmpDSRawFields.length > 0;
-
- const fileUpload = useCallback(
- (e: React.ChangeEvent<HTMLInputElement>) => {
- const files = e.target.files;
- if (files !== null) {
- const file = files[0];
- const name = file.name.toLowerCase();
- const ext = name.endsWith('.json') ? 'json' : 'csv';
- if (ext === 'csv') {
- FileReader.csvReader({
- file,
- config: { type: 'reservoirSampling', size: Infinity },
- onLoading: () => {},
- encoding,
- }).then((data) => {
- commonStore.updateTempDS(data as IRow[]);
- });
- } else {
- jsonReader(file).then((data) => {
- commonStore.updateTempDS(data as IRow[]);
- });
- }
- }
- },
- [commonStore, encoding]
- );
-
- return (
- <div className="min-h-[300px]">
- {!fileLoaded && (
- <div className="text-center">
- <svg className="mx-auto h-12 w-12 text-muted-foreground" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
- <path
- vectorEffect="non-scaling-stroke"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth={2}
- d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"
- />
- </svg>
- <h3 className="mt-2 text-sm font-semibold text-foreground">{t('choose_file')}</h3>
- <p className="mt-1 text-sm text-muted-foreground">{t('get_start_desc')}</p>
- </div>
- )}
- <input
- style={{ display: 'none' }}
- type="file"
- ref={fileRef}
- onChange={fileUpload}
- accept=".csv,.json"
- />
- {!fileLoaded && (
- <div className="my-1">
- <div className="flex flex-col items-center gap-1 w-fit mx-auto">
- <div className="flex w-full">
- <Button
- className="mr-2"
- variant="outline"
- onClick={() => {
- if (fileRef.current) {
- fileRef.current.click();
- }
- }}
- >
- {t('open')}
- </Button>
- <div className="relative flex-grow">
- <DropdownSelect
- className="w-full"
- options={charsetOptions}
- selectedKey={encoding}
- onSelect={(k) => {
- setEncoding(k);
- }}
- />
- </div>
- </div>
- </div>
- </div>
- )}
- {fileLoaded && (
- <div className="mb-2 mt-6">
- <label className="block text-xs text-secondary-foreground mb-1 font-bold">{t('dataset_name')}</label>
- <div className="flex space-x-2">
- <Input
- type="text"
- placeholder={t('dataset_name')}
- value={tmpDSName}
- onChange={(e) => {
- commonStore.updateTempName(e.target.value);
- }}
- className="text-xs placeholder:italic w-36"
- />
- <Button
- disabled={tmpDataSource.length === 0}
- onClick={() => {
- onSubmitData();
- }}
- >
- {t('submit')}
- </Button>
- </div>
- </div>
- )}
- {fileLoaded && <Table commonStore={commonStore} />}
- </div>
- );
-};
-
-export default observer(CSVData);
diff --git a/packages/graphic-walker/src/dataSource/dataSelection/demoData.tsx b/packages/graphic-walker/src/dataSource/dataSelection/demoData.tsx
new file mode 100644
index 00000000..c73fdca6
--- /dev/null
+++ b/packages/graphic-walker/src/dataSource/dataSelection/demoData.tsx
@@ -0,0 +1,98 @@
+import React, { useState } from 'react';
+import { observer } from 'mobx-react-lite';
+import { useTranslation } from 'react-i18next';
+import { ExclamationTriangleIcon } from '@heroicons/react/24/outline';
+import { DemoDataAssets, PUBLIC_DATA_LIST, IPublicData } from '../config';
+import { classNames } from '../../utils';
+import Spinner from '../../components/spinner';
+import { CommonStore } from '../../store/commonStore';
+
+interface IDemoDataProps {
+ commonStore: CommonStore;
+}
+
+const DemoData: React.FC<IDemoDataProps> = ({ commonStore }) => {
+ const { t } = useTranslation('translation', { keyPrefix: 'DataSource.dialog.public' });
+ const [loadingKey, setLoadingKey] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+
+ const loadDataset = async (data: IPublicData) => {
+ if (loadingKey) return;
+ setError(null);
+ setLoadingKey(data.key);
+ try {
+ const response = await fetch(DemoDataAssets[data.key]);
+ if (!response.ok) {
+ throw new Error(`${response.status} ${response.statusText}`);
+ }
+ const res = await response.json();
+ commonStore.updateTempSTDDS({
+ dataSource: res.dataSource,
+ rawFields: res.fields.map((f) => ({
+ fid: f.fid,
+ name: f.name,
+ analyticType: f.analyticType,
+ semanticType: f.semanticType,
+ dataType: f.dataType || '?',
+ })),
+ name: data.title,
+ });
+ } catch (err) {
+ console.error('Error fetching public data:', err);
+ setError(t('fetch_error', { name: data.title }));
+ } finally {
+ setLoadingKey(null);
+ }
+ };
+
+ return (
+ <div className="flex flex-col gap-2">
+ {error && (
+ <p role="alert" className="flex items-center gap-1 text-xs text-destructive">
+ <ExclamationTriangleIcon className="h-4 w-4 shrink-0" />
+ {error}
+ </p>
+ )}
+ <div className="grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3">
+ {PUBLIC_DATA_LIST.map((data) => {
+ const isLoading = loadingKey === data.key;
+ return (
+ <button
+ key={data.key}
+ type="button"
+ disabled={loadingKey !== null && !isLoading}
+ aria-busy={isLoading}
+ onClick={() => loadDataset(data)}
+ className={classNames(
+ 'flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring',
+ isLoading ? 'border-primary bg-accent' : 'hover:border-primary/50 hover:bg-accent',
+ 'disabled:cursor-default disabled:opacity-50 disabled:hover:border-border disabled:hover:bg-transparent'
+ )}
+ >
+ <div className="flex w-full items-center gap-2">
+ <span className="text-lg leading-none" aria-hidden="true">
+ {data.icon}
+ </span>
+ <span className="truncate font-medium text-foreground">{data.title}</span>
+ {isLoading && <Spinner className="ml-auto h-4 w-4 shrink-0 text-primary" />}
+ </div>
+ <p className="line-clamp-2 text-xs text-muted-foreground">{t(`datasets.${data.key}`)}</p>
+ {isLoading ? (
+ <p className="text-xs text-primary">{t('loading')}</p>
+ ) : (
+ data.rows !== undefined &&
+ data.columns !== undefined && (
+ <p className="text-xs text-muted-foreground/70">
+ {t('meta', { rows: data.rows.toLocaleString(), cols: data.columns })}
+ </p>
+ )
+ )}
+ </button>
+ );
+ })}
+ </div>
+ </div>
+ );
+};
+
+export default observer(DemoData);
diff --git a/packages/graphic-walker/src/dataSource/dataSelection/fileUpload.tsx b/packages/graphic-walker/src/dataSource/dataSelection/fileUpload.tsx
new file mode 100644
index 00000000..1ede4844
--- /dev/null
+++ b/packages/graphic-walker/src/dataSource/dataSelection/fileUpload.tsx
@@ -0,0 +1,171 @@
+import React, { useRef, useCallback, useState } from 'react';
+import { FileReader } from '@kanaries/web-data-loader';
+import { ArrowUpTrayIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline';
+import { observer } from 'mobx-react-lite';
+import { useTranslation } from 'react-i18next';
+import { IRow } from '../../interfaces';
+import DropdownSelect from '../../components/dropdownSelect';
+import Spinner from '../../components/spinner';
+import { classNames } from '../../utils';
+import { charsetOptions } from './config';
+import { jsonReader } from './utils';
+import { CommonStore } from '../../store/commonStore';
+
+interface IFileUploadProps {
+ commonStore: CommonStore;
+}
+
+const FileUpload: React.FC<IFileUploadProps> = ({ commonStore }) => {
+ const fileRef = useRef<HTMLInputElement>(null);
+ const dragCountRef = useRef(0);
+ const [dragOver, setDragOver] = useState(false);
+ const [parsingFile, setParsingFile] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const [encoding, setEncoding] = useState<string>('utf-8');
+
+ const { t } = useTranslation('translation', { keyPrefix: 'DataSource.dialog.file' });
+
+ const loadFile = useCallback(
+ (file: File) => {
+ const name = file.name;
+ const lowerName = name.toLowerCase();
+ const isJSON = lowerName.endsWith('.json');
+ const isCSV = lowerName.endsWith('.csv') || lowerName.endsWith('.tsv') || lowerName.endsWith('.txt');
+ if (!isJSON && !isCSV) {
+ setError(t('unsupported', { file: name }));
+ return;
+ }
+ setError(null);
+ setParsingFile(name);
+ const parsed: Promise<unknown> = isJSON
+ ? jsonReader(file)
+ : (FileReader.csvReader({
+ file,
+ config: { type: 'reservoirSampling', size: Infinity },
+ onLoading: () => {},
+ encoding,
+ }) as Promise<unknown>);
+ parsed
+ .then((data) => {
+ if (!Array.isArray(data) || data.length === 0) {
+ throw new Error('empty data');
+ }
+ commonStore.updateTempDS(data as IRow[]);
+ commonStore.updateTempName(name.replace(/\.(csv|tsv|txt|json)$/i, ''));
+ })
+ .catch(() => {
+ setError(t('read_error', { file: name }));
+ })
+ .finally(() => {
+ setParsingFile(null);
+ });
+ },
+ [commonStore, encoding, t]
+ );
+
+ const onDrop = useCallback(
+ (e: React.DragEvent) => {
+ e.preventDefault();
+ dragCountRef.current = 0;
+ setDragOver(false);
+ if (parsingFile) return;
+ const file = e.dataTransfer.files?.[0];
+ if (file) {
+ loadFile(file);
+ }
+ },
+ [loadFile, parsingFile]
+ );
+
+ const openFilePicker = useCallback(() => {
+ if (!parsingFile && fileRef.current) {
+ fileRef.current.click();
+ }
+ }, [parsingFile]);
+
+ return (
+ <div className="flex flex-col gap-2">
+ <input
+ style={{ display: 'none' }}
+ type="file"
+ ref={fileRef}
+ onChange={(e) => {
+ const file = e.target.files?.[0];
+ if (file) {
+ loadFile(file);
+ }
+ e.target.value = '';
+ }}
+ accept=".csv,.tsv,.txt,.json"
+ />
+ <div
+ role="button"
+ tabIndex={0}
+ aria-label={t('drop_title')}
+ className={classNames(
+ 'flex flex-col items-center justify-center gap-1 rounded-lg border-2 border-dashed px-6 py-10 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring',
+ parsingFile ? 'cursor-wait' : 'cursor-pointer',
+ dragOver ? 'border-primary bg-primary/10' : 'border-border hover:border-primary/50 hover:bg-accent/50'
+ )}
+ onClick={openFilePicker}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ openFilePicker();
+ }
+ }}
+ onDragEnter={(e) => {
+ e.preventDefault();
+ dragCountRef.current += 1;
+ setDragOver(true);
+ }}
+ onDragOver={(e) => {
+ e.preventDefault();
+ }}
+ onDragLeave={(e) => {
+ e.preventDefault();
+ dragCountRef.current -= 1;
+ if (dragCountRef.current <= 0) {
+ dragCountRef.current = 0;
+ setDragOver(false);
+ }
+ }}
+ onDrop={onDrop}
+ >
+ {parsingFile ? (
+ <>
+ <Spinner className="h-8 w-8 text-primary" />
+ <p className="mt-2 font-medium text-foreground">{t('parsing', { file: parsingFile })}</p>
+ </>
+ ) : (
+ <>
+ <ArrowUpTrayIcon className="h-8 w-8 text-muted-foreground" />
+ <p className="mt-2 font-medium text-foreground">{t('drop_title')}</p>
+ <p className="text-xs text-muted-foreground">{t('drop_desc')}</p>
+ </>
+ )}
+ </div>
+ <div className="flex items-start justify-between gap-4">
+ {error ? (
+ <p role="alert" className="flex items-center gap-1 text-xs text-destructive">
+ <ExclamationTriangleIcon className="h-4 w-4 shrink-0" />
+ {error}
+ </p>
+ ) : (
+ <span />
+ )}
+ <div className="flex shrink-0 items-center gap-2">
+ <label className="text-xs text-muted-foreground">{t('charset')}</label>
+ <DropdownSelect
+ className="text-xs !h-7"
+ options={charsetOptions}
+ selectedKey={encoding}
+ onSelect={setEncoding}
+ />
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export default observer(FileUpload);
diff --git a/packages/graphic-walker/src/dataSource/dataSelection/index.tsx b/packages/graphic-walker/src/dataSource/dataSelection/index.tsx
index 400de843..dadcff7e 100644
--- a/packages/graphic-walker/src/dataSource/dataSelection/index.tsx
+++ b/packages/graphic-walker/src/dataSource/dataSelection/index.tsx
@@ -1,32 +1,36 @@
import React from 'react';
-import CSVData from './csvData';
-import PublicData from './publicData';
+import { observer } from 'mobx-react-lite';
import { useTranslation } from 'react-i18next';
+import FileUpload from './fileUpload';
+import DemoData from './demoData';
+import DataPreview from './preview';
import { CommonStore } from '../../store/commonStore';
-import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
-const DataSelection: React.FC<{ commonStore: CommonStore }> = (props) => {
- const { commonStore } = props;
- const { t } = useTranslation('translation', { keyPrefix: 'DataSource' });
+const DataSelection: React.FC<{ commonStore: CommonStore }> = ({ commonStore }) => {
+ const { tmpDataSource, tmpDSRawFields } = commonStore;
+ const { t } = useTranslation('translation', { keyPrefix: 'DataSource.dialog' });
+ const dataLoaded = tmpDataSource.length > 0 && tmpDSRawFields.length > 0;
return (
- <div className="text-sm">
- <div className="mt-4">
- <Tabs defaultValue="file">
- <TabsList>
- <TabsTrigger value="file">{t('dialog.text_file_data')}</TabsTrigger>
- <TabsTrigger value="public">{t('dialog.public_data')}</TabsTrigger>
- </TabsList>
- <TabsContent value="file">
- <CSVData commonStore={commonStore} />
- </TabsContent>
- <TabsContent value="public">
- <PublicData commonStore={commonStore} />
- </TabsContent>
- </Tabs>
- </div>
+ <div className="mt-4 text-sm">
+ {dataLoaded ? (
+ <DataPreview commonStore={commonStore} />
+ ) : (
+ <div className="flex flex-col gap-4">
+ <FileUpload commonStore={commonStore} />
+ <div className="relative">
+ <div className="absolute inset-0 flex items-center" aria-hidden="true">
+ <span className="w-full border-t" />
+ </div>
+ <div className="relative flex justify-center">
+ <span className="bg-background px-3 text-xs uppercase tracking-wide text-muted-foreground">{t('or_demo')}</span>
+ </div>
+ </div>
+ <DemoData commonStore={commonStore} />
+ </div>
+ )}
</div>
);
};
-export default DataSelection;
+export default observer(DataSelection);
diff --git a/packages/graphic-walker/src/dataSource/dataSelection/preview.tsx b/packages/graphic-walker/src/dataSource/dataSelection/preview.tsx
new file mode 100644
index 00000000..06d4312c
--- /dev/null
+++ b/packages/graphic-walker/src/dataSource/dataSelection/preview.tsx
@@ -0,0 +1,60 @@
+import React from 'react';
+import { observer } from 'mobx-react-lite';
+import { useTranslation } from 'react-i18next';
+import { ChevronLeftIcon } from '@heroicons/react/24/outline';
+import Table from '../table';
+import { CommonStore } from '../../store/commonStore';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+
+interface IDataPreviewProps {
+ commonStore: CommonStore;
+}
+
+const DataPreview: React.FC<IDataPreviewProps> = ({ commonStore }) => {
+ const { tmpDSName, tmpDataSource, tmpDSRawFields } = commonStore;
+ const { t } = useTranslation('translation', { keyPrefix: 'DataSource.dialog.preview' });
+
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex flex-wrap items-center gap-2">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ commonStore.initTempDS();
+ }}
+ >
+ <ChevronLeftIcon className="mr-1 h-4 w-4" />
+ {t('back')}
+ </Button>
+ <Input
+ type="text"
+ aria-label={t('dataset_name')}
+ placeholder={t('dataset_name')}
+ value={tmpDSName}
+ onChange={(e) => {
+ commonStore.updateTempName(e.target.value);
+ }}
+ className="w-48"
+ />
+ <span className="text-xs text-muted-foreground">
+ {t('meta', { rows: tmpDataSource.length.toLocaleString(), cols: tmpDSRawFields.length })}
+ </span>
+ <Button
+ className="ml-auto"
+ disabled={tmpDSName.trim().length === 0}
+ onClick={() => {
+ commonStore.commitTempDS();
+ }}
+ >
+ {t('use_data')}
+ </Button>
+ </div>
+ <Table commonStore={commonStore} />
+ <p className="text-xs text-muted-foreground">{t('tip')}</p>
+ </div>
+ );
+};
+
+export default observer(DataPreview);
diff --git a/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsx b/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsx
deleted file mode 100644
index f443904f..00000000
--- a/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import React from 'react';
-import Table from '../table';
-import { DemoDataAssets, PUBLIC_DATA_LIST, IPublicData } from '../config';
-import { observer } from 'mobx-react-lite';
-import { useTranslation } from 'react-i18next';
-import { CommonStore } from '../../store/commonStore';
-import { RadioGroup } from '@headlessui/react';
-import { CheckCircleIcon } from '@heroicons/react/24/solid';
-import { classNames } from '../../utils';
-import { Button } from '@/components/ui/button';
-
-interface IPublicDataProps {
- commonStore: CommonStore;
-}
-
-const PublicData: React.FC<IPublicDataProps> = ({ commonStore }) => {
- const { tmpDataSource } = commonStore;
- const { t } = useTranslation('translation', { keyPrefix: 'DataSource.dialog.public' });
-
- const handleDataKeyChange = async (data: IPublicData) => {
- try {
- const response = await fetch(DemoDataAssets[data.key]);
- const res = await response.json();
- commonStore.updateTempSTDDS({
- dataSource: res.dataSource,
- rawFields: res.fields.map((f) => ({
- fid: f.fid,
- name: f.name,
- analyticType: f.analyticType,
- semanticType: f.semanticType,
- dataType: f.dataType || '?',
- })),
- name: data.title,
- });
- } catch (error) {
- // TODO: add error notification.
- console.error('Error fetching public data:', error);
- }
- };
-
- return (
- <div>
- <RadioGroup className="h-48 overflow-auto mb-1" by="key" onChange={handleDataKeyChange}>
- {PUBLIC_DATA_LIST.map((data) => (
- <RadioGroup.Option
- key={data.key}
- value={data}
- className={({ active, checked }) =>
- classNames(
- 'flex focus:outline-none border ring-ring rounded items-center justify-between p-2 m-2 cursor-pointer hover:bg-accent hover:text-accent-foreground',
- active ? 'ring-2 ring-offset-2' : '',
- checked ? 'bg-muted text-muted-foreground' : ''
- )
- }
- >
- {({ checked }) => (
- <>
- <RadioGroup.Label as="p">{data.title}</RadioGroup.Label>
- {checked && (
- <div className="shrink-0 text-primary">
- <CheckCircleIcon className="w-5 h-5" />
- </div>
- )}
- </>
- )}
- </RadioGroup.Option>
- ))}
- </RadioGroup>
- <Button
- className="my-1"
- disabled={tmpDataSource.length === 0}
- onClick={() => {
- commonStore.commitTempDS();
- }}
- >
- {t('submit')}
- </Button>
- <Table commonStore={commonStore} />
- </div>
- );
-};
-
-export default observer(PublicData);
diff --git a/packages/graphic-walker/src/locales/en-US.json b/packages/graphic-walker/src/locales/en-US.json
index 74874c0e..b1e1e52d 100644
--- a/packages/graphic-walker/src/locales/en-US.json
+++ b/packages/graphic-walker/src/locales/en-US.json
@@ -178,19 +178,37 @@
},
"dialog": {
"create_data_source": "New Data Source",
- "data_types": "DataSource Type",
- "text_file_data": "Local Files",
- "public_data": "Public Datasets",
- "data_source_type": "Data Source Type: {{sourceType}}",
+ "or_demo": "or try a sample dataset",
"file": {
- "open": "Open...",
- "submit": "Submit",
- "dataset_name": "Dataset Name",
- "choose_file": "Choose a Data File",
- "get_start_desc": "Get started by creating a dataset."
+ "drop_title": "Drop your CSV or JSON file here",
+ "drop_desc": "or click to browse your files",
+ "charset": "Charset",
+ "parsing": "Reading {{file}}…",
+ "unsupported": "\"{{file}}\" is not supported. Please choose a .csv or .json file.",
+ "read_error": "Could not read \"{{file}}\". Make sure it is a valid CSV or JSON file."
},
"public": {
- "submit": "Submit"
+ "loading": "Loading…",
+ "meta": "{{rows}} rows · {{cols}} fields",
+ "fetch_error": "Failed to load \"{{name}}\". Check your connection and click the dataset to try again.",
+ "datasets": {
+ "CARS": "Classic dataset of 400+ car models: MPG, horsepower, weight, and origin.",
+ "STUDENTS": "Exam scores of 1,000 students with gender, parental education, and test prep.",
+ "BIKE_SHARING": "Hourly bike rentals with weather, season, and holiday context.",
+ "EARTHQUAKE": "23,000+ earthquakes worldwide with location and magnitude.",
+ "CAR_SALES": "Sales, prices, and engine specs for 157 vehicle models.",
+ "COLLAGE": "US colleges compared by admission rate, SAT scores, and cost.",
+ "KELPER": "NASA Kepler exoplanet candidates with orbital measurements.",
+ "BTC_GOLD": "Daily Bitcoin and gold prices for comparing trading strategies.",
+ "TITANIC": "Titanic passengers: survival, class, age, and fare."
+ }
+ },
+ "preview": {
+ "back": "Back",
+ "dataset_name": "Dataset Name",
+ "meta": "{{rows}} rows · {{cols}} fields",
+ "use_data": "Use This Dataset",
+ "tip": "Tip: click a field's type icon in the table header to adjust it before importing."
}
}
},
diff --git a/packages/graphic-walker/src/locales/ja-JP.json b/packages/graphic-walker/src/locales/ja-JP.json
index 56ac6d76..e7fb4b20 100644
--- a/packages/graphic-walker/src/locales/ja-JP.json
+++ b/packages/graphic-walker/src/locales/ja-JP.json
@@ -167,19 +167,37 @@
},
"dialog": {
"create_data_source": "新しいデータソース",
- "data_types": "データソースの種類",
- "text_file_data": "ローカルファイル",
- "public_data": "公開データセット",
- "data_source_type": "データソースの種類:{{sourceType}}",
+ "or_demo": "またはサンプルデータセットを試す",
"file": {
- "open": "開く...",
- "submit": "提出する",
- "dataset_name": "データセット名",
- "choose_file": "データファイルを選択してください",
- "get_start_desc": "データセットの作成を始めましょう。"
+ "drop_title": "CSV / JSON ファイルをここにドロップ",
+ "drop_desc": "またはクリックしてファイルを選択",
+ "charset": "文字コード",
+ "parsing": "{{file}} を読み込み中…",
+ "unsupported": "「{{file}}」は対応していない形式です。.csv または .json を選択してください。",
+ "read_error": "「{{file}}」を読み込めませんでした。有効な CSV / JSON ファイルか確認してください。"
},
"public": {
- "submit": "提出する"
+ "loading": "読み込み中…",
+ "meta": "{{rows}} 行 · {{cols}} フィールド",
+ "fetch_error": "「{{name}}」の読み込みに失敗しました。接続を確認して、もう一度クリックしてください。",
+ "datasets": {
+ "CARS": "400 以上の車種の燃費・馬力・重量・生産国データ。",
+ "STUDENTS": "学生 1,000 人の試験成績と属性(性別・保護者の学歴など)。",
+ "BIKE_SHARING": "自転車シェアの時間別利用数と天候・季節データ。",
+ "EARTHQUAKE": "世界の地震 23,000 件超の位置とマグニチュード。",
+ "CAR_SALES": "157 車種の販売台数・価格・エンジン仕様。",
+ "COLLAGE": "米国大学の合格率・SAT スコア・学費データ。",
+ "KELPER": "NASA ケプラー計画の系外惑星候補と軌道データ。",
+ "BTC_GOLD": "ビットコインと金の日次価格。取引戦略の比較に。",
+ "TITANIC": "タイタニック号乗客の生存・等級・年齢・運賃。"
+ }
+ },
+ "preview": {
+ "back": "戻る",
+ "dataset_name": "データセット名",
+ "meta": "{{rows}} 行 · {{cols}} フィールド",
+ "use_data": "このデータセットを使う",
+ "tip": "ヒント:インポート前に表ヘッダーの型アイコンをクリックして調整できます。"
}
}
},
diff --git a/packages/graphic-walker/src/locales/zh-CN.json b/packages/graphic-walker/src/locales/zh-CN.json
index d2b204ac..53a4528b 100644
--- a/packages/graphic-walker/src/locales/zh-CN.json
+++ b/packages/graphic-walker/src/locales/zh-CN.json
@@ -173,19 +173,37 @@
},
"dialog": {
"create_data_source": "创建数据源",
- "data_types": "选择类型",
- "text_file_data": "导入文件",
- "public_data": "公共数据集",
- "data_source_type": "数据源类型:{{sourceType}}",
+ "or_demo": "或从示例数据集开始",
"file": {
- "open": "打开文件...",
- "submit": "确认",
- "dataset_name": "数据集名称",
- "choose_file": "选择文件",
- "get_start_desc": "创建一个数据集以开始分析"
+ "drop_title": "拖放 CSV 或 JSON 文件到这里",
+ "drop_desc": "或点击选择文件",
+ "charset": "文件编码",
+ "parsing": "正在读取 {{file}}…",
+ "unsupported": "不支持“{{file}}”的文件类型,请选择 .csv 或 .json 文件。",
+ "read_error": "无法读取“{{file}}”,请确认它是有效的 CSV 或 JSON 文件。"
},
"public": {
- "submit": "确认"
+ "loading": "正在加载…",
+ "meta": "{{rows}} 行 · {{cols}} 个字段",
+ "fetch_error": "“{{name}}”加载失败,请检查网络后点击重试。",
+ "datasets": {
+ "CARS": "400 多个经典车型:油耗、马力、重量与产地。",
+ "STUDENTS": "1000 名学生的考试成绩,含性别、父母教育程度与备考情况。",
+ "BIKE_SHARING": "共享单车每小时租借量,含天气、季节与节假日信息。",
+ "EARTHQUAKE": "全球 2.3 万余次地震的位置与震级记录。",
+ "CAR_SALES": "157 款车型的销量、价格与发动机参数。",
+ "COLLAGE": "美国高校数据:录取率、SAT 分数与费用。",
+ "KELPER": "NASA 开普勒系外行星候选体及轨道参数。",
+ "BTC_GOLD": "比特币与黄金每日价格,适合对比交易策略。",
+ "TITANIC": "泰坦尼克号乘客:生还情况、舱位、年龄与票价。"
+ }
+ },
+ "preview": {
+ "back": "返回",
+ "dataset_name": "数据集名称",
+ "meta": "{{rows}} 行 · {{cols}} 个字段",
+ "use_data": "使用此数据集",
+ "tip": "提示:导入前可点击表头中的字段类型图标进行调整。"
}
}
},