-
Notifications
You must be signed in to change notification settings - Fork 118
/
interfaces.ts
1160 lines (1046 loc) · 29.8 KB
/
interfaces.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Config as VgConfig, View } from 'vega';
import { Config as VlConfig } from 'vega-lite';
import type { FeatureCollection, Geometry, GeoJsonProperties } from 'geojson';
import type { feature } from 'topojson-client';
import { DATE_TIME_DRILL_LEVELS } from './constants';
import { ToolbarItemProps } from './components/toolbar';
import { GWGlobalConfig } from './vis/theme';
import { VizSpecStore } from './store/visualSpecStore';
import { CommonStore } from './store/commonStore';
import type { XOR } from 'ts-xor';
export type DeepReadonly<T extends Record<keyof any, any>> = {
readonly [K in keyof T]: T[K] extends Record<keyof any, any> ? DeepReadonly<T[K]> : T[K];
};
export type ISemanticType = 'quantitative' | 'nominal' | 'ordinal' | 'temporal';
export type IDataType = 'number' | 'integer' | 'boolean' | 'date' | 'string';
export type IAnalyticType = 'dimension' | 'measure';
export interface IRow {
[key: string]: any;
}
export type IAggregator = 'sum' | 'count' | 'max' | 'min' | 'mean' | 'median' | 'variance' | 'stdev' | 'distinctCount' | 'expr';
export type IEmbedMenuItem = 'data_interpretation' | 'data_view';
export interface Specification {
position?: string[];
color?: string[];
size?: string[];
shape?: string[];
opacity?: string[];
facets?: string[];
page?: string[];
filter?: string[];
highFacets?: string[];
geomType?: string[];
aggregate?: boolean;
}
export interface Filters {
[key: string]: any[];
}
export interface ICreateField {
channel: 'dimensions' | 'measures';
index: number;
}
export interface IMutField {
fid: string;
key?: string;
name?: string;
basename?: string;
disable?: boolean;
semanticType: ISemanticType;
analyticType: IAnalyticType;
path?: string[];
offset?: number;
}
export interface IUncertainMutField {
fid: string;
key?: string;
name?: string;
basename?: string;
disable?: boolean;
semanticType: ISemanticType | '?';
analyticType: IAnalyticType | '?';
path: string[];
}
export interface IDatasetStats {
rowCount: number;
}
export interface IFieldStats {
values: { value: number | string; count: number }[];
valuesMeta: { total: number; distinctTotal: number };
selectedCount: number;
range: [number, number];
}
/** @deprecated */
export interface IPaintMap {
/** fid of x */
x: string;
/** fid of y */
y: string;
domainX: [number, number];
domainY: [number, number];
/** width */
mapwidth: number;
/** a bit map, compressed array of UInt8[mapwidth][mapwidth] */
map: string;
/** map values */
dict: Record<number, { name: string; color: string }>;
usedColor: number[];
}
export interface IPaintDimension {
fid: string;
domain:
| {
type: 'nominal';
value: any[];
// = value.length
width: number;
}
| {
type: 'quantitative';
value: [number, number];
width: number;
};
// TODO: impement the temporal support
// | {
// type: 'temporal';
// value: [number, number];
// width: number;
// offset?: number;
// format?: string;
// };
}
export interface IPaintMapFacet {
dimensions: IPaintDimension[];
/** a bit map, compressed array of UInt8[dimensions.reduce((x,d) => x * d.domain.width, 1)] */
map: string;
usedColor: number[];
}
export interface IPaintMapV2 {
facets: IPaintMapFacet[];
dict: Record<number, { name: string; color: string }>;
usedColor: number[];
}
export type IExpParameter =
| {
type: 'field';
value: string;
}
| {
type: 'value';
value: any;
}
| {
type: 'expression';
value: IExpression;
}
| {
type: 'constant';
value: any;
}
| {
type: 'format';
value: string;
}
| {
type: 'offset';
value: number;
}
| {
type: 'map';
value: IPaintMap;
}
| {
type: 'sql';
value: string;
}
| {
type: 'newmap';
value: IPaintMapV2;
}
| {
type: 'displayOffset';
value: number;
};
export interface IExpression {
op: 'bin' | 'log2' | 'log10' | 'one' | 'binCount' | 'dateTimeDrill' | 'dateTimeFeature' | 'log' | 'paint' | 'expr';
params: IExpParameter[];
as: string;
num?: number;
}
export type IGeoRole = 'longitude' | 'latitude' | 'none';
export interface IField {
/**
* fid: key in data record
*/
fid: string;
/**
* display name for field
*/
name: string;
/**
* aggregator's name, "expr" represents for aggergated computed field.
*/
aggName?: string;
semanticType: ISemanticType;
analyticType: IAnalyticType;
cmp?: string;
geoRole?: IGeoRole;
computed?: boolean;
expression?: IExpression;
timeUnit?: (typeof DATE_TIME_DRILL_LEVELS)[number];
basename?: string;
path?: string[];
offset?: number;
aggergated?: boolean;
}
export type ISortMode = 'none' | 'ascending' | 'descending';
export interface IViewField extends IField {
sort?: ISortMode;
}
// shadow type of identifier of a Field, getting it using "getFieldIdentifier" in "@/utils"
export type FieldIdentifier = string & { _tagFieldId: never };
export interface DataSet {
id: string;
name: string;
rawFields: IMutField[];
dataSource: IRow[];
}
export interface IFieldNeighbor {
key: string;
cc: number;
}
export interface IMeasure {
key: string;
op: IAggregator;
}
export interface IPredicate {
key: string;
type: 'discrete' | 'continuous';
range: Set<any> | [number, number];
}
export interface IExplainProps {
dataSource: IRow[];
predicates: IPredicate[];
viewFields: IField[];
metas: IField[];
}
/** @deprecated */
export interface IDataSet {
id: string;
name: string;
rawFields: IMutField[];
dsId: string;
}
/**
* use as props to create a new dataset(IDataSet).
*/
export interface IDataSetInfo {
name: string;
rawFields: IMutField[];
dataSource: IRow[];
}
export interface IDataSource {
id: string;
metaId?: string;
name?: string;
data: IRow[];
}
export interface IFilterField extends IViewField {
rule: IFilterRule | null;
enableAgg?: boolean;
}
export interface IFilterFiledSimple {
fid: string;
rule: IFilterRule | null;
}
export interface DraggableFieldState {
dimensions: IViewField[];
measures: IViewField[];
rows: IViewField[];
columns: IViewField[];
color: IViewField[];
opacity: IViewField[];
size: IViewField[];
shape: IViewField[];
theta: IViewField[];
radius: IViewField[];
longitude: IViewField[];
latitude: IViewField[];
geoId: IViewField[];
details: IViewField[];
filters: IFilterField[];
text: IViewField[];
}
export interface IDraggableStateKey {
id: keyof DraggableFieldState;
mode: number;
}
export interface IDraggableViewStateKey {
id: keyof Omit<DraggableFieldState, 'filters'>;
mode: number;
}
export type IFilterRule =
| {
type: 'range';
value: [number | null, number | null];
}
| {
type: 'temporal range';
value: [number | null, number | null];
offset?: number;
format?: string;
}
| {
type: 'one of';
value: any[];
}
| {
type: 'not in';
value: any[];
}
| {
type: 'regexp';
value: string;
caseSensitive?: boolean;
};
export interface IKeyWord {
value: string;
caseSenstive: boolean;
word: boolean;
regexp: boolean;
}
export type IStackMode = 'none' | 'stack' | 'normalize' | 'zero' | 'center';
export type ICoordMode = 'generic' | 'geographic';
export type IConfigScale = {
rangeMax?: number;
rangeMin?: number;
domainMin?: number;
domainMax?: number;
};
export interface IVisualConfig {
defaultAggregated: boolean;
geoms: string[];
showTableSummary: boolean;
/** @default "generic" */
coordSystem?: ICoordMode;
stack: IStackMode;
showActions: boolean;
interactiveScale: boolean;
sorted: ISortMode;
zeroScale: boolean;
/** @default false */
scaleIncludeUnmatchedChoropleth?: boolean;
background?: string;
useSvg?: boolean;
format: {
numberFormat?: string;
timeFormat?: string;
normalizedNumberFormat?: string;
};
primaryColor?: string;
colorPalette?: string;
scale?: {
opacity: IConfigScale;
size: IConfigScale;
};
resolve: {
x?: boolean;
y?: boolean;
color?: boolean;
opacity?: boolean;
shape?: boolean;
size?: boolean;
};
size: {
mode: 'auto' | 'fixed';
width: number;
height: number;
};
geojson?: FeatureCollection<Geometry, GeoJsonProperties>;
geoKey?: string;
geoUrl?: IGeoUrl;
limit: number;
folds?: string[];
}
export interface IVisualLayout {
showTableSummary: boolean;
format: {
numberFormat?: string;
timeFormat?: string;
normalizedNumberFormat?: string;
};
primaryColor?: string;
colorPalette?: string;
scale?: {
opacity: IConfigScale;
size: IConfigScale;
};
resolve: {
x?: boolean;
y?: boolean;
color?: boolean;
opacity?: boolean;
shape?: boolean;
size?: boolean;
};
size: {
mode: 'auto' | 'fixed' | 'full';
width: number;
height: number;
};
useSvg?: boolean;
geojson?: FeatureCollection<Geometry, GeoJsonProperties>;
geoKey?: string;
geoUrl?: IGeoUrl;
geoMapTileUrl?: string;
interactiveScale: boolean;
stack: IStackMode;
showActions: boolean;
zeroScale: boolean;
background?: string;
/** @default false */
scaleIncludeUnmatchedChoropleth?: boolean;
showAllGeoshapeInChoropleth?: boolean;
}
export interface IVisualConfigNew {
defaultAggregated: boolean;
geoms: string[];
/** @default "generic" */
coordSystem?: ICoordMode;
limit: number;
folds?: string[];
timezoneDisplayOffset?: number;
}
export interface IGeoUrl {
type: 'GeoJSON' | 'TopoJSON';
url: string;
}
/** @deprecated */
export interface IVisSpec {
readonly visId: string;
readonly name?: string;
readonly encodings: DeepReadonly<DraggableFieldState>;
readonly config: DeepReadonly<IVisualConfig>;
}
export enum ISegmentKey {
vis = 'vis',
data = 'data',
chat = 'chat',
}
export type IThemeKey = 'vega' | 'g2' | 'streamlit';
export type IDarkMode = 'media' | 'light' | 'dark';
export type IComputationFunction = (payload: IDataQueryPayload) => Promise<IRow[]>;
export type VegaGlobalConfig = VgConfig & VlConfig & { leafletGeoTileUrl?: string };
export interface IVegaChartRef {
x: number;
y: number;
w: number;
h: number;
innerWidth: number;
innerHeight: number;
view: View;
canvas: HTMLCanvasElement | SVGSVGElement | null;
}
export interface IChartExportResult<T extends 'svg' | 'data-url' = 'svg' | 'data-url'> {
mode: T;
title: string;
nCols: number;
nRows: number;
charts: {
colIndex: number;
rowIndex: number;
width: number;
height: number;
canvasWidth: number;
canvasHeight: number;
data: string;
canvas(): HTMLCanvasElement | SVGSVGElement | null;
}[];
container(): HTMLDivElement | null;
chartType?: string;
}
interface IExportChart {
<T extends Extract<IChartExportResult['mode'], 'svg'>>(mode?: T): Promise<IChartExportResult<T>>;
<T extends IChartExportResult['mode']>(mode: T): Promise<IChartExportResult<T>>;
}
export interface IChartListExportResult<T extends 'svg' | 'data-url' = 'svg' | 'data-url'> {
mode: T;
total: number;
index: number;
data: IChartExportResult<T>;
hasNext: boolean;
}
interface IExportChartList {
<T extends Extract<IChartExportResult['mode'], 'svg'>>(mode?: T): AsyncGenerator<IChartListExportResult<T>, void, unknown>;
<T extends IChartExportResult['mode']>(mode: T): AsyncGenerator<IChartListExportResult<T>, void, unknown>;
}
/**
* The status of the current chart.
* * `computing`: _GraphicWalker_ is computing the data view.
* * `rendering`: _GraphicWalker_ is rendering the chart.
* * `idle`: rendering is finished.
* * `error`: an error occurs during the process above.
*/
export type IRenderStatus = 'computing' | 'rendering' | 'idle' | 'error';
export interface IGWHandler {
/** length of the "chart" tab list */
chartCount: number;
/** current selected chart index */
chartIndex: number;
/** Switches to the specified chart */
openChart: (index: number) => void;
/**
* Returns the status of the current chart.
*
* It is computed by the following rules:
* - If _GraphicWalker_ is computing the data view, it returns `computing`.
* - If _GraphicWalker_ is rendering the chart, it returns `rendering`.
* - If rendering is finished, it returns `idle`.
* - If an error occurs during the process above, it returns `error`.
*/
get renderStatus(): IRenderStatus;
/**
* Registers a callback function to listen to the status change of the current chart.
*
* @param {(renderStatus: IRenderStatus) => void} cb - the callback function
* @returns {() => void} a dispose function to remove this callback
*/
onRenderStatusChange: (cb: (renderStatus: IRenderStatus) => void) => () => void;
/**
* Exports the current chart.
*
* @param {IChartExportResult['mode']} [mode='svg'] - the export mode, either `svg` or `data-url`
*/
exportChart: IExportChart;
/**
* Exports all charts.
*
* @param {IChartExportResult['mode']} [mode='svg'] - the export mode, either `svg` or `data-url`
* @returns {AsyncGenerator<IChartListExportResult, void, unknown>} an async generator to iterate over all charts
* @example
* ```ts
* for await (const chart of gwRef.current.exportChartList()) {
* console.log(chart);
* }
* ```
*/
exportChartList: IExportChartList;
}
export interface IGWHandlerInsider extends IGWHandler {
updateRenderStatus: (renderStatus: IRenderStatus) => void;
}
export interface IVisField {
key: string;
type: ISemanticType;
name?: string;
description?: string;
format?: string;
expression?: IExpression;
}
export type IVisFieldComputation = {
field: IVisField['key'];
expression: NonNullable<IVisField['expression']>;
name: NonNullable<IVisField['name']>;
type: IVisField['type'];
};
export type IFieldTransform = {
key: IVisFieldComputation['field'];
expression: IVisFieldComputation['expression'];
};
export interface IVisFilter {
fid: string;
rule: IFilterRule;
}
export interface IFilterWorkflowStep {
type: 'filter';
filters: IVisFilter[];
}
export interface ITransformWorkflowStep {
type: 'transform';
transform: IFieldTransform[];
}
export interface IViewWorkflowStep {
type: 'view';
query: IViewQuery[];
}
export interface ISortWorkflowStep {
type: 'sort';
sort: 'ascending' | 'descending';
by: string[];
}
export type IDataQueryWorkflowStep = IFilterWorkflowStep | ITransformWorkflowStep | IViewWorkflowStep | ISortWorkflowStep;
export interface IDataQueryPayload {
workflow: IDataQueryWorkflowStep[];
limit?: number;
offset?: number;
}
export interface ILoadDataPayload {
pageSize: number;
pageIndex: number;
}
export interface IGWDatasetStat {
count: number;
}
export type IResponse<T> =
| {
success: true;
data: T;
}
| {
success: false;
message: string;
error?: {
code: `ERR_${Uppercase<string>}`;
options?: Record<string, string>;
};
};
export interface IAggQuery {
op: 'aggregate';
groupBy: string[];
measures: { field: string; agg: IAggregator; asFieldKey: string; format?: string; offset?: number }[];
}
export interface IFoldQuery {
op: 'fold';
foldBy: string[];
newFoldKeyCol: string;
newFoldValueCol: string;
}
export interface IBinQuery {
op: 'bin';
binBy: string;
newBinCol: string;
binSize: number;
}
export interface IRawQuery {
op: 'raw';
fields: string[];
}
export type IViewQuery = IAggQuery | IFoldQuery | IBinQuery | IRawQuery;
export interface IChart {
visId: string;
name?: string;
encodings: DraggableFieldState;
config: IVisualConfigNew;
layout: IVisualLayout;
}
export interface PartialChart {
visId?: string;
name?: string;
encodings?: Partial<DraggableFieldState>;
config?: Partial<IVisualConfigNew>;
layout?: Partial<IVisualLayout>;
}
export type Topology = Parameters<typeof feature>[0];
export type IGeographicData =
| {
type: 'GeoJSON';
data: FeatureCollection;
}
| {
type: 'TopoJSON';
data: Topology;
/**
* default to the first key of `objects` in Topology
*/
objectKey?: string;
};
export type IGeoDataItem = {
type: 'GeoJSON' | 'TopoJSON';
name: string;
url: string;
};
function toDict<T extends string>(a: readonly T[]) {
return Object.fromEntries(a.map((x) => [x, x])) as {
[k in T]: k;
};
}
export const ColorSchemes = {
/**
* @name Categorical Schemes
* @summary For nominal data.
* @description Categorical color schemes can be used to encode discrete data values, each representing a distinct category.
*/
discrete: toDict([
'accent',
'category10',
'category20',
'category20b',
'category20c',
'dark2',
'paired',
'pastel1',
'pastel2',
'set1',
'set2',
'set3',
'tableau10',
'tableau20',
] as const),
/**
* @name Sequential Single-Hue Schemes
* @summary For increasing quantitative data.
* @description Sequential color schemes can be used to encode quantitative values. These color ramps are designed to encode increasing numeric values.
*/
single: toDict(['blues', 'tealblues', 'teals', 'greens', 'browns', 'oranges', 'reds', 'purples', 'warmgreys', 'greys'] as const),
/**
* @name Sequential Multi-Hue Schemes
* @summary For quantitative data in heatmaps.
* @description Sequential color schemes can be used to encode quantitative values. These color ramps are designed to encode increasing numeric values, but use additional hues for more color discrimination, which may be useful for visualizations such as heatmaps. However, beware that using multiple hues may cause viewers to inaccurately see the data range as grouped into color-coded clusters.
*/
multi: toDict([
'viridis',
'magma',
'inferno',
'plasma',
'cividis',
'turbo',
'bluegreen',
'bluepurple',
'goldgreen',
'goldorange',
'goldred',
'greenblue',
'orangered',
'purplebluegreen',
'purpleblue',
'purplered',
'redpurple',
'yellowgreenblue',
'yellowgreen',
'yelloworangebrown',
'yelloworangered',
'darkblue',
'darkgold',
'darkgreen',
'darkmulti',
'darkred',
'lightgreyred',
'lightgreyteal',
'lightmulti',
'lightorange',
'lighttealblue',
] as const),
/**
* @name Diverging Schemes
* @summary For quantitative data with meaningful mid-point.
* @description Diverging color schemes can be used to encode quantitative values with a meaningful mid-point, such as zero or the average value. Color ramps with different hues diverge with increasing saturation to highlight the values below and above the mid-point.
*/
deiverging: toDict([
'blueorange',
'brownbluegreen',
'purplegreen',
'pinkyellowgreen',
'purpleorange',
'redblue',
'redgrey',
'redyellowblue',
'redyellowgreen',
'spectral',
] as const),
/**
* @name Cyclical Schemes
* @summary For quantitative data with periodic patterns.
* @description Cyclical color schemes may be used to highlight periodic patterns in continuous data. However, these schemes are not well suited to accurately convey value differences.
*/
cyclical: toDict(['rainbow', 'sinebow'] as const),
};
export type IPreDefinedColorSchemes =
| keyof (typeof ColorSchemes)['discrete']
| keyof (typeof ColorSchemes)['single']
| keyof (typeof ColorSchemes)['multi']
| keyof (typeof ColorSchemes)['deiverging']
| keyof (typeof ColorSchemes)['cyclical'];
export type IColorSchemes =
| IPreDefinedColorSchemes
| {
name: IPreDefinedColorSchemes;
extent?: [number, number];
count?: number;
};
export type IScale = {
domain?: [number, number] | string[];
domainMin?: number;
domainMax?: number;
range?: [number, number] | string[];
rangeMin?: number;
rangeMax?: number;
};
export type IColorScale = IScale & { scheme?: IColorSchemes };
export type IFieldInfos = {
semanticType: ISemanticType;
theme: 'dark' | 'light';
values: any[];
};
export interface IChannelScales {
color?: IColorScale | ((info: IFieldInfos) => IColorScale);
opacity?: IScale | ((info: IFieldInfos) => IScale);
size?: IScale | ((info: IFieldInfos) => IScale);
radius?: IScale | ((info: IFieldInfos) => IScale);
theta?: IScale | ((info: IFieldInfos) => IScale);
}
export interface IAppI18nProps {
i18nLang?: string;
i18nResources?: { [lang: string]: Record<string, string | any> };
}
export interface IThemeProps {
/** @deprecated renamed to appearence */
dark?: IDarkMode;
appearance?: IDarkMode;
/** @deprecated renamed to uiTheme */
colorConfig?: IUIThemeConfig;
uiTheme?: IUIThemeConfig;
}
export interface IErrorHandlerProps {
onError?: (err: Error) => void;
}
export interface IUserChatMessage {
content: string;
role: 'user';
type: 'generated' | 'normal';
}
export interface IAssistantChatMessage {
chart: IChart;
role: 'assistant';
type: 'generated' | 'normal';
}
export type IChatMessage = IUserChatMessage | IAssistantChatMessage;
export interface IVizProps {
/** @deprecated use vizThemeConfig instead */
themeKey?: IThemeKey;
/** @deprecated use vizThemeConfig instead */
themeConfig?: GWGlobalConfig;
vizThemeConfig?: IThemeKey | GWGlobalConfig;
toolbar?: {
extra?: ToolbarItemProps[];
exclude?: string[];
};
/** hide the chart navigation so make user can only edit on the only chart. */
hideChartNav?: boolean;
geographicData?: IGeographicData & {
key: string;
};
enhanceAPI?: {
header?: Record<string, string>;
features?: {
askviz?: string | boolean | ((metas: IViewField[], query: string) => PromiseLike<IVisSpec | IChart> | IVisSpec | IChart);
feedbackAskviz?: string | boolean | ((data: IAskVizFeedback) => void);
vlChat?: string | boolean | ((metas: IViewField[], chats: IChatMessage[]) => PromiseLike<IVisSpec | IChart> | IVisSpec | IChart);
};
};
geoList?: IGeoDataItem[];
/** @deprecated renamed to scales */
channelScales?: IChannelScales;
scales?: IChannelScales;
experimentalFeatures?: IExperimentalFeatures;
}
export interface IExperimentalFeatures {
computedField?: boolean;
}
export interface IDefaultConfig {
config?: Partial<IVisualConfigNew>;
layout?: Partial<IVisualLayout>;
}
export interface IVizStoreProps {
storeRef?: React.MutableRefObject<VizSpecStore | null>;
keepAlive?: boolean | string;
/** @deprecated renamed to fields */
rawFields?: IMutField[];
fields?: IMutField[];
onMetaChange?: (fid: string, meta: Partial<IMutField>) => void;
defaultConfig?: IDefaultConfig;
}
export interface ILocalComputationProps {
/**
* @deprecated will be removed in the future
*/
fieldKeyGuard?: boolean;
/** @deprecated renamed to data */
dataSource?: any[];
data?: any[];
computationTimeout?: number;
}
export interface IRemoteComputationProps {
computation: IComputationFunction;
}
export interface IComputationContextProps {
computation?: IComputationFunction;
computationTimeout?: number;
}
export type IComputationProps = XOR<IRemoteComputationProps, ILocalComputationProps>;
export type IGWProps = IAppI18nProps &
IVizProps &
IThemeProps &
IErrorHandlerProps & {
storeRef?: React.MutableRefObject<CommonStore | null>;
keepAlive?: boolean | string;
};
export interface ISpecProps {
spec?: Specification;
vlSpec?: any;
chart?: IChart[] | IVisSpec[];
}
export interface ITableSpecProps {
pageSize?: number;
displayOffset?: number;
/** @deprecated use vizThemeConfig instead */
themeKey?: IThemeKey;
/** @deprecated use vizThemeConfig instead */
themeConfig?: GWGlobalConfig;
vizThemeConfig?: IThemeKey | GWGlobalConfig;
}
export interface IVizAppProps extends IAppI18nProps, IVizProps, IThemeProps, IErrorHandlerProps, IVizStoreProps, ISpecProps {}
export interface ITableProps extends IAppI18nProps, ITableSpecProps, IThemeProps, IErrorHandlerProps, IVizStoreProps {}
export interface IAskVizFeedback {
action: 'voteup' | 'votedown' | 'report';
question: string;
spec: string;
}
export const IDataSourceEventType = {
updateList: 1,
updateMeta: 2,
updateSpec: 4,