@kanaries/graphic-walker 0.3.5 → 0.3.6
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 +6 -0
- package/dist/assets/{transform.worker-5d54ff09.js.map → transform.worker-90e4f506.js.map} +1 -1
- package/dist/assets/viewQuery.worker-03404216.js.map +1 -1
- package/dist/graphic-walker.es.js +1221 -1215
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +40 -40
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/interfaces.d.ts +1 -1
- package/dist/visualSettings/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/App.tsx +9 -1
- package/src/interfaces.ts +1 -1
- package/src/locales/en-US.json +2 -1
- package/src/locales/ja-JP.json +2 -1
- package/src/locales/zh-CN.json +2 -1
- package/src/store/visualSpecStore.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/visualSettings/index.tsx +17 -4
- package/src/workers/transform.ts +1 -1
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IDarkMode } from '../interfaces';
|
|
3
3
|
import { IReactVegaHandler } from '../vis/react-vega';
|
|
4
|
+
import { ToolbarItemProps } from '../components/toolbar';
|
|
4
5
|
interface IVisualSettings {
|
|
5
6
|
darkModePreference: IDarkMode;
|
|
6
7
|
rendererHandler?: React.RefObject<IReactVegaHandler>;
|
|
8
|
+
exclude?: string[];
|
|
9
|
+
extra?: ToolbarItemProps[];
|
|
7
10
|
}
|
|
8
11
|
declare const _default: React.FunctionComponent<IVisualSettings>;
|
|
9
12
|
export default _default;
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import DatasetConfig from './dataSource/datasetConfig';
|
|
|
19
19
|
import { useCurrentMediaTheme } from './utils/media';
|
|
20
20
|
import CodeExport from './components/codeExport';
|
|
21
21
|
import VisualConfig from './components/visualConfig';
|
|
22
|
+
import type { ToolbarItemProps } from './components/toolbar';
|
|
22
23
|
|
|
23
24
|
export interface IGWProps {
|
|
24
25
|
dataSource?: IRow[];
|
|
@@ -36,6 +37,10 @@ export interface IGWProps {
|
|
|
36
37
|
themeKey?: IThemeKey;
|
|
37
38
|
dark?: IDarkMode;
|
|
38
39
|
storeRef?: React.MutableRefObject<IGlobalStore | null>;
|
|
40
|
+
toolbar?: {
|
|
41
|
+
extra?: ToolbarItemProps[];
|
|
42
|
+
exclude?: string[];
|
|
43
|
+
};
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
const App = observer<IGWProps>(function App(props) {
|
|
@@ -49,6 +54,7 @@ const App = observer<IGWProps>(function App(props) {
|
|
|
49
54
|
fieldKeyGuard = true,
|
|
50
55
|
themeKey = 'vega',
|
|
51
56
|
dark = 'media',
|
|
57
|
+
toolbar,
|
|
52
58
|
} = props;
|
|
53
59
|
const { commonStore, vizStore } = useGlobalStore();
|
|
54
60
|
|
|
@@ -124,7 +130,7 @@ const App = observer<IGWProps>(function App(props) {
|
|
|
124
130
|
style={{ marginTop: '0em', borderTop: 'none' }}
|
|
125
131
|
className="m-4 p-4 border border-gray-200 dark:border-gray-700"
|
|
126
132
|
>
|
|
127
|
-
<VisualSettings rendererHandler={rendererRef} darkModePreference={dark} />
|
|
133
|
+
<VisualSettings rendererHandler={rendererRef} darkModePreference={dark} exclude={toolbar?.exclude} extra={toolbar?.extra} />
|
|
128
134
|
<CodeExport />
|
|
129
135
|
<VisualConfig />
|
|
130
136
|
<div className="md:grid md:grid-cols-12 xl:grid-cols-6">
|
|
@@ -187,3 +193,5 @@ const App = observer<IGWProps>(function App(props) {
|
|
|
187
193
|
});
|
|
188
194
|
|
|
189
195
|
export default App;
|
|
196
|
+
|
|
197
|
+
export type { ToolbarItemProps };
|
package/src/interfaces.ts
CHANGED
package/src/locales/en-US.json
CHANGED
|
@@ -148,7 +148,8 @@
|
|
|
148
148
|
"descending": "Sort in Descending Order",
|
|
149
149
|
"transpose": "Transpose",
|
|
150
150
|
"export_chart": "Export",
|
|
151
|
-
"export_chart_as": "Export as {{type}}"
|
|
151
|
+
"export_chart_as": "Export as {{type}}",
|
|
152
|
+
"export_code": "Export Code"
|
|
152
153
|
},
|
|
153
154
|
"size": "Resize",
|
|
154
155
|
"size_setting": {
|
package/src/locales/ja-JP.json
CHANGED
|
@@ -147,7 +147,8 @@
|
|
|
147
147
|
"descending": "降順に並べ替える",
|
|
148
148
|
"transpose": "転置",
|
|
149
149
|
"export_chart": "エクスポート",
|
|
150
|
-
"export_chart_as": "{{type}}としてエクスポート"
|
|
150
|
+
"export_chart_as": "{{type}}としてエクスポート",
|
|
151
|
+
"export_code": "コードをエクスポート"
|
|
151
152
|
},
|
|
152
153
|
"size": "サイズ変更",
|
|
153
154
|
"size_setting": {
|
package/src/locales/zh-CN.json
CHANGED
|
@@ -505,7 +505,7 @@ export class VizSpecStore {
|
|
|
505
505
|
semanticType: "ordinal",
|
|
506
506
|
analyticType: "dimension",
|
|
507
507
|
computed: true,
|
|
508
|
-
|
|
508
|
+
expression: {
|
|
509
509
|
op: binType,
|
|
510
510
|
as: newVarKey,
|
|
511
511
|
params: [
|
|
@@ -535,7 +535,7 @@ export class VizSpecStore {
|
|
|
535
535
|
analyticType: originField.analyticType,
|
|
536
536
|
aggName: 'sum',
|
|
537
537
|
computed: true,
|
|
538
|
-
|
|
538
|
+
expression: {
|
|
539
539
|
op: scaleType,
|
|
540
540
|
as: newVarKey,
|
|
541
541
|
params: [
|
package/src/utils/index.ts
CHANGED
|
@@ -61,9 +61,11 @@ const FormContainer = styled.div`
|
|
|
61
61
|
interface IVisualSettings {
|
|
62
62
|
darkModePreference: IDarkMode;
|
|
63
63
|
rendererHandler?: React.RefObject<IReactVegaHandler>;
|
|
64
|
+
exclude?: string[];
|
|
65
|
+
extra?: ToolbarItemProps[];
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePreference }) => {
|
|
68
|
+
const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePreference, extra = [], exclude = [] }) => {
|
|
67
69
|
const { vizStore, commonStore } = useGlobalStore();
|
|
68
70
|
const { visualConfig, canUndo, canRedo } = vizStore;
|
|
69
71
|
const { t: tGlobal } = useTranslation();
|
|
@@ -85,7 +87,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
|
|
|
85
87
|
const dark = useCurrentMediaTheme(darkModePreference) === 'dark';
|
|
86
88
|
|
|
87
89
|
const items = useMemo<ToolbarItemProps[]>(() => {
|
|
88
|
-
|
|
90
|
+
const builtInItems = [
|
|
89
91
|
{
|
|
90
92
|
key: 'undo',
|
|
91
93
|
label: 'undo (Ctrl + Z)',
|
|
@@ -296,9 +298,20 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler, darkModePr
|
|
|
296
298
|
onClick: () => {
|
|
297
299
|
commonStore.setShowCodeExportPanel(true);
|
|
298
300
|
}
|
|
299
|
-
}
|
|
301
|
+
},
|
|
300
302
|
] as ToolbarItemProps[];
|
|
301
|
-
|
|
303
|
+
|
|
304
|
+
const items = builtInItems.filter(item => typeof item === 'string' || !exclude.includes(item.key));
|
|
305
|
+
|
|
306
|
+
if (extra.length > 0) {
|
|
307
|
+
items.push(
|
|
308
|
+
'-',
|
|
309
|
+
...extra,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return items;
|
|
314
|
+
}, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height, showActions, downloadPNG, downloadSVG, dark, extra, exclude]);
|
|
302
315
|
|
|
303
316
|
return <div style={{ margin: '0.38em 0.28em 0.2em 0.18em' }}>
|
|
304
317
|
<Toolbar
|
package/src/workers/transform.ts
CHANGED
|
@@ -6,7 +6,7 @@ export function transformData(data: IRow[], columns: IField[]) {
|
|
|
6
6
|
let df = dataset2DataFrame(data, columns);
|
|
7
7
|
for (let i = 0; i < computedFields.length; i++) {
|
|
8
8
|
const field = computedFields[i];
|
|
9
|
-
df = execExpression(field.
|
|
9
|
+
df = execExpression(field.expression!, df, columns);
|
|
10
10
|
}
|
|
11
11
|
return dataframe2Dataset(df, columns);
|
|
12
12
|
}
|