@thoughtspot/ts-chart-sdk 0.0.2-alpha.8 → 1.0.0

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.
Files changed (144) hide show
  1. package/README.md +126 -50
  2. package/dist/ts-chart-sdk.d.ts +337 -31
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +3 -0
  6. package/lib/index.js.map +1 -1
  7. package/lib/main/custom-chart-context.d.ts +15 -3
  8. package/lib/main/custom-chart-context.d.ts.map +1 -1
  9. package/lib/main/custom-chart-context.js +45 -16
  10. package/lib/main/custom-chart-context.js.map +1 -1
  11. package/lib/main/custom-chart-context.spec.js +302 -4
  12. package/lib/main/custom-chart-context.spec.js.map +1 -1
  13. package/lib/main/logger.d.ts +13 -0
  14. package/lib/main/logger.d.ts.map +1 -0
  15. package/lib/main/logger.js +64 -0
  16. package/lib/main/logger.js.map +1 -0
  17. package/lib/main/logger.spec.d.ts +2 -0
  18. package/lib/main/logger.spec.d.ts.map +1 -0
  19. package/lib/main/logger.spec.js +88 -0
  20. package/lib/main/logger.spec.js.map +1 -0
  21. package/lib/main/util.d.ts +2 -0
  22. package/lib/main/util.d.ts.map +1 -1
  23. package/lib/main/util.js +11 -0
  24. package/lib/main/util.js.map +1 -1
  25. package/lib/main/util.spec.d.ts +2 -0
  26. package/lib/main/util.spec.d.ts.map +1 -0
  27. package/lib/main/util.spec.js +73 -0
  28. package/lib/main/util.spec.js.map +1 -0
  29. package/lib/react/use-custom-chart-context.d.ts.map +1 -1
  30. package/lib/react/use-custom-chart-context.js +3 -1
  31. package/lib/react/use-custom-chart-context.js.map +1 -1
  32. package/lib/react/use-custom-chart-context.spec.js +0 -1
  33. package/lib/react/use-custom-chart-context.spec.js.map +1 -1
  34. package/lib/react/use-custom-chart-context.util.d.ts.map +1 -1
  35. package/lib/react/use-custom-chart-context.util.js +5 -3
  36. package/lib/react/use-custom-chart-context.util.js.map +1 -1
  37. package/lib/types/answer-column.types.d.ts +15 -5
  38. package/lib/types/answer-column.types.d.ts.map +1 -1
  39. package/lib/types/answer-column.types.js +10 -3
  40. package/lib/types/answer-column.types.js.map +1 -1
  41. package/lib/types/chart-to-ts-event.types.d.ts +2 -0
  42. package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
  43. package/lib/types/chart-to-ts-event.types.js +1 -0
  44. package/lib/types/chart-to-ts-event.types.js.map +1 -1
  45. package/lib/types/common.types.d.ts +65 -5
  46. package/lib/types/common.types.d.ts.map +1 -1
  47. package/lib/types/common.types.js.map +1 -1
  48. package/lib/types/conditional-formatting.types.d.ts +1 -16
  49. package/lib/types/conditional-formatting.types.d.ts.map +1 -1
  50. package/lib/types/conditional-formatting.types.js.map +1 -1
  51. package/lib/types/configurator.types.d.ts +3 -1
  52. package/lib/types/configurator.types.d.ts.map +1 -1
  53. package/lib/types/number-formatting.types.d.ts +55 -0
  54. package/lib/types/number-formatting.types.d.ts.map +1 -0
  55. package/lib/types/number-formatting.types.js +23 -0
  56. package/lib/types/number-formatting.types.js.map +1 -0
  57. package/lib/types/ts-to-chart-event.types.d.ts +19 -6
  58. package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
  59. package/lib/types/ts-to-chart-event.types.js +1 -0
  60. package/lib/types/ts-to-chart-event.types.js.map +1 -1
  61. package/lib/types/visual-prop.types.d.ts +71 -3
  62. package/lib/types/visual-prop.types.d.ts.map +1 -1
  63. package/lib/types/visual-prop.types.js +32 -1
  64. package/lib/types/visual-prop.types.js.map +1 -1
  65. package/lib/utils/conditional-formatting/conditional-formatting.spec.js +2 -1
  66. package/lib/utils/conditional-formatting/conditional-formatting.spec.js.map +1 -1
  67. package/lib/utils/date-formatting.d.ts +85 -1
  68. package/lib/utils/date-formatting.d.ts.map +1 -1
  69. package/lib/utils/date-formatting.js +344 -9
  70. package/lib/utils/date-formatting.js.map +1 -1
  71. package/lib/utils/date-formatting.spec.js +303 -32
  72. package/lib/utils/date-formatting.spec.js.map +1 -1
  73. package/lib/utils/date-utils.d.ts +6 -0
  74. package/lib/utils/date-utils.d.ts.map +1 -0
  75. package/lib/utils/date-utils.js +20 -0
  76. package/lib/utils/date-utils.js.map +1 -0
  77. package/lib/utils/date-utils.spec.d.ts +2 -0
  78. package/lib/utils/date-utils.spec.d.ts.map +1 -0
  79. package/lib/utils/date-utils.spec.js +63 -0
  80. package/lib/utils/date-utils.spec.js.map +1 -0
  81. package/lib/utils/formatting-util.d.ts +10 -0
  82. package/lib/utils/formatting-util.d.ts.map +1 -0
  83. package/lib/utils/formatting-util.js +78 -0
  84. package/lib/utils/formatting-util.js.map +1 -0
  85. package/lib/utils/formatting-util.spec.d.ts +2 -0
  86. package/lib/utils/formatting-util.spec.d.ts.map +1 -0
  87. package/lib/utils/formatting-util.spec.js +247 -0
  88. package/lib/utils/formatting-util.spec.js.map +1 -0
  89. package/lib/utils/globalize-Initializer/globalize-utils.d.ts +16 -0
  90. package/lib/utils/globalize-Initializer/globalize-utils.d.ts.map +1 -0
  91. package/lib/utils/globalize-Initializer/globalize-utils.js +101 -0
  92. package/lib/utils/globalize-Initializer/globalize-utils.js.map +1 -0
  93. package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts +2 -0
  94. package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts.map +1 -0
  95. package/lib/utils/globalize-Initializer/globalize-utils.spec.js +149 -0
  96. package/lib/utils/globalize-Initializer/globalize-utils.spec.js.map +1 -0
  97. package/lib/utils/number-formatting/number-formatting-utils.d.ts +20 -0
  98. package/lib/utils/number-formatting/number-formatting-utils.d.ts.map +1 -0
  99. package/lib/utils/number-formatting/number-formatting-utils.js +159 -0
  100. package/lib/utils/number-formatting/number-formatting-utils.js.map +1 -0
  101. package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts +2 -0
  102. package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts.map +1 -0
  103. package/lib/utils/number-formatting/number-formatting-utils.spec.js +221 -0
  104. package/lib/utils/number-formatting/number-formatting-utils.spec.js.map +1 -0
  105. package/lib/utils/number-formatting/number-formatting.d.ts +5 -0
  106. package/lib/utils/number-formatting/number-formatting.d.ts.map +1 -0
  107. package/lib/utils/number-formatting/number-formatting.js +128 -0
  108. package/lib/utils/number-formatting/number-formatting.js.map +1 -0
  109. package/lib/utils/number-formatting/number-formatting.spec.d.ts +2 -0
  110. package/lib/utils/number-formatting/number-formatting.spec.d.ts.map +1 -0
  111. package/lib/utils/number-formatting/number-formatting.spec.js +159 -0
  112. package/lib/utils/number-formatting/number-formatting.spec.js.map +1 -0
  113. package/package.json +5 -2
  114. package/src/index.ts +3 -0
  115. package/src/main/custom-chart-context.spec.ts +356 -6
  116. package/src/main/custom-chart-context.ts +182 -15
  117. package/src/main/logger.spec.ts +114 -0
  118. package/src/main/logger.ts +97 -0
  119. package/src/main/util.spec.ts +94 -0
  120. package/src/main/util.ts +20 -0
  121. package/src/react/use-custom-chart-context.spec.tsx +0 -1
  122. package/src/react/use-custom-chart-context.tsx +4 -1
  123. package/src/react/use-custom-chart-context.util.ts +6 -3
  124. package/src/types/answer-column.types.ts +29 -6
  125. package/src/types/chart-to-ts-event.types.ts +7 -0
  126. package/src/types/common.types.ts +103 -8
  127. package/src/types/conditional-formatting.types.ts +2 -17
  128. package/src/types/configurator.types.ts +15 -1
  129. package/src/types/number-formatting.types.ts +80 -0
  130. package/src/types/ts-to-chart-event.types.ts +54 -5
  131. package/src/types/visual-prop.types.ts +197 -3
  132. package/src/utils/conditional-formatting/conditional-formatting.spec.ts +2 -0
  133. package/src/utils/date-formatting.spec.ts +377 -32
  134. package/src/utils/date-formatting.ts +587 -14
  135. package/src/utils/date-utils.spec.ts +93 -0
  136. package/src/utils/date-utils.ts +69 -0
  137. package/src/utils/formatting-util.spec.ts +312 -0
  138. package/src/utils/formatting-util.ts +234 -0
  139. package/src/utils/globalize-Initializer/globalize-utils.spec.ts +192 -0
  140. package/src/utils/globalize-Initializer/globalize-utils.ts +216 -0
  141. package/src/utils/number-formatting/number-formatting-utils.spec.ts +296 -0
  142. package/src/utils/number-formatting/number-formatting-utils.ts +260 -0
  143. package/src/utils/number-formatting/number-formatting.spec.ts +243 -0
  144. package/src/utils/number-formatting/number-formatting.ts +264 -0
