@kanaries/graphic-walker 0.3.1 → 0.3.2
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/graphic-walker.es.js +15354 -15542
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +120 -117
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/interfaces.d.ts +0 -9
- package/dist/store/visualSpecStore.d.ts +0 -1
- package/dist/vis/react-vega.d.ts +0 -3
- package/dist/vis/spec/view.d.ts +0 -53
- package/package.json +3 -2
- package/src/fields/encodeFields/singleEncodeEditor.tsx +8 -2
- package/src/interfaces.ts +0 -11
- package/src/renderer/specRenderer.tsx +7 -13
- package/src/store/visualSpecStore.ts +0 -14
- package/src/vis/react-vega.tsx +0 -21
- package/src/vis/spec/view.ts +1 -57
- package/src/visualSettings/index.tsx +3 -61
- package/dist/components/pivotTable/index.d.ts +0 -1
- package/dist/components/pivotTable/inteface.d.ts +0 -13
- package/dist/components/pivotTable/leftTree.d.ts +0 -7
- package/dist/components/pivotTable/store.d.ts +0 -24
- package/dist/components/pivotTable/topTree.d.ts +0 -7
- package/dist/components/pivotTable/utils.d.ts +0 -4
- package/src/components/pivotTable/index.tsx +0 -40
- package/src/components/pivotTable/inteface.ts +0 -12
- package/src/components/pivotTable/leftTree.tsx +0 -11
- package/src/components/pivotTable/store.tsx +0 -65
- package/src/components/pivotTable/topTree.tsx +0 -11
- package/src/components/pivotTable/utils.ts +0 -37
package/dist/interfaces.d.ts
CHANGED
|
@@ -155,11 +155,7 @@ export type IFilterRule = {
|
|
|
155
155
|
type: 'one of';
|
|
156
156
|
value: Set<string | number>;
|
|
157
157
|
};
|
|
158
|
-
export declare const EXPLORATION_TYPES: readonly ["none", "brush", "point"];
|
|
159
|
-
export declare const BRUSH_DIRECTIONS: readonly ["default", "x", "y"];
|
|
160
158
|
export type IStackMode = 'none' | 'stack' | 'normalize';
|
|
161
|
-
export type IExplorationType = typeof EXPLORATION_TYPES[number];
|
|
162
|
-
export type IBrushDirection = typeof BRUSH_DIRECTIONS[number];
|
|
163
159
|
export interface IVisualConfig {
|
|
164
160
|
defaultAggregated: boolean;
|
|
165
161
|
geoms: string[];
|
|
@@ -172,11 +168,6 @@ export interface IVisualConfig {
|
|
|
172
168
|
width: number;
|
|
173
169
|
height: number;
|
|
174
170
|
};
|
|
175
|
-
exploration: {
|
|
176
|
-
mode: IExplorationType;
|
|
177
|
-
/** works when mode is 'brush' */
|
|
178
|
-
brushDirection: IBrushDirection;
|
|
179
|
-
};
|
|
180
171
|
}
|
|
181
172
|
export interface IVisSpec {
|
|
182
173
|
readonly visId: string;
|
|
@@ -93,7 +93,6 @@ export declare class VizSpecStore {
|
|
|
93
93
|
width?: number;
|
|
94
94
|
height?: number;
|
|
95
95
|
}): void;
|
|
96
|
-
setExploration(value: Partial<IVisualConfig["exploration"]>): void;
|
|
97
96
|
reorderField(stateKey: keyof DraggableFieldState, sourceIndex: number, destinationIndex: number): void;
|
|
98
97
|
moveField(sourceKey: keyof DraggableFieldState, sourceIndex: number, destinationKey: keyof DraggableFieldState, destinationIndex: number): void;
|
|
99
98
|
removeField(sourceKey: keyof DraggableFieldState, sourceIndex: number): void;
|
package/dist/vis/react-vega.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IViewField, IRow, IStackMode, IDarkMode, IThemeKey } from '../interfaces';
|
|
3
|
-
import { SingleViewProps } from './spec/view';
|
|
4
3
|
export interface IReactVegaHandler {
|
|
5
4
|
getSVGData: () => Promise<string[]>;
|
|
6
5
|
getCanvasData: () => Promise<string[]>;
|
|
@@ -27,8 +26,6 @@ interface ReactVegaProps {
|
|
|
27
26
|
width: number;
|
|
28
27
|
height: number;
|
|
29
28
|
onGeomClick?: (values: any, e: any) => void;
|
|
30
|
-
selectEncoding: SingleViewProps['selectEncoding'];
|
|
31
|
-
brushEncoding: SingleViewProps['brushEncoding'];
|
|
32
29
|
/** @default "vega" */
|
|
33
30
|
themeKey?: IThemeKey;
|
|
34
31
|
dark?: IDarkMode;
|
package/dist/vis/spec/view.d.ts
CHANGED
|
@@ -3,10 +3,6 @@ import { IEncodeProps } from './encode';
|
|
|
3
3
|
export interface SingleViewProps extends IEncodeProps {
|
|
4
4
|
defaultAggregated: boolean;
|
|
5
5
|
stack: IStackMode;
|
|
6
|
-
enableCrossFilter: boolean;
|
|
7
|
-
asCrossFilterTrigger: boolean;
|
|
8
|
-
selectEncoding: 'default' | 'none';
|
|
9
|
-
brushEncoding: 'x' | 'y' | 'default' | 'none';
|
|
10
6
|
hideLegend?: boolean;
|
|
11
7
|
}
|
|
12
8
|
export declare function getSingleView(props: SingleViewProps): {
|
|
@@ -21,53 +17,4 @@ export declare function getSingleView(props: SingleViewProps): {
|
|
|
21
17
|
encoding: {
|
|
22
18
|
[key: string]: any;
|
|
23
19
|
};
|
|
24
|
-
transform?: undefined;
|
|
25
|
-
params?: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
config: any;
|
|
28
|
-
transform: {
|
|
29
|
-
filter: {
|
|
30
|
-
param: string;
|
|
31
|
-
};
|
|
32
|
-
}[];
|
|
33
|
-
params: {
|
|
34
|
-
name: string;
|
|
35
|
-
select: {
|
|
36
|
-
type: string;
|
|
37
|
-
encodings: ("x" | "y")[] | undefined;
|
|
38
|
-
};
|
|
39
|
-
}[];
|
|
40
|
-
mark: {
|
|
41
|
-
type: string;
|
|
42
|
-
opacity: number;
|
|
43
|
-
tooltip: {
|
|
44
|
-
content: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
encoding: {
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
};
|
|
50
|
-
} | {
|
|
51
|
-
config: any;
|
|
52
|
-
transform: {
|
|
53
|
-
filter: {
|
|
54
|
-
param: string;
|
|
55
|
-
};
|
|
56
|
-
}[];
|
|
57
|
-
params: {
|
|
58
|
-
name: string;
|
|
59
|
-
select: {
|
|
60
|
-
type: string;
|
|
61
|
-
};
|
|
62
|
-
}[];
|
|
63
|
-
mark: {
|
|
64
|
-
type: string;
|
|
65
|
-
opacity: number;
|
|
66
|
-
tooltip: {
|
|
67
|
-
content: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
encoding: {
|
|
71
|
-
[key: string]: any;
|
|
72
|
-
};
|
|
73
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanaries/graphic-walker",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev:front_end": "vite --host",
|
|
6
6
|
"dev": "npm run dev:front_end",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"import": "./dist/graphic-walker.es.js",
|
|
22
|
-
"require": "./dist/graphic-walker.umd.js"
|
|
22
|
+
"require": "./dist/graphic-walker.umd.js",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
23
24
|
},
|
|
24
25
|
"./dist/style.css": {
|
|
25
26
|
"import": "./dist/style.css",
|
|
@@ -9,6 +9,12 @@ import { COUNT_FIELD_ID } from '../../constants';
|
|
|
9
9
|
import DropdownContext from '../../components/dropdownContext';
|
|
10
10
|
import { AGGREGATOR_LIST } from '../fieldsContext';
|
|
11
11
|
import { Draggable, DroppableStateSnapshot } from '@kanaries/react-beautiful-dnd';
|
|
12
|
+
import styled from 'styled-components';
|
|
13
|
+
|
|
14
|
+
const PillActions = styled.div`
|
|
15
|
+
overflow: visible !important;
|
|
16
|
+
width: calc(100% - 1.875rem);
|
|
17
|
+
`;
|
|
12
18
|
|
|
13
19
|
interface SingleEncodeEditorProps {
|
|
14
20
|
dkey: IDraggableStateKey;
|
|
@@ -47,7 +53,7 @@ const SingleEncodeEditor: React.FC<SingleEncodeEditorProps> = (props) => {
|
|
|
47
53
|
>
|
|
48
54
|
<TrashIcon className="w-4" />
|
|
49
55
|
</div>
|
|
50
|
-
<
|
|
56
|
+
<PillActions className="flex-1 flex items-center border border-gray-200 dark:border-gray-700 border-l-0 px-2 space-x-2 truncate">
|
|
51
57
|
<span className="flex-1 truncate">
|
|
52
58
|
{channelItem.name}
|
|
53
59
|
</span>
|
|
@@ -64,7 +70,7 @@ const SingleEncodeEditor: React.FC<SingleEncodeEditorProps> = (props) => {
|
|
|
64
70
|
</span>
|
|
65
71
|
</DropdownContext>
|
|
66
72
|
)}
|
|
67
|
-
</
|
|
73
|
+
</PillActions>
|
|
68
74
|
</div>
|
|
69
75
|
);
|
|
70
76
|
}}
|
package/src/interfaces.ts
CHANGED
|
@@ -182,13 +182,7 @@ export type IFilterRule =
|
|
|
182
182
|
value: Set<string | number>;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
export const EXPLORATION_TYPES = ['none', 'brush', 'point'] as const;
|
|
186
|
-
|
|
187
|
-
export const BRUSH_DIRECTIONS = ['default', 'x', 'y'] as const;
|
|
188
|
-
|
|
189
185
|
export type IStackMode = 'none' | 'stack' | 'normalize';
|
|
190
|
-
export type IExplorationType = typeof EXPLORATION_TYPES[number];
|
|
191
|
-
export type IBrushDirection = typeof BRUSH_DIRECTIONS[number];
|
|
192
186
|
|
|
193
187
|
export interface IVisualConfig {
|
|
194
188
|
defaultAggregated: boolean;
|
|
@@ -202,11 +196,6 @@ export interface IVisualConfig {
|
|
|
202
196
|
width: number;
|
|
203
197
|
height: number;
|
|
204
198
|
};
|
|
205
|
-
exploration: {
|
|
206
|
-
mode: IExplorationType;
|
|
207
|
-
/** works when mode is 'brush' */
|
|
208
|
-
brushDirection: IBrushDirection;
|
|
209
|
-
};
|
|
210
199
|
}
|
|
211
200
|
|
|
212
201
|
export interface IVisSpec {
|
|
@@ -21,7 +21,7 @@ const SpecRenderer = forwardRef<IReactVegaHandler, SpecRendererProps>(function (
|
|
|
21
21
|
) {
|
|
22
22
|
const { vizStore, commonStore } = useGlobalStore();
|
|
23
23
|
// const { draggableFieldState, visualConfig } = vizStore;
|
|
24
|
-
const { geoms, interactiveScale, defaultAggregated, stack, showActions, size
|
|
24
|
+
const { geoms, interactiveScale, defaultAggregated, stack, showActions, size } = visualConfig;
|
|
25
25
|
|
|
26
26
|
const rows = draggableFieldState.rows;
|
|
27
27
|
const columns = draggableFieldState.columns;
|
|
@@ -41,19 +41,15 @@ const SpecRenderer = forwardRef<IReactVegaHandler, SpecRendererProps>(function (
|
|
|
41
41
|
|
|
42
42
|
const hasFacet = rowLeftFacetFields.length > 0 || colLeftFacetFields.length > 0;
|
|
43
43
|
|
|
44
|
-
const shouldTriggerMenu = exploration.mode === 'none';
|
|
45
|
-
|
|
46
44
|
const handleGeomClick = useCallback(
|
|
47
45
|
(values: any, e: any) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
}
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
runInAction(() => {
|
|
48
|
+
commonStore.showEmbededMenu([e.pageX, e.pageY]);
|
|
49
|
+
commonStore.setFilters(values);
|
|
50
|
+
});
|
|
55
51
|
},
|
|
56
|
-
[
|
|
52
|
+
[]
|
|
57
53
|
);
|
|
58
54
|
const enableResize = size.mode === 'fixed' && !hasFacet;
|
|
59
55
|
|
|
@@ -108,8 +104,6 @@ const SpecRenderer = forwardRef<IReactVegaHandler, SpecRendererProps>(function (
|
|
|
108
104
|
width={size.width - 12 * 4}
|
|
109
105
|
height={size.height - 12 * 4}
|
|
110
106
|
ref={ref}
|
|
111
|
-
brushEncoding={exploration.mode === 'brush' ? exploration.brushDirection : 'none'}
|
|
112
|
-
selectEncoding={exploration.mode === 'point' ? 'default' : 'none'}
|
|
113
107
|
onGeomClick={handleGeomClick}
|
|
114
108
|
themeKey={themeKey}
|
|
115
109
|
dark={dark}
|
|
@@ -74,10 +74,6 @@ export function initVisualConfig(): IVisualConfig {
|
|
|
74
74
|
width: 320,
|
|
75
75
|
height: 200,
|
|
76
76
|
},
|
|
77
|
-
exploration: {
|
|
78
|
-
mode: "none",
|
|
79
|
-
brushDirection: "default",
|
|
80
|
-
},
|
|
81
77
|
};
|
|
82
78
|
}
|
|
83
79
|
|
|
@@ -391,16 +387,6 @@ export class VizSpecStore {
|
|
|
391
387
|
config.size.height = height;
|
|
392
388
|
});
|
|
393
389
|
}
|
|
394
|
-
public setExploration(value: Partial<IVisualConfig["exploration"]>) {
|
|
395
|
-
this.useMutable(({ config }) => {
|
|
396
|
-
if (value.mode) {
|
|
397
|
-
config.exploration.mode = value.mode;
|
|
398
|
-
}
|
|
399
|
-
if (value.brushDirection) {
|
|
400
|
-
config.exploration.brushDirection = value.brushDirection;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
390
|
public reorderField(stateKey: keyof DraggableFieldState, sourceIndex: number, destinationIndex: number) {
|
|
405
391
|
if (MetaFieldKeys.includes(stateKey)) return;
|
|
406
392
|
if (sourceIndex === destinationIndex) return;
|
package/src/vis/react-vega.tsx
CHANGED
|
@@ -46,8 +46,6 @@ interface ReactVegaProps {
|
|
|
46
46
|
width: number;
|
|
47
47
|
height: number;
|
|
48
48
|
onGeomClick?: (values: any, e: any) => void
|
|
49
|
-
selectEncoding: SingleViewProps['selectEncoding'];
|
|
50
|
-
brushEncoding: SingleViewProps['brushEncoding'];
|
|
51
49
|
/** @default "vega" */
|
|
52
50
|
themeKey?: IThemeKey;
|
|
53
51
|
dark?: IDarkMode;
|
|
@@ -96,8 +94,6 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
96
94
|
layoutMode,
|
|
97
95
|
width,
|
|
98
96
|
height,
|
|
99
|
-
selectEncoding,
|
|
100
|
-
brushEncoding,
|
|
101
97
|
details = [],
|
|
102
98
|
themeKey = 'vega',
|
|
103
99
|
dark = 'media'
|
|
@@ -195,10 +191,6 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
195
191
|
defaultAggregated: defaultAggregate,
|
|
196
192
|
stack,
|
|
197
193
|
geomType,
|
|
198
|
-
selectEncoding,
|
|
199
|
-
brushEncoding,
|
|
200
|
-
enableCrossFilter: false,
|
|
201
|
-
asCrossFilterTrigger: false,
|
|
202
194
|
});
|
|
203
195
|
|
|
204
196
|
spec.mark = singleView.mark;
|
|
@@ -206,9 +198,6 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
206
198
|
spec.encoding = singleView.encoding;
|
|
207
199
|
}
|
|
208
200
|
|
|
209
|
-
if ('params' in singleView) {
|
|
210
|
-
spec.params.push(...singleView.params!);
|
|
211
|
-
}
|
|
212
201
|
if (viewPlaceholders.length > 0 && viewPlaceholders[0].current) {
|
|
213
202
|
embed(viewPlaceholders[0].current, spec, { mode: 'vega-lite', actions: showActions, timeFormatLocale: getVegaTimeFormatRules(i18n.language), config: themeConfig }).then(res => {
|
|
214
203
|
vegaRefs.current = [res.view];
|
|
@@ -264,18 +253,11 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
264
253
|
defaultAggregated: defaultAggregate,
|
|
265
254
|
stack,
|
|
266
255
|
geomType,
|
|
267
|
-
selectEncoding,
|
|
268
|
-
brushEncoding,
|
|
269
|
-
enableCrossFilter: crossFilterTriggerIdx !== -1,
|
|
270
|
-
asCrossFilterTrigger: crossFilterTriggerIdx === sourceId,
|
|
271
256
|
hideLegend: !hasLegend,
|
|
272
257
|
});
|
|
273
258
|
const node = i * colRepeatFields.length + j < viewPlaceholders.length ? viewPlaceholders[i * colRepeatFields.length + j].current : null
|
|
274
259
|
let commonSpec = { ...spec };
|
|
275
260
|
|
|
276
|
-
if ('params' in singleView) {
|
|
277
|
-
commonSpec.params = [...commonSpec.params, ...singleView.params!];
|
|
278
|
-
}
|
|
279
261
|
const ans = { ...commonSpec, ...singleView }
|
|
280
262
|
if ('params' in commonSpec) {
|
|
281
263
|
ans.params = commonSpec.params;
|
|
@@ -368,9 +350,6 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
368
350
|
layoutMode,
|
|
369
351
|
width,
|
|
370
352
|
height,
|
|
371
|
-
selectEncoding,
|
|
372
|
-
brushEncoding,
|
|
373
|
-
crossFilterTriggerIdx,
|
|
374
353
|
themeConfig,
|
|
375
354
|
details
|
|
376
355
|
]);
|
package/src/vis/spec/view.ts
CHANGED
|
@@ -6,15 +6,9 @@ import { IEncodeProps, channelEncode } from './encode';
|
|
|
6
6
|
import { channelStack } from './stack';
|
|
7
7
|
import { addTooltipEncode } from './tooltip';
|
|
8
8
|
|
|
9
|
-
const BRUSH_SIGNAL_NAME = '__gw_brush__';
|
|
10
|
-
const POINT_SIGNAL_NAME = '__gw_point__';
|
|
11
9
|
export interface SingleViewProps extends IEncodeProps {
|
|
12
10
|
defaultAggregated: boolean;
|
|
13
11
|
stack: IStackMode;
|
|
14
|
-
enableCrossFilter: boolean;
|
|
15
|
-
asCrossFilterTrigger: boolean;
|
|
16
|
-
selectEncoding: 'default' | 'none';
|
|
17
|
-
brushEncoding: 'x' | 'y' | 'default' | 'none';
|
|
18
12
|
hideLegend?: boolean;
|
|
19
13
|
}
|
|
20
14
|
export function getSingleView(props: SingleViewProps) {
|
|
@@ -35,10 +29,6 @@ export function getSingleView(props: SingleViewProps) {
|
|
|
35
29
|
defaultAggregated,
|
|
36
30
|
stack,
|
|
37
31
|
geomType,
|
|
38
|
-
selectEncoding,
|
|
39
|
-
brushEncoding,
|
|
40
|
-
enableCrossFilter,
|
|
41
|
-
asCrossFilterTrigger,
|
|
42
32
|
hideLegend = false,
|
|
43
33
|
} = props;
|
|
44
34
|
const fields: IViewField[] = [x, y, color, opacity, size, shape, row, column, xOffset, yOffset, theta, radius];
|
|
@@ -82,55 +72,9 @@ export function getSingleView(props: SingleViewProps) {
|
|
|
82
72
|
opacity: 0.96,
|
|
83
73
|
tooltip: { content: 'data' }
|
|
84
74
|
};
|
|
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
75
|
return {
|
|
114
76
|
config,
|
|
115
|
-
transform: asCrossFilterTrigger ? [] : [{ filter: { param: POINT_SIGNAL_NAME } }],
|
|
116
|
-
params: [
|
|
117
|
-
{
|
|
118
|
-
name: POINT_SIGNAL_NAME,
|
|
119
|
-
select: { type: 'point' },
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
77
|
mark,
|
|
123
|
-
encoding
|
|
124
|
-
? {
|
|
125
|
-
...encoding,
|
|
126
|
-
color: {
|
|
127
|
-
condition: {
|
|
128
|
-
...encoding.color,
|
|
129
|
-
param: POINT_SIGNAL_NAME,
|
|
130
|
-
},
|
|
131
|
-
value: '#888',
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
: encoding,
|
|
78
|
+
encoding,
|
|
135
79
|
};
|
|
136
80
|
}
|
|
@@ -11,10 +11,6 @@ import {
|
|
|
11
11
|
ArrowUturnRightIcon,
|
|
12
12
|
LockClosedIcon,
|
|
13
13
|
LockOpenIcon,
|
|
14
|
-
ViewfinderCircleIcon,
|
|
15
|
-
ChatBubbleBottomCenterTextIcon,
|
|
16
|
-
PaintBrushIcon,
|
|
17
|
-
CursorArrowRaysIcon,
|
|
18
14
|
WrenchIcon,
|
|
19
15
|
ChevronUpDownIcon,
|
|
20
16
|
XMarkIcon,
|
|
@@ -30,7 +26,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
30
26
|
import { ResizeDialog } from '../components/sizeSetting';
|
|
31
27
|
import { GEMO_TYPES, STACK_MODE, CHART_LAYOUT_TYPE } from '../config';
|
|
32
28
|
import { useGlobalStore } from '../store';
|
|
33
|
-
import { IStackMode,
|
|
29
|
+
import { IStackMode, IDarkMode } from '../interfaces';
|
|
34
30
|
import { IReactVegaHandler } from '../vis/react-vega';
|
|
35
31
|
import Toolbar, { ToolbarItemProps } from '../components/toolbar';
|
|
36
32
|
import { ButtonWithShortcut } from './menubar';
|
|
@@ -74,7 +70,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
|
|
|
74
70
|
|
|
75
71
|
const {
|
|
76
72
|
defaultAggregated, geoms: [markType], stack, interactiveScale, size: { mode: sizeMode, width, height },
|
|
77
|
-
|
|
73
|
+
showActions,
|
|
78
74
|
} = visualConfig;
|
|
79
75
|
|
|
80
76
|
const downloadPNG = useCallback(throttle(() => {
|
|
@@ -250,60 +246,6 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
|
|
|
250
246
|
),
|
|
251
247
|
},
|
|
252
248
|
'-',
|
|
253
|
-
{
|
|
254
|
-
key: 'exploration_mode',
|
|
255
|
-
icon: ViewfinderCircleIcon,
|
|
256
|
-
label: tGlobal(`constant.exploration_mode.__enum__`),
|
|
257
|
-
options: EXPLORATION_TYPES.map(g => ({
|
|
258
|
-
key: g,
|
|
259
|
-
label: tGlobal(`constant.exploration_mode.${g}`),
|
|
260
|
-
icon: {
|
|
261
|
-
none: ChatBubbleBottomCenterTextIcon,
|
|
262
|
-
brush: PaintBrushIcon,
|
|
263
|
-
point: CursorArrowRaysIcon,
|
|
264
|
-
}[g],
|
|
265
|
-
})),
|
|
266
|
-
value: explorationMode,
|
|
267
|
-
onSelect: key => {
|
|
268
|
-
vizStore.setExploration({
|
|
269
|
-
mode: key as (typeof EXPLORATION_TYPES)[number]
|
|
270
|
-
});
|
|
271
|
-
},
|
|
272
|
-
form: explorationMode === 'brush' ? (
|
|
273
|
-
<FormContainer>
|
|
274
|
-
<label
|
|
275
|
-
id="dropdown:brush_mode:label"
|
|
276
|
-
htmlFor="dropdown:brush_mode"
|
|
277
|
-
>
|
|
278
|
-
{tGlobal(`constant.brush_mode.__enum__`)}
|
|
279
|
-
</label>
|
|
280
|
-
<select
|
|
281
|
-
className="border border-gray-500 rounded-sm text-xs pt-0.5 pb-0.5 pl-2 pr-2 cursor-pointer"
|
|
282
|
-
id="dropdown:brush_mode"
|
|
283
|
-
aria-describedby="dropdown:brush_mode:label"
|
|
284
|
-
disabled={explorationMode !== 'brush'}
|
|
285
|
-
aria-disabled={explorationMode !== 'brush'}
|
|
286
|
-
value={brushDirection}
|
|
287
|
-
onChange={e => {
|
|
288
|
-
vizStore.setExploration({
|
|
289
|
-
brushDirection: e.target.value as IBrushDirection
|
|
290
|
-
});
|
|
291
|
-
}}
|
|
292
|
-
>
|
|
293
|
-
{BRUSH_DIRECTIONS.map(g => (
|
|
294
|
-
<option
|
|
295
|
-
key={g}
|
|
296
|
-
value={g}
|
|
297
|
-
className="cursor-pointer"
|
|
298
|
-
aria-selected={brushDirection === g}
|
|
299
|
-
>
|
|
300
|
-
{tGlobal(`constant.brush_mode.${g}`)}
|
|
301
|
-
</option>
|
|
302
|
-
))}
|
|
303
|
-
</select>
|
|
304
|
-
</FormContainer>
|
|
305
|
-
) : undefined,
|
|
306
|
-
},
|
|
307
249
|
{
|
|
308
250
|
key: 'debug',
|
|
309
251
|
label: t('toggle.debug'),
|
|
@@ -345,7 +287,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
|
|
|
345
287
|
}
|
|
346
288
|
}
|
|
347
289
|
] as ToolbarItemProps[];
|
|
348
|
-
}, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height,
|
|
290
|
+
}, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height, showActions, downloadPNG, downloadSVG, dark]);
|
|
349
291
|
|
|
350
292
|
return <div style={{ margin: '0.38em 0.28em 0.2em 0.18em' }}>
|
|
351
293
|
<Toolbar
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IAggregator } from "../../interfaces";
|
|
2
|
-
export interface INestNode {
|
|
3
|
-
key: string;
|
|
4
|
-
value: string;
|
|
5
|
-
children: INestNode[];
|
|
6
|
-
}
|
|
7
|
-
export interface IGroupByQuery {
|
|
8
|
-
groupBy: string[];
|
|
9
|
-
measures: {
|
|
10
|
-
field: string;
|
|
11
|
-
agg: IAggregator;
|
|
12
|
-
}[];
|
|
13
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { IGroupByQuery, INestNode } from './inteface';
|
|
2
|
-
import { IField, IRow } from '../../interfaces';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
declare class PivotTableStore {
|
|
5
|
-
leftTree: INestNode | null;
|
|
6
|
-
topTree: INestNode | null;
|
|
7
|
-
metricTable: any[][];
|
|
8
|
-
dataSource: IRow[];
|
|
9
|
-
metas: IField[];
|
|
10
|
-
viewData: IRow[];
|
|
11
|
-
constructor();
|
|
12
|
-
init(dataSource: IRow[], metas: IField[]): void;
|
|
13
|
-
createTree(query: IGroupByQuery, viewData: IRow[]): void;
|
|
14
|
-
createTopTree(query: IGroupByQuery, viewData: any): void;
|
|
15
|
-
createLeftTree(query: IGroupByQuery, viewData: any): void;
|
|
16
|
-
queryData(leftQuery: IGroupByQuery, topQuery: IGroupByQuery): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export interface PivotTableDataProps {
|
|
19
|
-
data: IRow[];
|
|
20
|
-
metas: IField[];
|
|
21
|
-
}
|
|
22
|
-
export declare const PivotTableStoreWrapper: React.FC<PivotTableDataProps>;
|
|
23
|
-
export declare function usePivotTableStore(): PivotTableStore;
|
|
24
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { IRow } from "../../interfaces";
|
|
2
|
-
import { INestNode } from "./inteface";
|
|
3
|
-
export declare function insertNode(tree: INestNode, layerKeys: string[], nodeData: IRow, depth: number): void;
|
|
4
|
-
export declare function buildNestTree(layerKeys: string[], data: IRow[]): INestNode;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StoreWrapper, useGlobalStore } from '../../store';
|
|
3
|
-
import { PivotTableDataProps, PivotTableStoreWrapper, usePivotTableStore } from './store';
|
|
4
|
-
import { observer } from 'mobx-react-lite';
|
|
5
|
-
import LeftTree from './leftTree';
|
|
6
|
-
import TopTree from './topTree';
|
|
7
|
-
|
|
8
|
-
interface PivotTableProps extends PivotTableDataProps {}
|
|
9
|
-
const PivotTable: React.FC = observer((props) => {
|
|
10
|
-
const store = usePivotTableStore();
|
|
11
|
-
const { vizStore } = useGlobalStore();
|
|
12
|
-
const { draggableFieldState } = vizStore;
|
|
13
|
-
const { rows, columns } = draggableFieldState;
|
|
14
|
-
|
|
15
|
-
const { leftTree, topTree, metricTable } = store;
|
|
16
|
-
return (
|
|
17
|
-
<div>
|
|
18
|
-
<div>
|
|
19
|
-
<h1>left</h1>
|
|
20
|
-
{leftTree && <LeftTree data={leftTree} />}
|
|
21
|
-
</div>
|
|
22
|
-
<div>
|
|
23
|
-
<h1>top</h1>
|
|
24
|
-
{topTree && <TopTree data={topTree} />}
|
|
25
|
-
</div>
|
|
26
|
-
<div>
|
|
27
|
-
<h1>metric</h1>
|
|
28
|
-
<code>{JSON.stringify(metricTable, null, 2)}</code>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const PivotTableApp: React.FC<PivotTableProps> = (props) => {
|
|
35
|
-
return (
|
|
36
|
-
<PivotTableStoreWrapper {...props}>
|
|
37
|
-
<PivotTable />
|
|
38
|
-
</PivotTableStoreWrapper>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IAggregator } from "../../interfaces";
|
|
2
|
-
|
|
3
|
-
export interface INestNode {
|
|
4
|
-
key: string;
|
|
5
|
-
value: string;
|
|
6
|
-
children: INestNode[];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface IGroupByQuery {
|
|
10
|
-
groupBy: string[];
|
|
11
|
-
measures: { field: string; agg: IAggregator }[];
|
|
12
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { INestNode } from './inteface';
|
|
3
|
-
|
|
4
|
-
export interface TreeProps {
|
|
5
|
-
data: INestNode;
|
|
6
|
-
}
|
|
7
|
-
const LeftTree: React.FC<TreeProps> = (props) => {
|
|
8
|
-
return <div>{JSON.stringify(props.data)}</div>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default LeftTree;
|