@kanaries/graphic-walker 0.2.14 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +5 -2
- package/dist/assets/explainer.worker-8428eb12.js.map +1 -1
- package/dist/assets/transform.worker-5d54ff09.js.map +1 -0
- package/dist/assets/viewQuery.worker-ffefc111.js.map +1 -0
- package/dist/components/callout.d.ts +2 -0
- package/dist/components/codeExport/index.d.ts +3 -0
- package/dist/components/loadingLayer.d.ts +2 -0
- package/dist/components/tabs/defaultTab.d.ts +1 -0
- package/dist/components/tabs/editableTab.d.ts +1 -2
- package/dist/components/toolbar/components.d.ts +4 -1
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/toolbar-item.d.ts +3 -0
- package/dist/components/tooltip.d.ts +2 -0
- package/dist/dataSource/dataSelection/config.d.ts +1 -0
- package/dist/dataSource/dataSelection/utils.d.ts +2 -0
- package/dist/datasets/tmp/test.json +1 -0
- package/dist/fields/components.d.ts +0 -1
- package/dist/fields/filterField/filterEditDialog.d.ts +1 -1
- package/dist/graphic-walker.es.js +23930 -23320
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +143 -273
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/interfaces.d.ts +23 -1
- package/dist/lib/execExp.d.ts +8 -0
- package/dist/lib/interfaces.d.ts +22 -0
- package/dist/lib/op/aggregate.d.ts +3 -0
- package/dist/lib/op/bin.d.ts +3 -0
- package/dist/lib/op/fold.d.ts +3 -0
- package/dist/lib/op/stat.d.ts +8 -0
- package/dist/lib/viewQuery.d.ts +5 -0
- package/dist/models/visSpecHistory.d.ts +2 -0
- package/dist/renderer/index.d.ts +6 -3
- package/dist/renderer/specRenderer.d.ts +13 -0
- package/dist/services.d.ts +4 -1
- package/dist/store/commonStore.d.ts +6 -0
- package/dist/store/index.d.ts +3 -2
- package/dist/store/visualSpecStore.d.ts +11 -4
- package/dist/utils/dataPrep.d.ts +2 -0
- package/dist/utils/index.d.ts +3 -5
- package/dist/utils/media.d.ts +2 -1
- package/dist/utils/save.d.ts +1 -2
- package/dist/vis/react-vega.d.ts +4 -23
- package/dist/vis/spec/aggregate.d.ts +4 -0
- package/dist/vis/spec/encode.d.ts +19 -0
- package/dist/vis/spec/field.d.ts +2 -0
- package/dist/vis/spec/mark.d.ts +7 -0
- package/dist/vis/spec/stack.d.ts +4 -0
- package/dist/vis/spec/view.d.ts +67 -0
- package/dist/vis/theme.d.ts +36 -20
- package/dist/visualSettings/index.d.ts +2 -1
- package/dist/workers/transform.d.ts +2 -0
- package/package.json +4 -3
- package/src/App.tsx +23 -15
- package/src/components/callout.tsx +9 -7
- package/src/components/clickMenu.tsx +1 -7
- package/src/components/codeExport/index.tsx +114 -0
- package/src/components/dataTable/index.tsx +10 -10
- package/src/components/loadingLayer.tsx +7 -0
- package/src/components/modal.tsx +1 -15
- package/src/components/sizeSetting.tsx +2 -2
- package/src/components/tabs/defaultTab.tsx +4 -2
- package/src/components/tabs/editableTab.tsx +75 -40
- package/src/components/toolbar/components.tsx +8 -23
- package/src/components/toolbar/index.tsx +11 -4
- package/src/components/toolbar/toolbar-button.tsx +2 -1
- package/src/components/toolbar/toolbar-item.tsx +17 -12
- package/src/components/toolbar/toolbar-select-button.tsx +9 -13
- package/src/components/toolbar/toolbar-toggle-button.tsx +2 -1
- package/src/components/tooltip.tsx +10 -6
- package/src/dataSource/dataSelection/config.ts +11 -0
- package/src/dataSource/dataSelection/csvData.tsx +72 -40
- package/src/dataSource/dataSelection/gwFile.tsx +2 -2
- package/src/dataSource/dataSelection/utils.ts +28 -0
- package/src/dataSource/index.tsx +2 -3
- package/src/dataSource/utils.ts +8 -3
- package/src/fields/components.tsx +13 -50
- package/src/fields/datasetFields/index.tsx +3 -4
- package/src/fields/datasetFields/meaFields.tsx +12 -4
- package/src/fields/encodeFields/singleEncodeEditor.tsx +1 -1
- package/src/fields/filterField/filterEditDialog.tsx +63 -99
- package/src/fields/filterField/slider.tsx +1 -1
- package/src/index.css +4 -4
- package/src/index.tsx +22 -22
- package/src/insightBoard/mainBoard.tsx +9 -2
- package/src/interfaces.ts +30 -3
- package/src/lib/execExp.ts +147 -0
- package/src/lib/interfaces.ts +39 -0
- package/src/lib/op/aggregate.ts +49 -0
- package/src/lib/op/bin.ts +25 -0
- package/src/lib/op/fold.ts +17 -0
- package/src/lib/op/stat.ts +46 -0
- package/src/lib/viewQuery.ts +23 -0
- package/src/locales/en-US.json +8 -3
- package/src/locales/i18n.ts +7 -1
- package/src/locales/ja-JP.json +197 -0
- package/src/locales/zh-CN.json +8 -3
- package/src/main.tsx +1 -1
- package/src/models/visSpecHistory.ts +14 -0
- package/src/renderer/index.tsx +58 -101
- package/src/renderer/specRenderer.tsx +119 -0
- package/src/segments/segmentNav.tsx +3 -16
- package/src/segments/visNav.tsx +17 -6
- package/src/services.ts +37 -1
- package/src/store/commonStore.ts +14 -9
- package/src/store/index.tsx +11 -4
- package/src/store/visualSpecStore.ts +89 -50
- package/src/utils/dataPrep.ts +24 -0
- package/src/utils/index.ts +16 -17
- package/src/utils/media.ts +16 -11
- package/src/utils/normalization.ts +3 -1
- package/src/utils/save.ts +1 -2
- package/src/vis/react-vega.tsx +11 -332
- package/src/vis/spec/aggregate.ts +13 -0
- package/src/vis/spec/encode.ts +69 -0
- package/src/vis/spec/field.ts +10 -0
- package/src/vis/spec/mark.ts +30 -0
- package/src/vis/spec/stack.ts +11 -0
- package/src/vis/spec/view.ts +138 -0
- package/src/vis/theme.ts +35 -25
- package/src/visualSettings/index.tsx +22 -33
- package/src/workers/transform.ts +12 -0
- package/src/workers/transform.worker.js +13 -0
- package/src/workers/viewQuery.worker.js +16 -0
- package/dist/components/container.d.ts +0 -2
- package/dist/dataSource/pannel.d.ts +0 -5
- package/src/components/container.tsx +0 -25
- package/src/dataSource/pannel.tsx +0 -71
package/src/vis/theme.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
const DEFAULT_COLOR = "#5B8FF9";
|
|
2
|
-
|
|
2
|
+
const DARK_COMMON_DESIGN = {
|
|
3
|
+
background: "transparent",
|
|
4
|
+
header: {
|
|
5
|
+
titleColor: "#d1d5db", // change title color to white
|
|
6
|
+
labelColor: "#d1d5db", // change label color to white
|
|
7
|
+
},
|
|
8
|
+
axis: {
|
|
9
|
+
gridColor: "#666",
|
|
10
|
+
domainColor: "#d1d5db", // change axis color to white
|
|
11
|
+
tickColor: "#d1d5db", // change tick color to white
|
|
12
|
+
labelColor: "#d1d5db", // change label color to white
|
|
13
|
+
titleColor: "#d1d5db", // change title color to white
|
|
14
|
+
},
|
|
15
|
+
legend: {
|
|
16
|
+
labelColor: "#d1d5db", // change legend label color to white
|
|
17
|
+
titleColor: "#d1d5db" // change legend title color to white
|
|
18
|
+
},
|
|
19
|
+
view: {
|
|
20
|
+
stroke: '#666'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
3
23
|
export const VegaTheme = {
|
|
4
24
|
light: {
|
|
5
25
|
background: "transparent",
|
|
6
26
|
},
|
|
7
|
-
dark:
|
|
8
|
-
background: "transparent",
|
|
9
|
-
axis: {
|
|
10
|
-
gridColor: "#666",
|
|
11
|
-
domainColor: "#d1d5db", // change axis color to white
|
|
12
|
-
tickColor: "#d1d5db", // change tick color to white
|
|
13
|
-
labelColor: "#d1d5db", // change label color to white
|
|
14
|
-
},
|
|
15
|
-
legend: {
|
|
16
|
-
labelColor: "#d1d5db", // change legend label color to white
|
|
17
|
-
titleColor: "#d1d5db" // change legend title color to white
|
|
18
|
-
},
|
|
19
|
-
},
|
|
27
|
+
dark: DARK_COMMON_DESIGN
|
|
20
28
|
} as const;
|
|
21
29
|
|
|
22
30
|
export const AntVTheme = {
|
|
@@ -48,6 +56,18 @@ export const AntVTheme = {
|
|
|
48
56
|
],
|
|
49
57
|
diverging: ["#7b3294", "#c2a5cf", "#f7f7f7", "#a6dba0", "#008837"],
|
|
50
58
|
heatmap: ["#000000", "#7b3294", "#c2a5cf", "#f7f7f7", "#a6dba0", "#008837"],
|
|
59
|
+
// ordinal: [
|
|
60
|
+
// '#B8E1FF',
|
|
61
|
+
// // '#9AC5FF',
|
|
62
|
+
// // '#7DAAFF',
|
|
63
|
+
// // '#5B8FF9',
|
|
64
|
+
// // '#3D76DD',
|
|
65
|
+
// // '#085EC0',
|
|
66
|
+
// // '#0047A5',
|
|
67
|
+
// // '#00318A',
|
|
68
|
+
// '#001D70'
|
|
69
|
+
// ],
|
|
70
|
+
// ordinal: 'blues',
|
|
51
71
|
ramp: [
|
|
52
72
|
"#EBCCFF",
|
|
53
73
|
"#CCB0FF",
|
|
@@ -65,6 +85,7 @@ export const AntVTheme = {
|
|
|
65
85
|
},
|
|
66
86
|
},
|
|
67
87
|
dark: {
|
|
88
|
+
...DARK_COMMON_DESIGN,
|
|
68
89
|
area: { fill: DEFAULT_COLOR },
|
|
69
90
|
bar: { fill: DEFAULT_COLOR },
|
|
70
91
|
circle: { fill: DEFAULT_COLOR },
|
|
@@ -76,17 +97,6 @@ export const AntVTheme = {
|
|
|
76
97
|
errorbar: { stroke: DEFAULT_COLOR },
|
|
77
98
|
errorband: { fill: DEFAULT_COLOR },
|
|
78
99
|
arc: { fill: DEFAULT_COLOR },
|
|
79
|
-
background: "transparent", // change background color to dark gray
|
|
80
|
-
axis: {
|
|
81
|
-
gridColor: "#666",
|
|
82
|
-
domainColor: "#d1d5db", // change axis color to white
|
|
83
|
-
tickColor: "#d1d5db", // change tick color to white
|
|
84
|
-
labelColor: "#d1d5db", // change label color to white
|
|
85
|
-
},
|
|
86
|
-
legend: {
|
|
87
|
-
labelColor: "#d1d5db", // change legend label color to white
|
|
88
|
-
titleColor: "#d1d5db" // change legend title color to white
|
|
89
|
-
},
|
|
90
100
|
range: {
|
|
91
101
|
category: [
|
|
92
102
|
"#5B8FF9",
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
ChevronDoubleUpIcon,
|
|
22
22
|
ArrowsUpDownIcon,
|
|
23
23
|
LightBulbIcon,
|
|
24
|
+
CodeBracketSquareIcon,
|
|
24
25
|
} from '@heroicons/react/24/outline';
|
|
25
26
|
import { observer } from 'mobx-react-lite';
|
|
26
27
|
import React, { SVGProps, useCallback, useMemo } from 'react';
|
|
@@ -29,38 +30,14 @@ import { useTranslation } from 'react-i18next';
|
|
|
29
30
|
import { ResizeDialog } from '../components/sizeSetting';
|
|
30
31
|
import { GEMO_TYPES, STACK_MODE, CHART_LAYOUT_TYPE } from '../config';
|
|
31
32
|
import { useGlobalStore } from '../store';
|
|
32
|
-
import { IStackMode, EXPLORATION_TYPES, IBrushDirection, BRUSH_DIRECTIONS } from '../interfaces';
|
|
33
|
+
import { IStackMode, EXPLORATION_TYPES, IBrushDirection, BRUSH_DIRECTIONS, IDarkMode } from '../interfaces';
|
|
33
34
|
import { IReactVegaHandler } from '../vis/react-vega';
|
|
34
35
|
import Toolbar, { ToolbarItemProps } from '../components/toolbar';
|
|
35
36
|
import { ButtonWithShortcut } from './menubar';
|
|
37
|
+
import { useCurrentMediaTheme } from '../utils/media';
|
|
36
38
|
import throttle from '../utils/throttle';
|
|
37
39
|
|
|
38
40
|
|
|
39
|
-
export const LiteContainer = styled.div`
|
|
40
|
-
margin: 0.2em;
|
|
41
|
-
border: 1px solid #e5e7eb;
|
|
42
|
-
padding: 1em;
|
|
43
|
-
background-color: #fff;
|
|
44
|
-
@media (prefers-color-scheme: dark) {
|
|
45
|
-
background-color: #000;
|
|
46
|
-
border: 1px solid #4b5563;
|
|
47
|
-
}
|
|
48
|
-
.menu-root {
|
|
49
|
-
position: relative;
|
|
50
|
-
& > *:not(.trigger) {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
position: absolute;
|
|
54
|
-
right: 0;
|
|
55
|
-
top: 100%;
|
|
56
|
-
border: 1px solid #8884;
|
|
57
|
-
}
|
|
58
|
-
&:not(:hover) > *:not(.trigger):not(:hover) {
|
|
59
|
-
display: none;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
41
|
const Invisible = styled.div`
|
|
65
42
|
clip: rect(1px, 1px, 1px, 1px);
|
|
66
43
|
clip-path: inset(50%);
|
|
@@ -79,17 +56,18 @@ const FormContainer = styled.div`
|
|
|
79
56
|
display: flex;
|
|
80
57
|
flex-direction: column;
|
|
81
58
|
color: #444;
|
|
82
|
-
|
|
59
|
+
.dark {
|
|
83
60
|
color: #aaa;
|
|
84
61
|
}
|
|
85
62
|
`;
|
|
86
63
|
|
|
87
64
|
interface IVisualSettings {
|
|
65
|
+
darkModePreference: IDarkMode;
|
|
88
66
|
rendererHandler?: React.RefObject<IReactVegaHandler>;
|
|
89
67
|
}
|
|
90
68
|
|
|
91
|
-
const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler }) => {
|
|
92
|
-
const { vizStore } = useGlobalStore();
|
|
69
|
+
const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePreference }) => {
|
|
70
|
+
const { vizStore, commonStore } = useGlobalStore();
|
|
93
71
|
const { visualConfig, canUndo, canRedo } = vizStore;
|
|
94
72
|
const { t: tGlobal } = useTranslation();
|
|
95
73
|
const { t } = useTranslation('translation', { keyPrefix: 'main.tabpanel.settings' });
|
|
@@ -107,6 +85,8 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler }) => {
|
|
|
107
85
|
rendererHandler?.current?.downloadSVG();
|
|
108
86
|
}, 200), [rendererHandler]);
|
|
109
87
|
|
|
88
|
+
const dark = useCurrentMediaTheme(darkModePreference) === 'dark';
|
|
89
|
+
|
|
110
90
|
const items = useMemo<ToolbarItemProps[]>(() => {
|
|
111
91
|
return [
|
|
112
92
|
{
|
|
@@ -338,16 +318,16 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler }) => {
|
|
|
338
318
|
label: t('button.export_chart'),
|
|
339
319
|
icon: PhotoIcon,
|
|
340
320
|
form: (
|
|
341
|
-
<FormContainer>
|
|
321
|
+
<FormContainer className={dark ? 'dark' : ''}>
|
|
342
322
|
<button
|
|
343
|
-
className=
|
|
323
|
+
className={`text-xs pt-1 pb-1 pl-6 pr-6 ${dark ? 'dark bg-zinc-900 text-gray-100 hover:bg-gray-700' : 'bg-white hover:bg-gray-200 text-gray-800'}`}
|
|
344
324
|
aria-label={t('button.export_chart_as', { type: 'png' })}
|
|
345
325
|
onClick={() => downloadPNG()}
|
|
346
326
|
>
|
|
347
327
|
{t('button.export_chart_as', { type: 'png' })}
|
|
348
328
|
</button>
|
|
349
329
|
<button
|
|
350
|
-
className=
|
|
330
|
+
className={`text-xs pt-1 pb-1 pl-6 pr-6 ${dark ? 'dark bg-zinc-900 text-gray-100 hover:bg-gray-700' : 'bg-white hover:bg-gray-200 text-gray-800'}`}
|
|
351
331
|
aria-label={t('button.export_chart_as', { type: 'svg' })}
|
|
352
332
|
onClick={() => downloadSVG()}
|
|
353
333
|
>
|
|
@@ -356,11 +336,20 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler }) => {
|
|
|
356
336
|
</FormContainer>
|
|
357
337
|
),
|
|
358
338
|
},
|
|
339
|
+
{
|
|
340
|
+
key: 'export_code',
|
|
341
|
+
label: t('button.export_code'),
|
|
342
|
+
icon: CodeBracketSquareIcon,
|
|
343
|
+
onClick: () => {
|
|
344
|
+
commonStore.setShowCodeExportPanel(true);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
359
347
|
] as ToolbarItemProps[];
|
|
360
|
-
}, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height, explorationMode, brushDirection, showActions, downloadPNG, downloadSVG]);
|
|
348
|
+
}, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height, explorationMode, brushDirection, showActions, downloadPNG, downloadSVG, dark]);
|
|
361
349
|
|
|
362
350
|
return <div style={{ margin: '0.38em 0.28em 0.2em 0.18em' }}>
|
|
363
351
|
<Toolbar
|
|
352
|
+
darkModePreference={darkModePreference}
|
|
364
353
|
items={items}
|
|
365
354
|
styles={{
|
|
366
355
|
root: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IField, IRow } from "../interfaces";
|
|
2
|
+
import { dataframe2Dataset, dataset2DataFrame, execExpression } from "../lib/execExp";
|
|
3
|
+
|
|
4
|
+
export function transformData(data: IRow[], columns: IField[]) {
|
|
5
|
+
const computedFields = columns.filter((f) => f.computed);
|
|
6
|
+
let df = dataset2DataFrame(data, columns);
|
|
7
|
+
for (let i = 0; i < computedFields.length; i++) {
|
|
8
|
+
const field = computedFields[i];
|
|
9
|
+
df = execExpression(field.expressoion!, df, columns);
|
|
10
|
+
}
|
|
11
|
+
return dataframe2Dataset(df, columns);
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { transformData } from './transform'
|
|
2
|
+
const main = e => {
|
|
3
|
+
const { dataSource, columns } = e.data;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const ans = transformData(dataSource, columns);
|
|
7
|
+
self.postMessage(ans);
|
|
8
|
+
} catch (error) {
|
|
9
|
+
self.postMessage({ error: error.message });
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
self.addEventListener('message', main, false);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { queryView } from '../lib/viewQuery'
|
|
2
|
+
const main = e => {
|
|
3
|
+
try {
|
|
4
|
+
const { dataSource, metas, query } = e.data;
|
|
5
|
+
const ans = queryView(dataSource, metas, query);
|
|
6
|
+
self.postMessage(ans);
|
|
7
|
+
|
|
8
|
+
} catch (err) {
|
|
9
|
+
// console.log(err.s)
|
|
10
|
+
// log err stack
|
|
11
|
+
console.error(err.stack);
|
|
12
|
+
self.postMessage(err.stack);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
self.addEventListener('message', main, false);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
|
|
3
|
-
export const Container = styled.div`
|
|
4
|
-
border: 1px solid #e5e7eb;
|
|
5
|
-
padding: 1em;
|
|
6
|
-
margin: 1em;
|
|
7
|
-
background-color: #fff;
|
|
8
|
-
// dark theme
|
|
9
|
-
@media (prefers-color-scheme: dark) {
|
|
10
|
-
background-color: #000;
|
|
11
|
-
border: 1px solid #4b5563;
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
export const NestContainer = styled.div`
|
|
16
|
-
border: 1px solid #e5e7eb;
|
|
17
|
-
padding: 0.4em;
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
margin: 0.2em;
|
|
20
|
-
background-color: #fff;
|
|
21
|
-
@media (prefers-color-scheme: dark) {
|
|
22
|
-
background-color: #000;
|
|
23
|
-
border: 1px solid #4b5563;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useCallback } from 'react';
|
|
2
|
-
import { FileReader } from '@kanaries/web-data-loader';
|
|
3
|
-
import { IRow } from '../interfaces';
|
|
4
|
-
import Table from './table';
|
|
5
|
-
import styled from 'styled-components';
|
|
6
|
-
import { useGlobalStore } from '../store';
|
|
7
|
-
import { observer } from 'mobx-react-lite';
|
|
8
|
-
|
|
9
|
-
const Container = styled.div`
|
|
10
|
-
overflow-x: auto;
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
interface DSPanelProps {
|
|
14
|
-
}
|
|
15
|
-
const DataSourcePanel: React.FC<DSPanelProps> = props => {
|
|
16
|
-
const fileRef = useRef<HTMLInputElement>(null);
|
|
17
|
-
const { commonStore } = useGlobalStore();
|
|
18
|
-
const { tmpDSName, tmpDataSource } = commonStore;
|
|
19
|
-
|
|
20
|
-
const onSubmitData = useCallback(() => {
|
|
21
|
-
commonStore.commitTempDS();
|
|
22
|
-
}, [])
|
|
23
|
-
return (
|
|
24
|
-
<Container>
|
|
25
|
-
<input
|
|
26
|
-
style={{ display: 'none' }}
|
|
27
|
-
type="file"
|
|
28
|
-
ref={fileRef}
|
|
29
|
-
onChange={(e) => {
|
|
30
|
-
const files = e.target.files;
|
|
31
|
-
if (files !== null) {
|
|
32
|
-
const file = files[0];
|
|
33
|
-
FileReader.csvReader({
|
|
34
|
-
file,
|
|
35
|
-
config: { type: 'reservoirSampling', size: Infinity },
|
|
36
|
-
onLoading: () => {}
|
|
37
|
-
}).then((data) => {
|
|
38
|
-
commonStore.updateTempDS(data as IRow[]);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
<div className="mt-1 mb-1">
|
|
44
|
-
<button className="inline-block min-w-96 text-xs mr-2 pt-1 pb-1 pl-6 pr-6 border border-gray-500 rounded-sm cursor-pointer hover:bg-gray-200"
|
|
45
|
-
onClick={() => { if (fileRef.current) { fileRef.current.click(); }}}
|
|
46
|
-
>
|
|
47
|
-
上传数据
|
|
48
|
-
</button>
|
|
49
|
-
<button className="inline-block min-w-96 text-xs mr-2 pt-1 pb-1 pl-6 pr-6 bg-yellow-600 rounded-sm hover:bg-yellow-500 text-white font-bold disabled:bg-gray-300"
|
|
50
|
-
disabled={tmpDataSource.length === 0}
|
|
51
|
-
onClick={() => { onSubmitData(); }}
|
|
52
|
-
>
|
|
53
|
-
确认
|
|
54
|
-
</button>
|
|
55
|
-
</div>
|
|
56
|
-
<div className="mt-1 mb-1">
|
|
57
|
-
<label className="block text-xs text-gray-800">数据集名称</label>
|
|
58
|
-
<input type="text" placeholder="数据集名称"
|
|
59
|
-
value={tmpDSName}
|
|
60
|
-
onChange={e => {
|
|
61
|
-
commonStore.updateTempName(e.target.value)
|
|
62
|
-
}}
|
|
63
|
-
className="text-xs p-1 border border-gray-200 outline-none focus:outline-none focus:border-blue-500"
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
<Table />
|
|
67
|
-
</Container>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default observer(DataSourcePanel);
|