@@ -8,8 +8,46 @@
8
8
  * Copyright: ThoughtSpot Inc. 2023
9
9
  */
10
10
 
11
- import { CustomChartContext } from '../main/custom-chart-context';
11
+ import type { CustomChartContext } from '../main/custom-chart-context';
12
+ import { ColumnType } from './answer-column.types';
12
13
  import { ChartModel } from './common.types';
14
+
15
+ export type TSTooltipConfig = {
16
+ columnIds: Array<string>;
17
+ };
18
+
19
+ export enum VisualPropComponentTranslationKeys {
20
+ SHOW_ALL_LABELS = 'SHOW_ALL_LABELS',
21
+ TOO_MANY_LABELS = 'TOO_MANY_LABELS',
22
+ MAP_TILE_LABEL = 'MAP_TILE_LABEL',
23
+ ENABLE_MARKERS = 'ENABLE_MARKERS',
24
+ SHOW_REGRESSION_LINE = 'SHOW_REGRESSION_LINE',
25
+ X_AXIS_GRID_LINE = 'X_AXIS_GRID_LINE',
26
+ Y_AXIS_GRID_LINE = 'Y_AXIS_GRID_LINE',
27
+ MAX_DATA_POINTS = 'MAX_DATA_POINTS',
28
+ HIGH_CARDINALITY_BATCH_SIZE_DISABLED = 'highCardinalityBatchSizeDisabled',
29
+ HIGH_CARDINALITY_BATCH_SIZE_LIMIT = 'highCardinalityBatchSizeLimit',
30
+ CHART_CUSTOMIZE = 'CHART_CUSTOMIZE',
31
+ SELECT_AN_AREA = 'chartConfigurator.SELECT_AN_AREA',
32
+ RESET_ZOOM = 'chartConfigurator.RESET_ZOOM',
33
+ EDIT_TOOLTIP = 'EDIT_TOOLTIP',
34
+ DONT_SHOW = 'DONT_SHOW',
35
+ SHOW_GAP = 'SHOW_GAP',
36
+ SHOW_AS_ZERO = 'SHOW_AS_ZERO',
37
+ HANDLE_MISSING_VALUES = 'HANDLE_MISSING_VALUES',
38
+ SHOW_NULL_AS_ZERO = 'SHOW_NULL_AS_ZERO',
39
+ EXCLUDE_NULL_VALUES = 'EXCLUDE_NULL_VALUES',
40
+ COLUMN_CUSTOMIZE = 'COLUMN_CUSTOMIZE',
41
+ SHOW_TOTAL_LABELS = 'SHOW_TOTAL_LABELS',
42
+ SHOW_DETAILED_LABELS = 'SHOW_DETAILED_LABELS',
43
+ SHOW_DATA_LABELS = 'SHOW_DATA_LABELS',
44
+ SHOW_AXIS_AS_PERCENT = 'SHOW_AXIS_AS_PERCENT',
45
+ RIGHT_LEGEND = 'RIGHT_LEGEND',
46
+ LEFT_LEGEND = 'LEFT_LEGEND',
47
+ TOP_LEGEND = 'TOP_LEGEND',
48
+ BOTTOM_LEGEND = 'BOTTOM_LEGEND',
49
+ }
50
+
13
51
  /**
14
52
  * Configuration for input validation rules
15
53
  */
