@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.
@@ -75,7 +75,7 @@ export interface IField {
75
75
  analyticType: IAnalyticType;
76
76
  cmp?: (a: any, b: any) => number;
77
77
  computed?: boolean;
78
- expressoion?: IExpression;
78
+ expression?: IExpression;
79
79
  }
80
80
  export interface IViewField extends IField {
81
81
  dragId: string;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanaries/graphic-walker",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "scripts": {
5
5
  "dev:front_end": "vite --host",
6
6
  "dev": "npm run dev:front_end",
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
@@ -86,7 +86,7 @@ export interface IField {
86
86
  analyticType: IAnalyticType;
87
87
  cmp?: (a: any, b: any) => number;
88
88
  computed?: boolean;
89
- expressoion?: IExpression;
89
+ expression?: IExpression;
90
90
  }
91
91
 
92
92
  export interface IViewField extends IField {
@@ -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": {
@@ -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": {
@@ -148,7 +148,8 @@
148
148
  "descending": "降序排序",
149
149
  "transpose": "转置",
150
150
  "export_chart": "导出",
151
- "export_chart_as": "导出 {{type}}"
151
+ "export_chart_as": "导出 {{type}}",
152
+ "export_code": "导出代码"
152
153
  },
153
154
  "size": "调整尺寸",
154
155
  "size_setting": {
@@ -505,7 +505,7 @@ export class VizSpecStore {
505
505
  semanticType: "ordinal",
506
506
  analyticType: "dimension",
507
507
  computed: true,
508
- expressoion: {
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
- expressoion: {
538
+ expression: {
539
539
  op: scaleType,
540
540
  as: newVarKey,
541
541
  params: [
@@ -246,7 +246,7 @@ export function createCountField(): IViewField {
246
246
  semanticType: "quantitative",
247
247
  aggName: 'sum',
248
248
  computed: true,
249
- expressoion: {
249
+ expression: {
250
250
  op: 'one',
251
251
  params: [],
252
252
  as: COUNT_FIELD_ID,
@@ -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
- return [
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
- }, [vizStore, canUndo, canRedo, defaultAggregated, markType, stack, interactiveScale, sizeMode, width, height, showActions, downloadPNG, downloadSVG, dark]);
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
@@ -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.expressoion!, df, columns);
9
+ df = execExpression(field.expression!, df, columns);
10
10
  }
11
11
  return dataframe2Dataset(df, columns);
12
12
  }