@thoughtspot/ts-chart-sdk 0.0.2-alpha.9 → 1.1.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.
- package/README.md +126 -50
- package/dist/ts-chart-sdk.d.ts +330 -32
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/main/custom-chart-context.d.ts +17 -4
- package/lib/main/custom-chart-context.d.ts.map +1 -1
- package/lib/main/custom-chart-context.js +46 -16
- package/lib/main/custom-chart-context.js.map +1 -1
- package/lib/main/custom-chart-context.spec.js +302 -4
- package/lib/main/custom-chart-context.spec.js.map +1 -1
- package/lib/main/logger.d.ts +13 -0
- package/lib/main/logger.d.ts.map +1 -0
- package/lib/main/logger.js +64 -0
- package/lib/main/logger.js.map +1 -0
- package/lib/main/logger.spec.d.ts +2 -0
- package/lib/main/logger.spec.d.ts.map +1 -0
- package/lib/main/logger.spec.js +88 -0
- package/lib/main/logger.spec.js.map +1 -0
- package/lib/main/util.d.ts +2 -0
- package/lib/main/util.d.ts.map +1 -1
- package/lib/main/util.js +11 -0
- package/lib/main/util.js.map +1 -1
- package/lib/main/util.spec.d.ts +2 -0
- package/lib/main/util.spec.d.ts.map +1 -0
- package/lib/main/util.spec.js +73 -0
- package/lib/main/util.spec.js.map +1 -0
- package/lib/react/use-custom-chart-context.d.ts.map +1 -1
- package/lib/react/use-custom-chart-context.js +3 -1
- package/lib/react/use-custom-chart-context.js.map +1 -1
- package/lib/react/use-custom-chart-context.spec.js +0 -1
- package/lib/react/use-custom-chart-context.spec.js.map +1 -1
- package/lib/react/use-custom-chart-context.util.d.ts.map +1 -1
- package/lib/react/use-custom-chart-context.util.js +5 -3
- package/lib/react/use-custom-chart-context.util.js.map +1 -1
- package/lib/types/answer-column.types.d.ts +7 -4
- package/lib/types/answer-column.types.d.ts.map +1 -1
- package/lib/types/answer-column.types.js +3 -3
- package/lib/types/answer-column.types.js.map +1 -1
- package/lib/types/chart-to-ts-event.types.d.ts +2 -0
- package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/lib/types/chart-to-ts-event.types.js +1 -0
- package/lib/types/chart-to-ts-event.types.js.map +1 -1
- package/lib/types/common.types.d.ts +65 -6
- package/lib/types/common.types.d.ts.map +1 -1
- package/lib/types/common.types.js.map +1 -1
- package/lib/types/conditional-formatting.types.d.ts +1 -16
- package/lib/types/conditional-formatting.types.d.ts.map +1 -1
- package/lib/types/conditional-formatting.types.js.map +1 -1
- package/lib/types/configurator.types.d.ts +1 -1
- package/lib/types/configurator.types.d.ts.map +1 -1
- package/lib/types/number-formatting.types.d.ts +55 -0
- package/lib/types/number-formatting.types.d.ts.map +1 -0
- package/lib/types/number-formatting.types.js +23 -0
- package/lib/types/number-formatting.types.js.map +1 -0
- package/lib/types/ts-to-chart-event.types.d.ts +20 -6
- package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
- package/lib/types/ts-to-chart-event.types.js +1 -0
- package/lib/types/ts-to-chart-event.types.js.map +1 -1
- package/lib/types/visual-prop.types.d.ts +71 -3
- package/lib/types/visual-prop.types.d.ts.map +1 -1
- package/lib/types/visual-prop.types.js +32 -1
- package/lib/types/visual-prop.types.js.map +1 -1
- package/lib/utils/date-formatting.d.ts +85 -1
- package/lib/utils/date-formatting.d.ts.map +1 -1
- package/lib/utils/date-formatting.js +344 -9
- package/lib/utils/date-formatting.js.map +1 -1
- package/lib/utils/date-formatting.spec.js +301 -31
- package/lib/utils/date-formatting.spec.js.map +1 -1
- package/lib/utils/date-utils.d.ts +6 -0
- package/lib/utils/date-utils.d.ts.map +1 -0
- package/lib/utils/date-utils.js +20 -0
- package/lib/utils/date-utils.js.map +1 -0
- package/lib/utils/date-utils.spec.d.ts +2 -0
- package/lib/utils/date-utils.spec.d.ts.map +1 -0
- package/lib/utils/date-utils.spec.js +63 -0
- package/lib/utils/date-utils.spec.js.map +1 -0
- package/lib/utils/formatting-util.d.ts +10 -0
- package/lib/utils/formatting-util.d.ts.map +1 -0
- package/lib/utils/formatting-util.js +78 -0
- package/lib/utils/formatting-util.js.map +1 -0
- package/lib/utils/formatting-util.spec.d.ts +2 -0
- package/lib/utils/formatting-util.spec.d.ts.map +1 -0
- package/lib/utils/formatting-util.spec.js +247 -0
- package/lib/utils/formatting-util.spec.js.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.d.ts +16 -0
- package/lib/utils/globalize-Initializer/globalize-utils.d.ts.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.js +101 -0
- package/lib/utils/globalize-Initializer/globalize-utils.js.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts +2 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.js +149 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.d.ts +20 -0
- package/lib/utils/number-formatting/number-formatting-utils.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.js +159 -0
- package/lib/utils/number-formatting/number-formatting-utils.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts +2 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.js +221 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting.d.ts +5 -0
- package/lib/utils/number-formatting/number-formatting.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting.js +128 -0
- package/lib/utils/number-formatting/number-formatting.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting.spec.d.ts +2 -0
- package/lib/utils/number-formatting/number-formatting.spec.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting.spec.js +159 -0
- package/lib/utils/number-formatting/number-formatting.spec.js.map +1 -0
- package/package.json +4 -1
- package/src/index.ts +3 -0
- package/src/main/custom-chart-context.spec.ts +356 -6
- package/src/main/custom-chart-context.ts +205 -16
- package/src/main/logger.spec.ts +114 -0
- package/src/main/logger.ts +97 -0
- package/src/main/util.spec.ts +94 -0
- package/src/main/util.ts +20 -0
- package/src/react/use-custom-chart-context.spec.tsx +0 -1
- package/src/react/use-custom-chart-context.tsx +4 -1
- package/src/react/use-custom-chart-context.util.ts +6 -3
- package/src/types/answer-column.types.ts +9 -6
- package/src/types/chart-to-ts-event.types.ts +7 -0
- package/src/types/common.types.ts +100 -10
- package/src/types/conditional-formatting.types.ts +2 -17
- package/src/types/configurator.types.ts +1 -1
- package/src/types/number-formatting.types.ts +80 -0
- package/src/types/ts-to-chart-event.types.ts +63 -5
- package/src/types/visual-prop.types.ts +197 -3
- package/src/utils/date-formatting.spec.ts +375 -32
- package/src/utils/date-formatting.ts +587 -14
- package/src/utils/date-utils.spec.ts +93 -0
- package/src/utils/date-utils.ts +69 -0
- package/src/utils/formatting-util.spec.ts +312 -0
- package/src/utils/formatting-util.ts +234 -0
- package/src/utils/globalize-Initializer/globalize-utils.spec.ts +192 -0
- package/src/utils/globalize-Initializer/globalize-utils.ts +216 -0
- package/src/utils/number-formatting/number-formatting-utils.spec.ts +296 -0
- package/src/utils/number-formatting/number-formatting-utils.ts +260 -0
- package/src/utils/number-formatting/number-formatting.spec.ts +243 -0
- package/src/utils/number-formatting/number-formatting.ts +264 -0
package/README.md
CHANGED
|
@@ -6,58 +6,75 @@
|
|
|
6
6
|
|
|
7
7
|
# ThoughtSpot Charts SDK <br/>
|
|
8
8
|
|
|
9
|
-
ThoughtSpot Charts SDK allows developers to integrate custom charts into ThoughtSpot. Developers can create custom charts in Javascript using charting libraries such as HighCharts and upload them to ThoughtSpot.
|
|
9
|
+
ThoughtSpot Charts SDK allows developers to integrate custom charts into ThoughtSpot. Developers can create custom charts in Javascript using charting libraries such as HighCharts and upload them to ThoughtSpot.
|
|
10
10
|
|
|
11
|
+
## Doc for custom chart examples
|
|
12
|
+
|
|
13
|
+
- [Custom Map charts](./example/custom-bar-chart/README.md)
|
|
14
|
+
- [Custom Bar Charts](./example/custom-bar-chart/README.md)
|
|
15
|
+
|
|
16
|
+
## ⚠️ Important Information ⚠️
|
|
17
|
+
|
|
18
|
+
### 🚀 Use `ts-chart-sdk` with TypeScript to enable static type checking.
|
|
19
|
+
|
|
20
|
+
### 📊 See [Custom Bar Chart](./example/custom-bar-chart/) example for the latest update.
|
|
21
|
+
|
|
22
|
+
---
|
|
11
23
|
|
|
12
24
|
# Get started
|
|
13
|
-
|
|
25
|
+
|
|
26
|
+
This tutorial demonstrates how to create a Gantt chart using HighCharts.
|
|
14
27
|
<insert links and fiddle links above>
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
|
|
29
|
+
- [Highchart demo link](https://www.highcharts.com/demo/gantt/progress-indicator)
|
|
30
|
+
- [JSFiddle link](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/gantt/demo/progress-indicator)
|
|
17
31
|
|
|
18
32
|
## Prerequisites
|
|
33
|
+
|
|
19
34
|
Before you begin, check for the following requirements:
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
- Access to a ThoughtSpot Cloud application instance
|
|
37
|
+
- A Development Environment (IDE) for building custom charts
|
|
38
|
+
- Working knowledge of JavaScript or Typescript
|
|
39
|
+
- Familiarity with charting libraries such as Highcharts
|
|
40
|
+
- Knowledge of the chart type
|
|
26
41
|
|
|
27
42
|
## Set up your environment
|
|
43
|
+
|
|
28
44
|
To create and test the application, this tutorial uses a Vite project setup.
|
|
29
45
|
|
|
30
46
|
### Create a new Vite project
|
|
31
47
|
|
|
32
48
|
1. Open a terminal window and run the following commands:
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
```bash
|
|
51
|
+
md gantt
|
|
52
|
+
cd gantt
|
|
53
|
+
```
|
|
38
54
|
|
|
39
55
|
2. Create a Vite project.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
```bash
|
|
57
|
+
$ npm create vite@latest
|
|
58
|
+
```
|
|
43
59
|
3. Configure the project name and development framework for your chart application. In this tutorial, we will use the Vanilla framework with TypeScript.
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
```bash
|
|
62
|
+
✔ Project name: … gantt demo
|
|
63
|
+
✔ Package name: … gantt-demo
|
|
64
|
+
✔ Select a framework: › Vanilla
|
|
65
|
+
✔ Select a variant: › TypeScript
|
|
66
|
+
```
|
|
67
|
+
|
|
51
68
|
4. Initialize your application.
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
```bash
|
|
71
|
+
npm install
|
|
72
|
+
npm run dev
|
|
73
|
+
```
|
|
57
74
|
|
|
58
75
|
5. Go to the localhost link and check if the following page shows up.
|
|
59
76
|
|
|
60
|
-
|
|
77
|
+

|
|
61
78
|
|
|
62
79
|
### Install Highcharts and lodash
|
|
63
80
|
|
|
@@ -75,7 +92,7 @@ npm install --save @thoughtspot/ts-chart-sdk
|
|
|
75
92
|
|
|
76
93
|
Render a chart in the application created from the preceding steps.
|
|
77
94
|
|
|
78
|
-
This tutorial uses the
|
|
95
|
+
This tutorial uses the [chart from the Highcharts library](https://www.highcharts.com/demo/gantt/progress-indicator) to create a custom Gantt chart.
|
|
79
96
|
|
|
80
97
|
### Implement the chart code
|
|
81
98
|
|
|
@@ -83,7 +100,7 @@ This tutorial uses the implementation code of the Gantt chart from the [Highchar
|
|
|
83
100
|
|
|
84
101
|
To implement the chart code in your application, complete these steps:
|
|
85
102
|
|
|
86
|
-
1. To copy the implementation code from the Highcharts library, select a chart type and click **Copy JS Code**.
|
|
103
|
+
1. To copy the implementation code from the Highcharts library, select a chart type and click **Copy JS Code**.
|
|
87
104
|
2. Paste this code into the `main.ts` file in your `src` folder.
|
|
88
105
|
3. Import the dependencies for Highcharts and Highcharts Gantt module into your application code as shown in this example:
|
|
89
106
|
|
|
@@ -91,6 +108,7 @@ To implement the chart code in your application, complete these steps:
|
|
|
91
108
|
import Highcharts from 'highcharts/es-modules/masters/highcharts.src';
|
|
92
109
|
import 'highcharts/es-modules/masters/modules/gantt.src';
|
|
93
110
|
```
|
|
111
|
+
|
|
94
112
|
Note the order of import.
|
|
95
113
|
|
|
96
114
|
4. Replace the content of `index.html` with the following snippet:
|
|
@@ -111,8 +129,9 @@ To implement the chart code in your application, complete these steps:
|
|
|
111
129
|
</body>
|
|
112
130
|
</html>
|
|
113
131
|
```
|
|
132
|
+
|
|
114
133
|
5. Refresh the application URL and check if the chart imported into your application code is rendered:
|
|
115
|
-
|
|
134
|
+

|
|
116
135
|
6. Delete the unwanted files from your project folder
|
|
117
136
|
The folder structure in your project at this point includes many files as shown in this figure.
|
|
118
137
|
|
|
@@ -120,11 +139,11 @@ To implement the chart code in your application, complete these steps:
|
|
|
120
139
|
|
|
121
140
|
You can remove the following files.
|
|
122
141
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
- `/public/vite.svg`
|
|
143
|
+
- `/src/counter.ts`
|
|
144
|
+
- `/src/typescript.svg`
|
|
126
145
|
|
|
127
|
-
## Integrate ThoughtSpot Chart SDK
|
|
146
|
+
## Integrate ThoughtSpot Chart SDK
|
|
128
147
|
|
|
129
148
|
The chart imported into your application has static data. To add ThoughtSpot capabilities such as drill, you need to fetch data from your ThoughtSpot application. To add ThoughtSpot capabilities and data to the chart code in your application, integrate ThoughtSpot Chart SDK and complete these steps:
|
|
130
149
|
|
|
@@ -207,16 +226,18 @@ const init = async () => {
|
|
|
207
226
|
|
|
208
227
|
init();
|
|
209
228
|
```
|
|
210
|
-
|
|
211
|
-
>
|
|
212
|
-
|
|
213
|
-
|
|
229
|
+
|
|
230
|
+
> NOTE:
|
|
231
|
+
> For more information about the chart context component, refer to the following documentation resources:
|
|
232
|
+
>
|
|
233
|
+
> - [https://ts-chart-sdk-docs.vercel.app/types/CustomChartContextProps.html](https://ts-chart-sdk-docs.vercel.app/types/CustomChartContextProps.html)
|
|
234
|
+
> - [https://github.com/thoughtspot/ts-chart-sdk/blob/main/src/main/custom-chart-context.ts#L40](https://github.com/thoughtspot/ts-chart-sdk/blob/main/src/main/custom-chart-context.ts#L40)
|
|
214
235
|
|
|
215
236
|
The custom chart context component must include the following mandatory properties to function:
|
|
216
237
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
238
|
+
- [`getDefaultChartConfig (Doc)`](<#getDefaultChartConfig-(Doc)>)
|
|
239
|
+
- [`getQueriesFromChartConfig (Doc)`](<#getQueriesFromChartConfig-(Doc)>)
|
|
240
|
+
- [`renderChart (Doc)`](<#getQueriesFromChartConfig-(Doc)>)
|
|
220
241
|
|
|
221
242
|
#### getDefaultChartConfig (Doc)
|
|
222
243
|
|
|
@@ -235,6 +256,7 @@ The point for the Gantt chart used in this tutorial looks like this:
|
|
|
235
256
|
},
|
|
236
257
|
}
|
|
237
258
|
```
|
|
259
|
+
|
|
238
260
|
The above data can be represented as a table in CSV format as shown here:
|
|
239
261
|
|
|
240
262
|
```bash
|
|
@@ -332,9 +354,9 @@ getQueriesFromChartConfig: (
|
|
|
332
354
|
This `renderChart (Doc)` function is required to render the chart implemented in your code. This function ensures that every time `chartContext` tries to re-render the chart due to the changes in data or chart model, the chart rendered in your application is updated.
|
|
333
355
|
|
|
334
356
|
> **Note**:
|
|
335
|
-
You can control render and re-render by implementing more granular control for the updates on data, visual props, or chart model.
|
|
357
|
+
> You can control render and re-render by implementing more granular control for the updates on data, visual props, or chart model.
|
|
336
358
|
>
|
|
337
|
-
But we haven't yet implemented this. So let's proceed and implement this.
|
|
359
|
+
> But we haven't yet implemented this. So let's proceed and implement this.
|
|
338
360
|
|
|
339
361
|
#### Implement the renderChart function
|
|
340
362
|
|
|
@@ -352,13 +374,14 @@ const renderChart = (ctx) => {
|
|
|
352
374
|
};
|
|
353
375
|
```
|
|
354
376
|
|
|
355
|
-
2. Implement the `renderChart` function in `getChartContext` as shown in this example:
|
|
377
|
+
2. Implement the `renderChart` function in `getChartContext` as shown in this example:
|
|
356
378
|
|
|
357
379
|
```jsx
|
|
358
380
|
...
|
|
359
381
|
renderChart: (context) => renderChart(context),
|
|
360
382
|
...
|
|
361
383
|
```
|
|
384
|
+
|
|
362
385
|
At this point, you will notice that the chart is gone on the link.
|
|
363
386
|
|
|
364
387
|
3. Wait for the chart to connect to the TS application.
|
|
@@ -369,6 +392,7 @@ At this point, you will notice that the chart is gone on the link.
|
|
|
369
392
|
[vite] connected.
|
|
370
393
|
Chart Context: initialization start
|
|
371
394
|
```
|
|
395
|
+
|
|
372
396
|
5. Run your application and test the chart implementation in the Playground.
|
|
373
397
|
|
|
374
398
|
#### Run the chart in the Playground
|
|
@@ -385,8 +409,8 @@ To run the chart and test your implementation, you need a Playground.
|
|
|
385
409
|
|
|
386
410
|
2. Add the following details as shown in the following example:
|
|
387
411
|
|
|
388
|
-
|
|
389
|
-
|
|
412
|
+
- App Url : `<your localhost url with port>`
|
|
413
|
+
- Chart Model: `Gantt - 3 Attribute - 2 Date - 1 Measure`
|
|
390
414
|
|
|
391
415
|

|
|
392
416
|
|
|
@@ -408,7 +432,8 @@ For the Gantt chart, this tutorial uses the following format for data points:
|
|
|
408
432
|
},
|
|
409
433
|
}
|
|
410
434
|
```
|
|
411
|
-
|
|
435
|
+
|
|
436
|
+
However, the data retrieved from the chart model includes an array of column types as shown in this example:
|
|
412
437
|
|
|
413
438
|
```jsx
|
|
414
439
|
// inside chart model
|
|
@@ -563,12 +588,13 @@ const getDataModel = (chartModel: any) => {
|
|
|
563
588
|
|
|
564
589
|
Use the data model created from the above function and plug the values into the Highchart configuration to render the chart.
|
|
565
590
|
|
|
566
|
-
1. Create a data model object.
|
|
591
|
+
1. Create a data model object.
|
|
567
592
|
In your `renderChart` code, add the following line:
|
|
568
593
|
|
|
569
594
|
```jsx
|
|
570
595
|
const dataModel = getDataModel(chartModel);
|
|
571
596
|
```
|
|
597
|
+
|
|
572
598
|
2. Replace X Axis min and max values.
|
|
573
599
|
|
|
574
600
|
```jsx
|
|
@@ -577,13 +603,14 @@ xAxis: {
|
|
|
577
603
|
max: dataModel.maxDate,
|
|
578
604
|
},
|
|
579
605
|
```
|
|
606
|
+
|
|
580
607
|
3. Replace the series.
|
|
581
608
|
|
|
582
609
|
```jsx
|
|
583
610
|
series: dataModel.dataSeries,
|
|
584
611
|
```
|
|
585
612
|
|
|
586
|
-
The chart implemented in your code now shows up on the playground with the data values you just plugged in.
|
|
613
|
+
The chart implemented in your code now shows up on the playground with the data values you just plugged in.
|
|
587
614
|
|
|
588
615
|
The following example shows the entire chart code for the Gantt chart implementation described in this tutorial:
|
|
589
616
|
|
|
@@ -769,14 +796,63 @@ To deploy your charts, you can use Vercel, Netlify, or any server that can rende
|
|
|
769
796
|
To deploy the chart on a test domain in Vercel, install <a href="https://vercel.com/docs/cli" target="_blank">Vercel CLI</a> and run the following command:
|
|
770
797
|
|
|
771
798
|
```jsx
|
|
772
|
-
vercel
|
|
799
|
+
vercel;
|
|
773
800
|
```
|
|
801
|
+
|
|
774
802
|
For more information about Vercel deployment, see <a href="https://vercel.com/docs/getting-started-with-vercel" target="_blank">Vercel documentation</a>.
|
|
775
803
|
|
|
776
804
|
### Content Security Policy Overrides
|
|
777
805
|
|
|
778
806
|
To allow the use of Vercel application content in Thoughtspot, add the Vercel domain URL to the CSP allow-list. For more information, see the <a href="https://developers.thoughtspot.com/docs/?pageid=security-settings" target="_blank">Security settings section in ThoughtSpot documentation</a>.
|
|
779
807
|
|
|
808
|
+
## Useful URLs
|
|
809
|
+
|
|
810
|
+
### API references
|
|
811
|
+
|
|
812
|
+
- Check out [ts-charts-sdk docs](https://ts-chart-sdk-docs.vercel.app/) to get API reference.
|
|
813
|
+
|
|
814
|
+
### Test framework
|
|
815
|
+
|
|
816
|
+
- Open [Playground](https://ts-chart-playground.vercel.app/) to play with ts-chart-sdk with mock chartModel.
|
|
817
|
+
|
|
818
|
+
### Code Walkthrough
|
|
819
|
+
|
|
820
|
+
- Play [demo](https://drive.google.com/drive/u/0/folders/1DbfiT1VP7j4SqhiCtM2JksTeIjbkI8h3) to get a viedo demo of code walkthrough and custom gantt-chart implementation.
|
|
821
|
+
|
|
822
|
+
## FAQ
|
|
823
|
+
|
|
824
|
+
#### How to save some chart specific state after client have made some changes in charts?
|
|
825
|
+
|
|
826
|
+
You can use `ChartToTSEvent.UpdateVisualProps` eventType inside `ctx.emitEvent()`. Since the payload type for this event is `unkown` you can just add a key value pair naming `clientState`.
|
|
827
|
+
|
|
828
|
+
**Sample** -
|
|
829
|
+
|
|
830
|
+
```js
|
|
831
|
+
ctx.emitEvent(ChartTOTSEvent.UpdateVisualProps,{
|
|
832
|
+
visualProps:{
|
|
833
|
+
clientState:"<req_state_in_string_format>"
|
|
834
|
+
...rest_of_visualProp
|
|
835
|
+
}
|
|
836
|
+
})
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
- NOTE: client State currently support only string data type. To use it with json object you can use `JSON.stringify(somelocalstate)`
|
|
840
|
+
|
|
841
|
+
#### Why my chart is getting re render in an infinte loop?
|
|
842
|
+
|
|
843
|
+
Probably you are implementing `update client state` logic inside the the `render` function of `getChartContext`. Since it `render` will be calling `update client state` logic and this logic might again cause `render` this will cause a cyclic call of `render`. Hence,it is advised not to implement it inside `render` function.
|
|
844
|
+
|
|
845
|
+
> NOTE:
|
|
846
|
+
> This can be called inside render function just that to avoid having an infinite loop clientState updates should be handled by chart developer properly.
|
|
847
|
+
|
|
848
|
+
#### How to add dynamic config for visualPorpEditorDefintion?
|
|
849
|
+
|
|
850
|
+
Since in our previous implementation of `visualPropEditorDefintion` we provided this as an static object of type `VisualPropEditorDefinition` but with the resent update this is converted function of type `VisualEditorDefinitonSetter` along with `VisualEditorDefintion`. So currently you can provide static config or dynamic config based on use case.
|
|
851
|
+
|
|
852
|
+
#### Only 1000 points are getting fetched for my query even though there are more results. How to increase that?
|
|
853
|
+
|
|
854
|
+
In `getQueriesFromChartConfig` along with `QueryColumn` you can provide additional optional key `queryParams`. In `queryParams` you can provide `size` to deal with the number of data points that need to fetched. Also there is hard limit of 100K data points to be fetched from the backend.
|
|
855
|
+
|
|
780
856
|
<br/>
|
|
781
857
|
|
|
782
858
|
ThoughtSpot Chart SDK, © ThoughtSpot, Inc. 2023
|