@@ -115,6 +153,18 @@ export interface TextInputFormDetail {
115
153
  * @version SDK: 0.0.1-alpha.3 | ThoughtSpot:
116
154
  */
117
155
  inputValidation?: InputValidation;
156
+ /**
157
+ * Determines whether it should be disabled or not
158
+ *
159
+ * @version SDK: 0.0.2-alpha.13 | ThoughtSpot:
160
+ */
161
+ disabled?: boolean;
162
+ /**
163
+ * Translation key for the label
164
+ *
165
+ * @version SDK: 0.2 | ThoughtSpot:
166
+ */
167
+ labelTranslation?: VisualPropComponentTranslationKeys;
118
168
  }
119
169
 
120
170
  /**
@@ -148,6 +198,18 @@ export interface NumberInputFormDetail {
148
198
  * @version SDK: 0.0.1-alpha.7 | ThoughtSpot:
149
199
  */
150
200
  inputValidation?: InputValidation;
201
+ /**
202
+ * Determines whether it should be disabled or not
203
+ *
204
+ * @version SDK: 0.0.2-alpha.13 | ThoughtSpot:
205
+ */
206
+ disabled?: boolean;
207
+ /**
208
+ * Translation key for the label
209
+ *
210
+ * @version SDK: 0.2 | ThoughtSpot:
211
+ */
212
+ labelTranslation?: VisualPropComponentTranslationKeys;
151
213
  }
