@kanaries/graphic-walker 0.2.15 → 0.2.17
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 +4 -3
- package/dist/assets/transform.worker-5d54ff09.js.map +1 -0
- package/dist/assets/viewQuery.worker-ffefc111.js.map +1 -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/dataSource/dataSelection/config.d.ts +1 -0
- package/dist/dataSource/dataSelection/utils.d.ts +2 -0
- package/dist/dataSource/index.d.ts +0 -1
- package/dist/datasets/tmp/test.json +1 -0
- package/dist/fields/encodeFields/singleEncodeEditor.d.ts +4 -4
- package/dist/graphic-walker.es.js +29228 -33650
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +218 -256
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/interfaces.d.ts +52 -17
- package/dist/lib/execExp.d.ts +8 -0
- package/dist/lib/inferMeta.d.ts +2 -9
- package/dist/lib/insights/explainByChildren.d.ts +16 -0
- package/dist/lib/insights/explainBySelection.d.ts +5 -0
- package/dist/lib/insights/explainValue.d.ts +2 -0
- package/dist/lib/insights/utils.d.ts +11 -0
- package/dist/lib/interfaces.d.ts +23 -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 +4 -0
- package/dist/models/visSpecHistory.d.ts +2 -0
- package/dist/renderer/index.d.ts +8 -7
- package/dist/renderer/specRenderer.d.ts +13 -0
- package/dist/services.d.ts +5 -31
- package/dist/store/commonStore.d.ts +6 -0
- package/dist/store/index.d.ts +3 -2
- package/dist/store/visualSpecStore.d.ts +11 -5
- package/dist/utils/autoMark.d.ts +1 -1
- package/dist/utils/dataPrep.d.ts +3 -2
- package/dist/utils/index.d.ts +3 -5
- package/dist/utils/save.d.ts +1 -2
- package/dist/vis/react-vega.d.ts +2 -22
- package/dist/vis/spec/aggregate.d.ts +4 -0
- package/dist/vis/spec/encode.d.ts +20 -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/tooltip.d.ts +4 -0
- package/dist/vis/spec/view.d.ts +73 -0
- package/dist/workers/transform.d.ts +2 -0
- package/package.json +5 -6
- package/src/App.tsx +56 -66
- 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/tabs/defaultTab.tsx +4 -2
- package/src/components/tabs/editableTab.tsx +74 -39
- package/src/dataSource/dataSelection/config.ts +11 -0
- package/src/dataSource/dataSelection/csvData.tsx +71 -39
- package/src/dataSource/dataSelection/gwFile.tsx +2 -2
- package/src/dataSource/dataSelection/utils.ts +28 -0
- package/src/dataSource/index.tsx +0 -17
- package/src/dataSource/utils.ts +8 -3
- package/src/fields/aestheticFields.tsx +1 -2
- package/src/fields/datasetFields/meaFields.tsx +12 -4
- package/src/fields/encodeFields/singleEncodeEditor.tsx +11 -12
- package/src/fields/fieldsContext.tsx +1 -0
- package/src/index.css +4 -4
- package/src/index.tsx +22 -22
- package/src/interfaces.ts +85 -49
- package/src/lib/execExp.ts +147 -0
- package/src/lib/inferMeta.ts +26 -29
- package/src/lib/insights/explainByChildren.ts +50 -0
- package/src/lib/insights/explainBySelection.ts +47 -0
- package/src/lib/insights/explainValue.ts +30 -0
- package/src/lib/insights/utils.ts +21 -0
- package/src/lib/interfaces.ts +33 -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 +22 -0
- package/src/locales/en-US.json +6 -3
- package/src/locales/i18n.ts +0 -1
- package/src/locales/ja-JP.json +4 -2
- package/src/locales/zh-CN.json +6 -3
- package/src/main.tsx +1 -1
- package/src/models/visSpecHistory.ts +14 -0
- package/src/renderer/index.tsx +58 -126
- package/src/renderer/specRenderer.tsx +121 -0
- package/src/segments/segmentNav.tsx +3 -16
- package/src/segments/visNav.tsx +17 -6
- package/src/services.ts +101 -67
- package/src/store/commonStore.ts +14 -9
- package/src/store/index.tsx +11 -4
- package/src/store/visualSpecStore.ts +89 -52
- package/src/utils/autoMark.ts +1 -1
- package/src/utils/dataPrep.ts +25 -2
- package/src/utils/index.ts +16 -17
- package/src/utils/normalization.ts +3 -1
- package/src/utils/save.ts +1 -2
- package/src/vis/react-vega.tsx +9 -340
- package/src/vis/spec/aggregate.ts +13 -0
- package/src/vis/spec/encode.ts +70 -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/tooltip.ts +16 -0
- package/src/vis/spec/view.ts +136 -0
- package/src/vis/theme.ts +12 -0
- package/src/visualSettings/index.tsx +10 -1
- 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/assets/explainer.worker-8428eb12.js.map +0 -1
- package/dist/dataSource/pannel.d.ts +0 -5
- package/dist/insightBoard/index.d.ts +0 -3
- package/dist/insightBoard/mainBoard.d.ts +0 -11
- package/dist/insightBoard/radioGroupButtons.d.ts +0 -12
- package/dist/insightBoard/selectionSpec.d.ts +0 -13
- package/dist/insightBoard/std2vegaSpec.d.ts +0 -12
- package/dist/insightBoard/utils.d.ts +0 -8
- package/dist/insights.d.ts +0 -61
- package/src/dataSource/pannel.tsx +0 -71
- package/src/insightBoard/index.tsx +0 -31
- package/src/insightBoard/mainBoard.tsx +0 -224
- package/src/insightBoard/radioGroupButtons.tsx +0 -57
- package/src/insightBoard/selectionSpec.ts +0 -113
- package/src/insightBoard/std2vegaSpec.ts +0 -184
- package/src/insightBoard/utils.ts +0 -32
- package/src/insights.ts +0 -408
- package/src/workers/explainer.worker.js +0 -76
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ISemanticType, IStackMode, IViewField } from '../../interfaces';
|
|
2
|
+
import { autoMark } from './mark';
|
|
3
|
+
import { NULL_FIELD } from './field';
|
|
4
|
+
import { channelAggregate } from './aggregate';
|
|
5
|
+
import { IEncodeProps, channelEncode } from './encode';
|
|
6
|
+
import { channelStack } from './stack';
|
|
7
|
+
import { addTooltipEncode } from './tooltip';
|
|
8
|
+
|
|
9
|
+
const BRUSH_SIGNAL_NAME = '__gw_brush__';
|
|
10
|
+
const POINT_SIGNAL_NAME = '__gw_point__';
|
|
11
|
+
export interface SingleViewProps extends IEncodeProps {
|
|
12
|
+
defaultAggregated: boolean;
|
|
13
|
+
stack: IStackMode;
|
|
14
|
+
enableCrossFilter: boolean;
|
|
15
|
+
asCrossFilterTrigger: boolean;
|
|
16
|
+
selectEncoding: 'default' | 'none';
|
|
17
|
+
brushEncoding: 'x' | 'y' | 'default' | 'none';
|
|
18
|
+
hideLegend?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export function getSingleView(props: SingleViewProps) {
|
|
21
|
+
const {
|
|
22
|
+
x,
|
|
23
|
+
y,
|
|
24
|
+
color,
|
|
25
|
+
opacity,
|
|
26
|
+
size,
|
|
27
|
+
shape,
|
|
28
|
+
theta,
|
|
29
|
+
radius,
|
|
30
|
+
row,
|
|
31
|
+
column,
|
|
32
|
+
xOffset,
|
|
33
|
+
yOffset,
|
|
34
|
+
details,
|
|
35
|
+
defaultAggregated,
|
|
36
|
+
stack,
|
|
37
|
+
geomType,
|
|
38
|
+
selectEncoding,
|
|
39
|
+
brushEncoding,
|
|
40
|
+
enableCrossFilter,
|
|
41
|
+
asCrossFilterTrigger,
|
|
42
|
+
hideLegend = false,
|
|
43
|
+
} = props;
|
|
44
|
+
const fields: IViewField[] = [x, y, color, opacity, size, shape, row, column, xOffset, yOffset, theta, radius];
|
|
45
|
+
let markType = geomType;
|
|
46
|
+
let config: any = {};
|
|
47
|
+
if (hideLegend) {
|
|
48
|
+
config.legend = {
|
|
49
|
+
disable: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (geomType === 'auto') {
|
|
53
|
+
const types: ISemanticType[] = [];
|
|
54
|
+
if (x !== NULL_FIELD) types.push(x.semanticType); //types.push(getFieldType(x));
|
|
55
|
+
if (y !== NULL_FIELD) types.push(y.semanticType); //types.push(getFieldType(yField));
|
|
56
|
+
markType = autoMark(types);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let encoding = channelEncode({
|
|
60
|
+
geomType: markType,
|
|
61
|
+
x,
|
|
62
|
+
y,
|
|
63
|
+
color,
|
|
64
|
+
opacity,
|
|
65
|
+
size,
|
|
66
|
+
shape,
|
|
67
|
+
row,
|
|
68
|
+
column,
|
|
69
|
+
xOffset,
|
|
70
|
+
yOffset,
|
|
71
|
+
theta,
|
|
72
|
+
radius,
|
|
73
|
+
details
|
|
74
|
+
});
|
|
75
|
+
addTooltipEncode(encoding, details)
|
|
76
|
+
if (defaultAggregated) {
|
|
77
|
+
channelAggregate(encoding, fields);
|
|
78
|
+
}
|
|
79
|
+
channelStack(encoding, stack);
|
|
80
|
+
const mark = {
|
|
81
|
+
type: markType,
|
|
82
|
+
opacity: 0.96,
|
|
83
|
+
tooltip: { content: 'data' }
|
|
84
|
+
};
|
|
85
|
+
if (!enableCrossFilter || (brushEncoding === 'none' && selectEncoding === 'none')) {
|
|
86
|
+
return {
|
|
87
|
+
config,
|
|
88
|
+
mark,
|
|
89
|
+
encoding,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (brushEncoding !== 'none') {
|
|
94
|
+
return {
|
|
95
|
+
config,
|
|
96
|
+
transform: asCrossFilterTrigger ? [] : [{ filter: { param: BRUSH_SIGNAL_NAME } }],
|
|
97
|
+
params: [
|
|
98
|
+
// {
|
|
99
|
+
// name: BRUSH_SIGNAL_DISPLAY_NAME,
|
|
100
|
+
// select: { type: 'interval', encodings: brushEncoding === 'default' ? undefined : [brushEncoding] },
|
|
101
|
+
// on: '__YOU_CANNOT_MODIFY_THIS_SIGNAL__',
|
|
102
|
+
// },
|
|
103
|
+
{
|
|
104
|
+
name: BRUSH_SIGNAL_NAME,
|
|
105
|
+
select: { type: 'interval', encodings: brushEncoding === 'default' ? undefined : [brushEncoding] },
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
mark,
|
|
109
|
+
encoding,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
config,
|
|
115
|
+
transform: asCrossFilterTrigger ? [] : [{ filter: { param: POINT_SIGNAL_NAME } }],
|
|
116
|
+
params: [
|
|
117
|
+
{
|
|
118
|
+
name: POINT_SIGNAL_NAME,
|
|
119
|
+
select: { type: 'point' },
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
mark,
|
|
123
|
+
encoding: asCrossFilterTrigger
|
|
124
|
+
? {
|
|
125
|
+
...encoding,
|
|
126
|
+
color: {
|
|
127
|
+
condition: {
|
|
128
|
+
...encoding.color,
|
|
129
|
+
param: POINT_SIGNAL_NAME,
|
|
130
|
+
},
|
|
131
|
+
value: '#888',
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
: encoding,
|
|
135
|
+
};
|
|
136
|
+
}
|
package/src/vis/theme.ts
CHANGED
|
@@ -56,6 +56,18 @@ export const AntVTheme = {
|
|
|
56
56
|
],
|
|
57
57
|
diverging: ["#7b3294", "#c2a5cf", "#f7f7f7", "#a6dba0", "#008837"],
|
|
58
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',
|
|
59
71
|
ramp: [
|
|
60
72
|
"#EBCCFF",
|
|
61
73
|
"#CCB0FF",
|
|
@@ -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';
|
|
@@ -66,7 +67,7 @@ interface IVisualSettings {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePreference }) => {
|
|
69
|
-
const { vizStore } = useGlobalStore();
|
|
70
|
+
const { vizStore, commonStore } = useGlobalStore();
|
|
70
71
|
const { visualConfig, canUndo, canRedo } = vizStore;
|
|
71
72
|
const { t: tGlobal } = useTranslation();
|
|
72
73
|
const { t } = useTranslation('translation', { keyPrefix: 'main.tabpanel.settings' });
|
|
@@ -335,6 +336,14 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
|
|
|
335
336
|
</FormContainer>
|
|
336
337
|
),
|
|
337
338
|
},
|
|
339
|
+
{
|
|
340
|
+
key: 'export_code',
|
|
341
|
+
label: t('button.export_code'),
|
|
342
|
+
icon: CodeBracketSquareIcon,
|
|
343
|
+
onClick: () => {
|
|
344
|
+
commonStore.setShowCodeExportPanel(true);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
338
347
|
] as ToolbarItemProps[];
|
|
339
348
|
}, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height, explorationMode, brushDirection, showActions, downloadPNG, downloadSVG, dark]);
|
|
340
349
|
|
|
@@ -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);
|