@kanaries/graphic-walker 0.2.16 → 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 +3 -4
- package/dist/assets/viewQuery.worker-ffefc111.js.map +1 -1
- package/dist/dataSource/index.d.ts +0 -1
- package/dist/fields/encodeFields/singleEncodeEditor.d.ts +4 -4
- package/dist/graphic-walker.es.js +29716 -34642
- 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/interfaces.d.ts +31 -16
- 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 +2 -1
- package/dist/lib/op/aggregate.d.ts +1 -1
- package/dist/lib/op/bin.d.ts +1 -1
- package/dist/lib/op/fold.d.ts +1 -1
- package/dist/lib/viewQuery.d.ts +1 -2
- package/dist/services.d.ts +1 -30
- package/dist/store/visualSpecStore.d.ts +1 -2
- package/dist/utils/autoMark.d.ts +1 -1
- package/dist/utils/dataPrep.d.ts +1 -2
- package/dist/vis/react-vega.d.ts +1 -0
- package/dist/vis/spec/encode.d.ts +1 -0
- package/dist/vis/spec/mark.d.ts +1 -1
- package/dist/vis/spec/tooltip.d.ts +4 -0
- package/dist/vis/spec/view.d.ts +9 -3
- package/package.json +2 -4
- package/src/App.tsx +55 -68
- package/src/dataSource/index.tsx +0 -17
- package/src/fields/aestheticFields.tsx +1 -2
- package/src/fields/encodeFields/singleEncodeEditor.tsx +11 -12
- package/src/fields/fieldsContext.tsx +1 -0
- package/src/interfaces.ts +75 -63
- 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 +3 -9
- package/src/lib/op/aggregate.ts +1 -1
- package/src/lib/op/bin.ts +1 -1
- package/src/lib/op/fold.ts +1 -1
- package/src/lib/viewQuery.ts +1 -2
- package/src/locales/en-US.json +2 -1
- package/src/locales/zh-CN.json +2 -1
- package/src/renderer/specRenderer.tsx +2 -0
- package/src/services.ts +65 -67
- package/src/store/visualSpecStore.ts +2 -4
- package/src/utils/autoMark.ts +1 -1
- package/src/utils/dataPrep.ts +1 -2
- package/src/vis/react-vega.tsx +5 -0
- package/src/vis/spec/encode.ts +1 -0
- package/src/vis/spec/mark.ts +1 -1
- package/src/vis/spec/tooltip.ts +16 -0
- package/src/vis/spec/view.ts +12 -14
- package/dist/assets/explainer.worker-8428eb12.js.map +0 -1
- 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/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
package/src/services.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { toJS } from 'mobx';
|
|
2
|
-
import {
|
|
3
|
-
import { IRow, Filters, SemanticType, IMeasure, IMutField, IFilterField } from './interfaces';
|
|
2
|
+
import { IRow, IMutField, IFilterField, Specification } from './interfaces';
|
|
4
3
|
/* eslint import/no-webpack-loader-syntax:0 */
|
|
5
4
|
// @ts-ignore
|
|
6
5
|
// eslint-disable-next-line
|
|
@@ -8,20 +7,19 @@ import { IRow, Filters, SemanticType, IMeasure, IMutField, IFilterField } from '
|
|
|
8
7
|
/* eslint import/no-webpack-loader-syntax:0 */
|
|
9
8
|
// @ts-ignore
|
|
10
9
|
// eslint-disable-next-line
|
|
11
|
-
import ExplainerWorker from './workers/explainer.worker?worker&inline';
|
|
10
|
+
// import ExplainerWorker from './workers/explainer.worker?worker&inline';
|
|
12
11
|
import FilterWorker from './workers/filter.worker?worker&inline';
|
|
13
12
|
import TransformDataWorker from './workers/transform.worker?worker&inline';
|
|
14
13
|
import ViewQueryWorker from './workers/viewQuery.worker?worker&inline';
|
|
15
|
-
import {
|
|
16
|
-
import { IViewQuery, queryView } from './lib/viewQuery';
|
|
14
|
+
import { IViewQuery } from './lib/viewQuery';
|
|
17
15
|
|
|
18
|
-
interface WorkerState {
|
|
19
|
-
|
|
20
|
-
}
|
|
16
|
+
// interface WorkerState {
|
|
17
|
+
// eWorker: Worker | null;
|
|
18
|
+
// }
|
|
21
19
|
|
|
22
|
-
const workerState: WorkerState = {
|
|
23
|
-
|
|
24
|
-
}
|
|
20
|
+
// const workerState: WorkerState = {
|
|
21
|
+
// eWorker: null,
|
|
22
|
+
// }
|
|
25
23
|
|
|
26
24
|
function workerService<T, R>(worker: Worker, data: R): Promise<T> {
|
|
27
25
|
return new Promise<T>((resolve, reject) => {
|
|
@@ -38,72 +36,72 @@ function workerService<T, R>(worker: Worker, data: R): Promise<T> {
|
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
interface ExplainParams {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
39
|
+
// interface ExplainParams {
|
|
40
|
+
// dimensions: string[];
|
|
41
|
+
// measures: string[];
|
|
42
|
+
// dataSource: IRow[];
|
|
43
|
+
// filters?: Filters;
|
|
44
|
+
// currentSpace: {
|
|
45
|
+
// dimensions: string[];
|
|
46
|
+
// measures: IMeasure[];
|
|
47
|
+
// };
|
|
48
|
+
// }
|
|
51
49
|
export interface IVisSpace {
|
|
52
50
|
dataView: IRow[];
|
|
53
51
|
schema: Specification;
|
|
54
52
|
}
|
|
55
|
-
interface ExplainReturns {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
export async function getExplaination(props: ExplainParams) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
53
|
+
// interface ExplainReturns {
|
|
54
|
+
// explainations: IExplaination[];
|
|
55
|
+
// valueExp: IMeasureWithStat[];
|
|
56
|
+
// visSpaces: IVisSpace[];
|
|
57
|
+
// fieldsWithSemanticType: Array<{ key: string; type: SemanticType }>;
|
|
58
|
+
// }
|
|
59
|
+
// export async function getExplaination(props: ExplainParams) {
|
|
60
|
+
// const worker = workerState.eWorker;
|
|
61
|
+
// if (worker === null) throw new Error('init worker first.')
|
|
62
|
+
// let result: ExplainReturns = {
|
|
63
|
+
// explainations: [],
|
|
64
|
+
// valueExp: [],
|
|
65
|
+
// visSpaces: [],
|
|
66
|
+
// fieldsWithSemanticType: [],
|
|
67
|
+
// };
|
|
68
|
+
// try {
|
|
69
|
+
// result = await workerService<ExplainReturns, { type: string; data: ExplainParams }>(
|
|
70
|
+
// worker,
|
|
71
|
+
// {
|
|
72
|
+
// type: 'getExplaination',
|
|
73
|
+
// data: props
|
|
74
|
+
// }
|
|
75
|
+
// );
|
|
76
|
+
// return result;
|
|
77
|
+
// } catch (error) {
|
|
78
|
+
// console.error(error);
|
|
79
|
+
// }
|
|
80
|
+
// return result;
|
|
81
|
+
// }
|
|
84
82
|
|
|
85
83
|
interface PreAnalysisParams {
|
|
86
84
|
fields: IMutField[];
|
|
87
85
|
dataSource: IRow[];
|
|
88
86
|
}
|
|
89
|
-
export async function preAnalysis(props: PreAnalysisParams) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
87
|
+
// export async function preAnalysis(props: PreAnalysisParams) {
|
|
88
|
+
// if (workerState.eWorker !== null) {
|
|
89
|
+
// workerState.eWorker.terminate();
|
|
90
|
+
// }
|
|
91
|
+
// try {
|
|
92
|
+
// workerState.eWorker = new ExplainerWorker() as Worker;
|
|
93
|
+
// const tmp = await workerService<boolean, { type: string; data: PreAnalysisParams}>(workerState.eWorker, { type: 'preAnalysis', data: props });
|
|
94
|
+
// } catch (error) {
|
|
95
|
+
// console.error(error)
|
|
96
|
+
// }
|
|
97
|
+
// }
|
|
100
98
|
|
|
101
|
-
export function destroyWorker() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
99
|
+
// export function destroyWorker() {
|
|
100
|
+
// if (workerState.eWorker) {
|
|
101
|
+
// workerState.eWorker.terminate();
|
|
102
|
+
// workerState.eWorker = null;
|
|
103
|
+
// }
|
|
104
|
+
// }
|
|
107
105
|
|
|
108
106
|
let filterWorker: Worker | null = null;
|
|
109
107
|
let filterWorkerAutoTerminator: NodeJS.Timeout | null = null;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { IReactionDisposer, makeAutoObservable, observable, reaction, toJS } from "mobx";
|
|
2
2
|
import produce from "immer";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
|
-
import { Specification } from "
|
|
5
|
-
import { DataSet, DraggableFieldState, IExpression, IFilterRule, IViewField, IVisSpec, IVisualConfig } from "../interfaces";
|
|
4
|
+
import { DataSet, DraggableFieldState, IFilterRule, IViewField, IVisSpec, IVisualConfig, Specification } from "../interfaces";
|
|
6
5
|
import { CHANNEL_LIMIT, GEMO_TYPES, MetaFieldKeys } from "../config";
|
|
7
|
-
import { makeBinField, makeLogField } from "../utils/normalization";
|
|
8
6
|
import { VisSpecWithHistory } from "../models/visSpecHistory";
|
|
9
7
|
import { IStoInfo, dumpsGWPureSpec, parseGWContent, parseGWPureSpec, stringifyGWContent } from "../utils/save";
|
|
10
8
|
import { CommonStore } from "./commonStore";
|
|
11
9
|
import { createCountField } from "../utils";
|
|
12
|
-
import { IViewQuery } from "../lib/viewQuery";
|
|
13
10
|
|
|
14
11
|
function getChannelSizeLimit(channel: string): number {
|
|
15
12
|
if (typeof CHANNEL_LIMIT[channel] === "undefined") return Infinity;
|
|
@@ -649,6 +646,7 @@ export class VizSpecStore {
|
|
|
649
646
|
// thi
|
|
650
647
|
// const [xField, yField, ] = spec.position;
|
|
651
648
|
this.clearState();
|
|
649
|
+
this.setVisualConfig('defaultAggregated', Boolean(spec.aggregate));
|
|
652
650
|
if ((spec.geomType?.length ?? 0) > 0) {
|
|
653
651
|
this.setVisualConfig(
|
|
654
652
|
"geoms",
|
package/src/utils/autoMark.ts
CHANGED
package/src/utils/dataPrep.ts
CHANGED
package/src/vis/react-vega.tsx
CHANGED
|
@@ -40,6 +40,7 @@ interface ReactVegaProps {
|
|
|
40
40
|
shape?: IViewField;
|
|
41
41
|
theta?: IViewField;
|
|
42
42
|
radius?: IViewField;
|
|
43
|
+
details?: Readonly<IViewField[]>;
|
|
43
44
|
showActions: boolean;
|
|
44
45
|
layoutMode: string;
|
|
45
46
|
width: number;
|
|
@@ -97,6 +98,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
97
98
|
height,
|
|
98
99
|
selectEncoding,
|
|
99
100
|
brushEncoding,
|
|
101
|
+
details = [],
|
|
100
102
|
themeKey = 'vega',
|
|
101
103
|
dark = 'media'
|
|
102
104
|
} = props;
|
|
@@ -189,6 +191,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
189
191
|
column: colFacetField,
|
|
190
192
|
xOffset: NULL_FIELD,
|
|
191
193
|
yOffset: NULL_FIELD,
|
|
194
|
+
details,
|
|
192
195
|
defaultAggregated: defaultAggregate,
|
|
193
196
|
stack,
|
|
194
197
|
geomType,
|
|
@@ -257,6 +260,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
257
260
|
column: colFacetField,
|
|
258
261
|
xOffset: NULL_FIELD,
|
|
259
262
|
yOffset: NULL_FIELD,
|
|
263
|
+
details,
|
|
260
264
|
defaultAggregated: defaultAggregate,
|
|
261
265
|
stack,
|
|
262
266
|
geomType,
|
|
@@ -368,6 +372,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVe
|
|
|
368
372
|
brushEncoding,
|
|
369
373
|
crossFilterTriggerIdx,
|
|
370
374
|
themeConfig,
|
|
375
|
+
details
|
|
371
376
|
]);
|
|
372
377
|
|
|
373
378
|
useImperativeHandle(ref, () => ({
|
package/src/vis/spec/encode.ts
CHANGED
package/src/vis/spec/mark.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IViewField } from "../../interfaces";
|
|
2
|
+
|
|
3
|
+
export function addTooltipEncode (encoding: {[key: string]: any}, details: Readonly<IViewField[]> = []) {
|
|
4
|
+
const encs = Object.keys(encoding).filter(ck => ck !== 'tooltip').map(ck => {
|
|
5
|
+
return {
|
|
6
|
+
field: encoding[ck].field,
|
|
7
|
+
type: encoding[ck].type,
|
|
8
|
+
title: encoding[ck].title
|
|
9
|
+
}
|
|
10
|
+
}).concat(details.map(f => ({
|
|
11
|
+
field: f.fid,
|
|
12
|
+
title: f.name,
|
|
13
|
+
type: f.semanticType
|
|
14
|
+
})))
|
|
15
|
+
encoding.tooltip = encs
|
|
16
|
+
}
|
package/src/vis/spec/view.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { ISemanticType } from '
|
|
2
|
-
import { IStackMode, IViewField } from '../../interfaces';
|
|
1
|
+
import { ISemanticType, IStackMode, IViewField } from '../../interfaces';
|
|
3
2
|
import { autoMark } from './mark';
|
|
4
3
|
import { NULL_FIELD } from './field';
|
|
5
4
|
import { channelAggregate } from './aggregate';
|
|
6
5
|
import { IEncodeProps, channelEncode } from './encode';
|
|
7
|
-
import { channelStack } from './stack'
|
|
6
|
+
import { channelStack } from './stack';
|
|
7
|
+
import { addTooltipEncode } from './tooltip';
|
|
8
8
|
|
|
9
9
|
const BRUSH_SIGNAL_NAME = '__gw_brush__';
|
|
10
10
|
const POINT_SIGNAL_NAME = '__gw_point__';
|
|
11
11
|
export interface SingleViewProps extends IEncodeProps {
|
|
12
|
-
|
|
13
12
|
defaultAggregated: boolean;
|
|
14
13
|
stack: IStackMode;
|
|
15
14
|
enableCrossFilter: boolean;
|
|
@@ -32,6 +31,7 @@ export function getSingleView(props: SingleViewProps) {
|
|
|
32
31
|
column,
|
|
33
32
|
xOffset,
|
|
34
33
|
yOffset,
|
|
34
|
+
details,
|
|
35
35
|
defaultAggregated,
|
|
36
36
|
stack,
|
|
37
37
|
geomType,
|
|
@@ -70,27 +70,25 @@ export function getSingleView(props: SingleViewProps) {
|
|
|
70
70
|
yOffset,
|
|
71
71
|
theta,
|
|
72
72
|
radius,
|
|
73
|
+
details
|
|
73
74
|
});
|
|
75
|
+
addTooltipEncode(encoding, details)
|
|
74
76
|
if (defaultAggregated) {
|
|
75
77
|
channelAggregate(encoding, fields);
|
|
76
78
|
}
|
|
77
79
|
channelStack(encoding, stack);
|
|
80
|
+
const mark = {
|
|
81
|
+
type: markType,
|
|
82
|
+
opacity: 0.96,
|
|
83
|
+
tooltip: { content: 'data' }
|
|
84
|
+
};
|
|
78
85
|
if (!enableCrossFilter || (brushEncoding === 'none' && selectEncoding === 'none')) {
|
|
79
86
|
return {
|
|
80
87
|
config,
|
|
81
|
-
mark
|
|
82
|
-
type: markType,
|
|
83
|
-
opacity: 0.96,
|
|
84
|
-
tooltip: true,
|
|
85
|
-
},
|
|
88
|
+
mark,
|
|
86
89
|
encoding,
|
|
87
90
|
};
|
|
88
91
|
}
|
|
89
|
-
const mark = {
|
|
90
|
-
type: markType,
|
|
91
|
-
opacity: 0.96,
|
|
92
|
-
tooltip: true,
|
|
93
|
-
};
|
|
94
92
|
|
|
95
93
|
if (brushEncoding !== 'none') {
|
|
96
94
|
return {
|