152
214
 
153
215
  /**
@@ -182,6 +244,12 @@ export interface ColorPickerFormDetail {
182
244
  * @version SDK: 0.0.1-alpha.7 | ThoughtSpot:
183
245
  */
184
246
  defaultValue?: string;
247
+ /**
248
+ * Translation key for the label
249
+ *
250
+ * @version SDK: 0.2 | ThoughtSpot:
251
+ */
252
+ labelTranslation?: VisualPropComponentTranslationKeys;
185
253
  }
186
254
 
187
255
  /**
@@ -209,6 +277,18 @@ export interface ToggleFormDetail {
209
277
  * @version SDK: 0.1 | ThoughtSpot:
210
278
  */
211
279
  defaultValue?: boolean;
280
+ /**
281
+ * Determines whether it should be disabled or not
282
+ *
283
+ * @version SDK: 0.0.2-alpha.13 | ThoughtSpot:
284
+ */
285
+ disabled?: boolean;
286
+ /**
287
+ * Translation key for the label
288
+ *
289
+ * @version SDK: 0.2 | ThoughtSpot:
290
+ */
291
+ labelTranslation?: VisualPropComponentTranslationKeys;
212
292
  }
213
293
 
214
294
  /**
@@ -236,6 +316,18 @@ export interface CheckboxFormDetail {
236
316
  * @version SDK: 0.1 | ThoughtSpot:
237
317
  */
238
318
  defaultValue?: boolean;
319
+ /**
320
+ * Determines whether it should be disabled or not
321
+ *
322
+ * @version SDK: 0.0.2-alpha.13 | ThoughtSpot:
323
+ */
324
+ disabled?: boolean;
325
+ /**
326
+ * Translation key for the label
327
+ *
328
+ * @version SDK: 0.2 | ThoughtSpot:
329
+ */
330
+ labelTranslation?: VisualPropComponentTranslationKeys;
239
331
  }
240
332
 
241
333
  /**
@@ -269,6 +361,18 @@ export interface RadioButtonFormDetail {
269
361
  * @version SDK: 0.1 | ThoughtSpot:
270
362
  */
271
363
  values: string[];
364
+ /**
365
+ * Determines whether it should be disabled or not
366
+ *
367
+ * @version SDK: 0.0.2-3 | ThoughtSpot:
368
+ */
369
+ disabled?: boolean;
370
+ /**
371
+ * Translation key for the label
372
+ *
373
+ * @version SDK: 0.2 | ThoughtSpot:
374
+ */
375
+ labelTranslation?: VisualPropComponentTranslationKeys;
272
376
  }
273
377
 
274
378
  /**
@@ -302,6 +406,18 @@ export interface DropDownFormDetail {
302
406
  * @version SDK: 0.1 | ThoughtSpot:
303
407
  */
304
408
  values: string[];
409
+ /**
410
+ * Determines whether it should be disabled or not
411
+ *
412
+ * @version SDK: 0.0.2-alpha.13 | ThoughtSpot:
413
+ */
414
+ disabled?: boolean;
415
+ /**
416
+ * Translation key for the label
417
+ *
418
+ * @version SDK: 0.2 | ThoughtSpot:
419
+ */
420
+ labelTranslation?: VisualPropComponentTranslationKeys;
305
421
  }
306
422
 
307
423
  /**
@@ -331,7 +447,6 @@ export interface Section {
331
447
  children?: PropElement[];
332
448
  /**
333
449
  * Defines form alignment in the view for the section
334
- *
335
450
  * @version SDK: 0.1 | ThoughtSpot:
336
451
  */
337
452
  alignment?: 'row' | 'column';
