-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
vis-state-actions.ts
1509 lines (1434 loc) · 34.9 KB
/
vis-state-actions.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
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
// vis-state-reducer
import {PickInfo} from '@deck.gl/core/lib/deck';
import {default as ActionTypes} from './action-types';
import {FileCacheItem} from '@kepler.gl/processors';
import {Layer, LayerBaseConfig} from '@kepler.gl/layers';
import {
AddDataToMapPayload,
ValueOf,
Merge,
RGBColor,
NestedPartial,
LayerVisConfig,
ColorUI,
Feature,
FeatureSelectionContext,
InteractionConfig,
Filter,
ParsedConfig,
ParsedLayer,
EffectPropsPartial
} from '@kepler.gl/types';
// TODO - import LoaderObject type from @loaders.gl/core when supported
// TODO - import LoadOptions type from @loaders.gl/core when supported
export type ApplyLayerConfigUpdaterAction = {
oldLayerId: string;
newLayerConfig: ParsedLayer;
layerIndex?: number;
};
/**
* Update layer base config: dataId, label, column, isVisible
* @param oldLayerId - layer id to be updated
* @param newLayerConfig - new layer config
* @param layerIndex - (Optional) Index of the layer to be updated (can be useful in some cases, because
* the layer id might change during update, e.g. when the type of the layer changes)
* @returns action
* @public
*/
export function applyLayerConfig(
oldLayerId: string,
newLayerConfig: ParsedLayer,
layerIndex?: number
): Merge<ApplyLayerConfigUpdaterAction, {type: typeof ActionTypes.APPLY_LAYER_CONFIG}> {
return {
type: ActionTypes.APPLY_LAYER_CONFIG,
oldLayerId,
newLayerConfig,
layerIndex
};
}
export type LayerConfigChangeUpdaterAction = {
oldLayer: Layer;
newConfig: Partial<LayerBaseConfig>;
};
/**
* Update layer base config: dataId, label, column, isVisible
* @param oldLayer - layer to be updated
* @param newConfig - new config to be merged with old config
* @returns action
* @public
*/
export function layerConfigChange(
oldLayer: Layer,
newConfig: Partial<LayerBaseConfig>
): Merge<LayerConfigChangeUpdaterAction, {type: typeof ActionTypes.LAYER_CONFIG_CHANGE}> {
return {
type: ActionTypes.LAYER_CONFIG_CHANGE,
oldLayer,
newConfig
};
}
export type LayerTextLabelChangeUpdaterAction = {
oldLayer: Layer;
idx: number | 'all';
prop: string;
value: any;
};
/**
* Update layer text label
* @param oldLayer - layer to be updated
* @param idx -`idx` of text label to be updated
* @param prop - `prop` of text label, e,g, `anchor`, `alignment`, `color`, `size`, `field`, `outlineWidth`, `outlineColor`
* @param value - new value
* @returns action
* @public
*/
export function layerTextLabelChange(
oldLayer: Layer,
idx: number | 'all',
prop: string,
value: any
): Merge<LayerTextLabelChangeUpdaterAction, {type: typeof ActionTypes.LAYER_TEXT_LABEL_CHANGE}> {
return {
type: ActionTypes.LAYER_TEXT_LABEL_CHANGE,
oldLayer,
idx,
prop,
value
};
}
export type LayerSetIsValidUpdaterAction = {
oldLayer: Layer;
isValid: boolean;
};
/**
* Changes value of isValid flag for a layer.
* The action also updates visibility of the layer based on isValid.
* @param oldLayer - layer to be updated
* @param isValid - new value for isValid flag
* @returns action
* @public
*/
export function layerSetIsValid(
oldLayer: Layer,
isValid: boolean
): Merge<LayerSetIsValidUpdaterAction, {type: typeof ActionTypes.LAYER_SET_IS_VALID}> {
return {
type: ActionTypes.LAYER_SET_IS_VALID,
oldLayer,
isValid
};
}
export type LayerTypeChangeUpdaterAction = {
oldLayer: Layer;
newType: string;
};
/**
* Update layer type. Previews layer config will be copied if applicable.
* @param oldLayer - layer to be updated
* @param newType - new type
* @returns action
* @public
*/
export function layerTypeChange(
oldLayer: Layer,
newType: string
): Merge<LayerTypeChangeUpdaterAction, {type: typeof ActionTypes.LAYER_TYPE_CHANGE}> {
return {
type: ActionTypes.LAYER_TYPE_CHANGE,
oldLayer,
newType
};
}
export type LayerVisualChannelConfigChangeUpdaterAction = {
oldLayer: Layer;
newConfig: Partial<LayerBaseConfig>;
channel: string;
};
/**
* Update layer visual channel
* @memberof visStateActions
* @param oldLayer - layer to be updated
* @param newConfig - new visual channel config
* @param channel - channel to be updated
* @returns action
* @public
*/
export function layerVisualChannelConfigChange(
oldLayer: Layer,
newConfig: Partial<LayerBaseConfig>,
channel: string
): Merge<
LayerVisualChannelConfigChangeUpdaterAction,
{type: typeof ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE}
> {
return {
type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE,
oldLayer,
newConfig,
channel
};
}
export type LayerVisConfigChangeUpdaterAction = {
oldLayer: Layer;
newVisConfig: Partial<LayerVisConfig>;
};
/**
* Update layer `visConfig`
* @memberof visStateActions
* @param oldLayer - layer to be updated
* @param newVisConfig - new visConfig as a key value map: e.g. `{opacity: 0.8}`
* @returns action
* @public
*/
export function layerVisConfigChange(
oldLayer: Layer,
newVisConfig: Partial<LayerVisConfig>
): Merge<LayerVisConfigChangeUpdaterAction, {type: typeof ActionTypes.LAYER_VIS_CONFIG_CHANGE}> {
return {
type: ActionTypes.LAYER_VIS_CONFIG_CHANGE,
oldLayer,
newVisConfig
};
}
export type LayerColorUIChangeUpdaterAction = {
oldLayer: Layer;
prop: string;
newConfig: NestedPartial<ColorUI>;
};
/**
* Set the color palette ui for layer color
* @memberof visStateActions
* @param oldLayer - layer to be updated
* @param prop - which color prop
* @param newConfig - to be merged
* @returns action
* @public
*/
export function layerColorUIChange(
oldLayer: Layer,
prop: string,
newConfig: NestedPartial<ColorUI>
): Merge<LayerColorUIChangeUpdaterAction, {type: typeof ActionTypes.LAYER_COLOR_UI_CHANGE}> {
return {
type: ActionTypes.LAYER_COLOR_UI_CHANGE,
oldLayer,
prop,
newConfig
};
}
export type UpdateLayerBlendingUpdaterAction = {
mode: 'additive' | 'normal' | 'subtractive';
};
/**
* Update layer blending mode
* @memberof visStateActions
* @param mode one of `additive`, `normal` and `subtractive`
* @returns action
* @public
*/
export function updateLayerBlending(
mode: 'additive' | 'normal' | 'subtractive'
): Merge<UpdateLayerBlendingUpdaterAction, {type: typeof ActionTypes.UPDATE_LAYER_BLENDING}> {
return {
type: ActionTypes.UPDATE_LAYER_BLENDING,
mode
};
}
export type UpdateOverlayBlendingUpdaterAction = {
mode: 'screen' | 'normal' | 'darken';
};
/**
* Update overlay blending mode
* @memberof visStateActions
* @param mode one of `screen`, `normal` and `darken`
* @returns action
* @public
*/
export function updateOverlayBlending(
mode: 'screen' | 'normal' | 'darken'
): Merge<UpdateOverlayBlendingUpdaterAction, {type: typeof ActionTypes.UPDATE_OVERLAY_BLENDING}> {
return {
type: ActionTypes.UPDATE_OVERLAY_BLENDING,
mode
};
}
export type InteractionConfigChangeUpdaterAction = {
config: ValueOf<InteractionConfig>;
};
/**
* Update `interactionConfig`
* @memberof visStateActions
* @param config - new config as key value map: `{tooltip: {enabled: true}}`
* @returns action
* @public
*/
export function interactionConfigChange(
config: ValueOf<InteractionConfig>
): Merge<
InteractionConfigChangeUpdaterAction,
{type: typeof ActionTypes.INTERACTION_CONFIG_CHANGE}
> {
return {
type: ActionTypes.INTERACTION_CONFIG_CHANGE,
config
};
}
export type SetFilterUpdaterAction = {
idx: number;
prop: string;
value: any;
valueIndex?: number;
};
/**
* Update filter property
* @memberof visStateActions
* @param idx -`idx` of filter to be updated
* @param prop - `prop` of filter, e,g, `dataId`, `name`, `value`
* @param value - new value
* @param valueIndex - dataId index
* @returns action
* @public
*/
export function setFilter(
idx: number,
prop: string,
value: any,
valueIndex?: number
): Merge<SetFilterUpdaterAction, {type: typeof ActionTypes.SET_FILTER}> {
return {
type: ActionTypes.SET_FILTER,
idx,
prop,
value,
valueIndex
};
}
export type SetFilterAnimationTimeUpdaterAction = {
idx: number;
prop: string;
value: any;
valueIndex?: number;
};
/**
* Same as Update filter
* @memberof visStateActions
* @param idx -`idx` of filter to be updated
* @param prop - `prop` of filter, e,g, `dataId`, `name`, `value`
* @param value - new value
* @param valueIndex - dataId index
* @returns action
* @public
*/
export function setFilterAnimationTime(
idx: number,
prop: string,
value: any,
valueIndex?: number
): Merge<
SetFilterAnimationTimeUpdaterAction,
{type: typeof ActionTypes.SET_FILTER_ANIMATION_TIME}
> {
return {
type: ActionTypes.SET_FILTER_ANIMATION_TIME,
idx,
prop,
value,
valueIndex
};
}
export type SetFilterAnimationWindowUpdaterAction = {
id: string;
animationWindow: string;
};
/**
* Same as Update filter
* @memberof visStateActions
* @public
*/
export function setFilterAnimationWindow({
id,
animationWindow
}: SetFilterAnimationWindowUpdaterAction): Merge<
SetFilterAnimationWindowUpdaterAction,
{type: typeof ActionTypes.SET_FILTER_ANIMATION_WINDOW}
> {
return {
type: ActionTypes.SET_FILTER_ANIMATION_WINDOW,
id,
animationWindow
};
}
export type AddFilterUpdaterAction = {
dataId?: string | string[] | null;
id?: string;
};
/**
* Add a new filter
* @memberof visStateActions
* @param dataId - dataset `id` this new filter is associated with
* @param id - `id` for the new filter
* @returns action
* @public
*/
export function addFilter(
dataId: string | null,
id?: string
): Merge<AddFilterUpdaterAction, {type: typeof ActionTypes.ADD_FILTER}> {
return {
type: ActionTypes.ADD_FILTER,
dataId,
id
};
}
export type AddLayerUpdaterAction = {
config?: object;
datasetId?: string;
};
/**
* Add a new layer
* @memberof visStateActions
* @param config - new layer config
* @param datasetId - dataset id used for creating an empty layer
* @returns action
* @public
*/
export function addLayer(
config?: object,
datasetId?: string
): Merge<AddLayerUpdaterAction, {type: typeof ActionTypes.ADD_LAYER}> {
return {
type: ActionTypes.ADD_LAYER,
config,
datasetId
};
}
export type ReorderLayerUpdaterAction = {
order: string[];
};
/**
* Reorder layer, order is an array of layer indexes, index 0 will be the one at the bottom
* @memberof visStateActions
* @param order an array of layer indexes
* @returns action
* @public
* @example
*
* bring `layers[1]` below `layers[0]`, the sequence layers will be rendered is `layers[1].id`, `layers[0].id`, `layers[2].id`, `layers[3].id`.
* `layers[1]` will be at the bottom, `layers[13]` will be at the top.
* this.props.dispatch(reorderLayer([`layers[1].id`, `layers[0].id`, `layers[2].id`, `layers[3].id`]));
*/
export function reorderLayer(
order: string[]
): Merge<ReorderLayerUpdaterAction, {type: typeof ActionTypes.REORDER_LAYER}> {
return {
type: ActionTypes.REORDER_LAYER,
order
};
}
export type RemoveFilterUpdaterAction = {
idx: number;
};
/**
* Remove a filter from `visState.filters`, once a filter is removed, data will be re-filtered and layer will be updated
* @memberof visStateActions
* @param idx idx of filter to be removed
* @returns action
* @public
*/
export function removeFilter(
idx: number
): Merge<RemoveFilterUpdaterAction, {type: typeof ActionTypes.REMOVE_FILTER}> {
return {
type: ActionTypes.REMOVE_FILTER,
idx
};
}
export type RemoveLayerUpdaterAction = {
id: string;
};
/**
* Remove a layer
* @memberof visStateActions
* @param id idx of layer to be removed
* @returns action
* @public
*/
export function removeLayer(
id: string
): Merge<RemoveLayerUpdaterAction, {type: typeof ActionTypes.REMOVE_LAYER}> {
return {
type: ActionTypes.REMOVE_LAYER,
id
};
}
export type DuplicateLayerUpdaterAction = {
id: string;
};
/**
* Duplicate a layer
* @memberof visStateActions
* @param id id of layer to be duplicated
* @returns action
* @public
*/
export function duplicateLayer(
id: string
): Merge<DuplicateLayerUpdaterAction, {type: typeof ActionTypes.DUPLICATE_LAYER}> {
return {
type: ActionTypes.DUPLICATE_LAYER,
id
};
}
export type AddEffectUpdaterAction = {
config: EffectPropsPartial;
};
/**
* Add a new effect
* @memberof visStateActions
* @param config - new effect config
* @returns action
* @public
*/
export function addEffect(
config: EffectPropsPartial
): Merge<AddEffectUpdaterAction, {type: typeof ActionTypes.ADD_EFFECT}> {
return {
type: ActionTypes.ADD_EFFECT,
config
};
}
export type ReorderEffectUpdaterAction = {
order: string[];
};
/**
* Reorder effects
* @memberof visStateActions
* @param order an array of effect ids
* @returns action
* @public
*/
export function reorderEffect(
order: string[]
): Merge<ReorderEffectUpdaterAction, {type: typeof ActionTypes.REORDER_EFFECT}> {
return {
type: ActionTypes.REORDER_EFFECT,
order
};
}
export type RemoveEffectUpdaterAction = {
id: string;
};
/**
* Remove an effect
* @memberof visStateActions
* @param id idx of the effect to be removed
* @returns action
* @public
*/
export function removeEffect(
id: string
): Merge<RemoveEffectUpdaterAction, {type: typeof ActionTypes.REMOVE_EFFECT}> {
return {
type: ActionTypes.REMOVE_EFFECT,
id
};
}
export type UpdateEffectUpdaterAction = {
id: string;
props: EffectPropsPartial;
};
/**
* Update an effect
* @memberof visStateActions
* @param props idx of the effect to be updated with specified props
* @returns action
* @public
*/
export function updateEffect(
id: string,
props: EffectPropsPartial
): Merge<UpdateEffectUpdaterAction, {type: typeof ActionTypes.UPDATE_EFFECT}> {
return {
type: ActionTypes.UPDATE_EFFECT,
id,
props
};
}
export type RemoveDatasetUpdaterAction = {
dataId: string;
};
/**
* Remove a dataset and all layers, filters, tooltip configs that based on it
* @memberof visStateActions
* @param dataId dataset id
* @returns action
* @public
*/
export function removeDataset(
dataId: string
): Merge<RemoveDatasetUpdaterAction, {type: typeof ActionTypes.REMOVE_DATASET}> {
return {
type: ActionTypes.REMOVE_DATASET,
dataId
};
}
export type ShowDatasetTableUpdaterAction = {
dataId: string;
};
/**
* Display dataset table in a modal
* @memberof visStateActions
* @param dataId dataset id to show in table
* @returns action
* @public
*/
export function showDatasetTable(
dataId: string
): Merge<ShowDatasetTableUpdaterAction, {type: typeof ActionTypes.SHOW_DATASET_TABLE}> {
return {
type: ActionTypes.SHOW_DATASET_TABLE,
dataId
};
}
export type UpdateDatasetColorUpdater = {
dataId: string;
newColor: RGBColor;
};
/**
* Update dataset color to custom by means of color picker
* @memberof visStateActions
* @param dataId dataset `id` this custom color is associated with
* @param newColor custom color in RGBformat
* @returns action
* @public
*/
export function updateTableColor(
dataId: string,
newColor: RGBColor
): Merge<UpdateDatasetColorUpdater, {type: typeof ActionTypes.UPDATE_TABLE_COLOR}> {
return {
type: ActionTypes.UPDATE_TABLE_COLOR,
dataId,
newColor
};
}
export type SortTableColumnUpdaterAction = {
dataId: string;
column: string;
mode?: string;
};
/**
* Sort dataset column, for table display
* @memberof visStateActions
* @param dataId
* @param column
* @param mode
* @returns action
* @public
*/
export function sortTableColumn(
dataId: string,
column: string,
mode?: string
): Merge<SortTableColumnUpdaterAction, {type: typeof ActionTypes.SORT_TABLE_COLUMN}> {
return {
type: ActionTypes.SORT_TABLE_COLUMN,
dataId,
column,
mode
};
}
export type PinTableColumnUpdaterAction = {
dataId: string;
column: string;
};
/**
* Pin dataset column, for table display
* @param dataId
* @param column
* @returns action
* @public
*/
export function pinTableColumn(
dataId: string,
column: string
): Merge<PinTableColumnUpdaterAction, {type: typeof ActionTypes.PIN_TABLE_COLUMN}> {
return {
type: ActionTypes.PIN_TABLE_COLUMN,
dataId,
column
};
}
export type CopyTableColumnUpdaterAction = {
dataId: string;
column: string;
};
/**
* Copy column, for table display
* @param dataId
* @param column
* @returns action
* @public
*/
export function copyTableColumn(
dataId: string,
column: string
): Merge<CopyTableColumnUpdaterAction, {type: typeof ActionTypes.COPY_TABLE_COLUMN}> {
return {
type: ActionTypes.COPY_TABLE_COLUMN,
dataId,
column
};
}
export type SetColumnDisplayFormatUpdaterAction = {
dataId: string;
formats: {
[key: string]: string;
};
};
/**
* Set column display format
* @param dataId
* @param formats
* @returns action
* @public
*/
export function setColumnDisplayFormat(
dataId: string,
formats: {
[key: string]: string;
}
): Merge<
SetColumnDisplayFormatUpdaterAction,
{type: typeof ActionTypes.SET_COLUMN_DISPLAY_FORMAT}
> {
return {
type: ActionTypes.SET_COLUMN_DISPLAY_FORMAT,
dataId,
formats
};
}
export type AddDataToMapUpdaterOptions = {
centrMap?: boolean;
readOnly?: boolean;
keepExistingConfig?: boolean;
};
export type UpdateVisDataUpdaterAction = {
datasets: AddDataToMapPayload['datasets'];
options: AddDataToMapPayload['options'];
config?: ParsedConfig;
};
// * @param dataset.info -info of a dataset
// * @param dataset.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
// * @param dataset.info.label - A display name of this dataset
// * @param dataset.data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
// * @param dataset.data.fields - ***required** Array of fields,
// * @param dataset.data.fields.name - ***required** Name of the field,
// * @param dataset.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
/**
* Add new dataset to `visState`, with option to load a map config along with the datasets
* @memberof visStateActions
* @param datasets - ***required** datasets can be a dataset or an array of datasets
* Each dataset object needs to have `info` and `data` property.
* @param {object} options
* @param options.centerMap `default: true` if `centerMap` is set to `true` kepler.gl will
* place the map view within the data points boundaries
* @param options.readOnly `default: false` if `readOnly` is set to `true`
* the left setting panel will be hidden
* @param config this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
* @returns action
* @public
*/
export function updateVisData(
datasets: AddDataToMapPayload['datasets'],
options: AddDataToMapPayload['options'],
config?: ParsedConfig
): Merge<UpdateVisDataUpdaterAction, {type: typeof ActionTypes.UPDATE_VIS_DATA}> {
return {
type: ActionTypes.UPDATE_VIS_DATA,
datasets,
options,
config
};
}
export type RenameDatasetUpdaterAction = {
dataId: string;
label: string;
};
/**
* Rename an existing dataset in `visState`
* @memberof visStateActions
* @param dataId - ***required** Id of the dataset to update
* @param label - ***required** New name for the dataset
* @returns action
* @public
*/
export function renameDataset(
dataId: string,
label: string
): Merge<RenameDatasetUpdaterAction, {type: typeof ActionTypes.RENAME_DATASET}> {
return {
type: ActionTypes.RENAME_DATASET,
dataId,
label
};
}
export type UpdateDatasetPropsUpdaterAction = {
dataId: string;
props: {
label?: string;
color?: RGBColor;
metadata?: Record<string, unknown>;
};
};
/**
* Update an existing dataset props in `visState`
* @param dataId - ***required** Id of the dataset to update
* @param props - ***required** New props to update
* @returns action
*/
export function updateDatasetProps(
dataId: string,
props: {
label?: string;
color?: RGBColor;
metadata?: Record<string, unknown>;
}
): Merge<UpdateDatasetPropsUpdaterAction, {type: typeof ActionTypes.UPDATE_DATASET_PROPS}> {
return {
type: ActionTypes.UPDATE_DATASET_PROPS,
dataId,
props
};
}
export type ToggleFilterAnimationUpdaterAction = {
idx: number;
};
/**
* Start and end filter animation
* @memberof visStateActions
* @param {Number} idx of filter
* @returns action
* @public
*/
export function toggleFilterAnimation(
idx: number
): Merge<ToggleFilterAnimationUpdaterAction, {type: typeof ActionTypes.TOGGLE_FILTER_ANIMATION}> {
return {
type: ActionTypes.TOGGLE_FILTER_ANIMATION,
idx
};
}
export type UpdateFilterAnimationSpeedUpdaterAction = {
idx: number;
speed: number;
};
/**
* Change filter animation speed
* @memberof visStateActions
* @param idx - `idx` of filter
* @param speed - `speed` to change it to. `speed` is a multiplier
* @returns action
* @public
*/
export function updateFilterAnimationSpeed(
idx: number,
speed: number
): Merge<
UpdateFilterAnimationSpeedUpdaterAction,
{type: typeof ActionTypes.UPDATE_FILTER_ANIMATION_SPEED}
> {
return {
type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED,
idx,
speed
};
}
export type SetLayerAnimationTimeUpdaterAction = {
value: number;
};
/**
* Reset animation
* @memberof visStateActions
* @param value - Current value of the slider
* @returns action
* @public
*/
export function setLayerAnimationTime(
value: number
): Merge<SetLayerAnimationTimeUpdaterAction, {type: typeof ActionTypes.SET_LAYER_ANIMATION_TIME}> {
return {
type: ActionTypes.SET_LAYER_ANIMATION_TIME,
value
};
}
export type UpdateLayerAnimationSpeedUpdaterAction = {
speed: number;
};
/**
* update trip layer animation speed
* @memberof visStateActions
* @param speed - `speed` to change it to. `speed` is a multiplier
* @returns action
* @public
*/
export function updateLayerAnimationSpeed(
speed: number
): Merge<
UpdateLayerAnimationSpeedUpdaterAction,
{type: typeof ActionTypes.UPDATE_LAYER_ANIMATION_SPEED}
> {
return {
type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED,
speed
};
}
export type ToggleLayerAnimationUpdaterAction = {};
/**
* start end end layer animation
* @memberof visStateActions
* @returns action
* @public
*/
export function toggleLayerAnimation(): Merge<
ToggleLayerAnimationUpdaterAction,
{type: typeof ActionTypes.TOGGLE_LAYER_ANIMATION}
> {
return {
type: ActionTypes.TOGGLE_LAYER_ANIMATION
};
}
export type ToggleLayerAnimationControlUpdaterAction = {};
/**
* hide and show layer animation control
* @memberof visStateActions
* @returns action
* @public
*/
export function toggleLayerAnimationControl(): Merge<
ToggleLayerAnimationControlUpdaterAction,
{type: typeof ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL}
> {
return {
type: ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL
};
}
export type SetFilterViewUpdaterAction = {
idx: number;
view: Filter['view'];
};
/**
* Show larger time filter at bottom for time playback (apply to time filter only)
* @memberof visStateActions
* @param idx - index of filter to enlarge
* @param view - type of filter view
* @returns action
* @public
*/
export function setFilterView(
idx: number,
view: Filter['view']
): Merge<SetFilterViewUpdaterAction, {type: typeof ActionTypes.SET_FILTER_VIEW}> {
return {
type: ActionTypes.SET_FILTER_VIEW,
idx,
view
};
}
export type ToggleFilterFeatureUpdaterAction = {
idx: number;
};
/**
* Show/hide filter feature on map
* @memberof visStateActions
* @param idx - index of filter feature to show/hide
* @return action
*/
export function toggleFilterFeature(
idx: number