@@ -343,6 +458,65 @@ export interface Section {
343
458
  * @version SDK: 0.0.1-alpha.3 | ThoughtSpot:
344
459
  */
345
460
  layoutType?: 'accordion' | 'tab' | 'none';
461
+ /**
462
+ * Determines whether section should be disabled or not
463
+ *
464
+ * @version SDK: 0.0.2-alpha.18 | ThoughtSpot:
465
+ */
466
+ disabled?: boolean;
467
+ /* Optional property to make the accordian expanded by default. If
468
+ * not passed the accordian will remain closed by default. Only works with layout type
469
+ * 'accordian'
470
+ *
471
+ * @version SDK: 0.0.2-alpha.19 | ThoughtSpot:
472
+ */
473
+ isAccordianExpanded?: boolean;
474
+ /**
475
+ * Translation key for the label
476
+ *
477
+ * @version SDK: 0.2 | ThoughtSpot:
478
+ */
479
+ labelTranslation?: VisualPropComponentTranslationKeys;
480
+ }
481
+
482
+ /**
483
+ * Native charts edit tool tip component defined for regular charts in TS Advance Chart Settings
484
+ *
485
+ * @group Visual Properties Editor
486
+ */
487
+ export interface NativeEditToolTip {
488
+ type: 'tooltipconfig';
489
+ /**
490
+ * Key to store the value
491
+ *
492
+ * @version SDK: 0.1 | ThoughtSpot:
493
+ */
494
+ key: string;
495
+
496
+ /*
497
+ List of column ids that are present in ToolTipConfig by default
498
+ */
499
+
500
+ defaultValue?: TSTooltipConfig;
501
+
502
+ /**
503
+ * I18n'ed string to show on the form label
504
+ *
505
+ * @version SDK: 0.1 | ThoughtSpot:
506
+ */
507
+ label?: string;
508
+ /**
509
+ * Determines whether it should be disabled or not
510
+ *
511
+ * @version SDK: 0.0.2-alpha.13 | ThoughtSpot:
512
+ */
513
+ disabled?: boolean;
514
+ /**
515
+ * Translation key for the label
516
+ *
517
+ * @version SDK: 0.2 | ThoughtSpot:
518
+ */
519
+ labelTranslation?: VisualPropComponentTranslationKeys;
346
520
  }
347
521
 
348
522
  /**
@@ -358,7 +532,20 @@ export type PropElement =
358
532
  | ToggleFormDetail
359
533
  | CheckboxFormDetail
360
534
  | RadioButtonFormDetail
361
- | DropDownFormDetail;
535
+ | DropDownFormDetail
536
+ | NativeEditToolTip;
537
+
538
+ /**
539
+ * Define Column settings, based on column type, settings needs to be defined in
540
+ * visualPropEditorDefinition using the current config columns,
541
+ * @version SDK: 0.2 | ThoughtSpot:
542
+ */
543
+ export interface ColumnProp {
544
+ type: ColumnType;
545
+ columnSettingsDefinition: {
546
+ [columnId: string]: { elements: PropElement[] };
547
+ };
548
+ }
362
549
 
363
550
  /**
364
551
  * Visual property editor definition object
@@ -373,11 +560,18 @@ export interface VisualPropEditorDefinition {
373
560
  * @version SDK: 0.1 | ThoughtSpot:
374
561
  */
375
562
  elements: PropElement[];
563
+ /**
564
+ *To Define column level settings.
565
+ *
566
+ * @version SDK: 0.2 | ThoughtSpot:
567
+ */
568
+ columnsVizPropDefinition?: ColumnProp[];
376
569
  }
377
570
 
378
571
  export type VisualEditorDefinitionSetter = (
379
572
  currentState: ChartModel,
380
573
  ctx: CustomChartContext,
574
+ activeColumnId?: string,
381
575
  ) => VisualPropEditorDefinition;
382
576
 
383
577
  /**
@@ -13,6 +13,7 @@ import {
13
13
  } from '../../test/test-conditional-formatting-utils';
14
14
  import {
15
15
  ChartColumn,
16
+ ChartSpecificColumnType,
16
17
  ColumnTimeBucket,
17
18
  ColumnType,
18
19
  DataType,
@@ -190,6 +191,7 @@ describe('getCfForColumn', () => {
190
191
  id: 'col3',
191
192
  name: '',
192
193
  type: ColumnType.MEASURE,
194
+ chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
193
195
  timeBucket: ColumnTimeBucket.AUTO,
194
196
  dataType: DataType.UNKNOWN,
195
197
  columnProperties: {