@thoughtspot/ts-chart-sdk 0.0.1-alpha.1 → 0.0.1-alpha.11
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/cjs/index.d.ts +1 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/main/custom-chart-context.d.ts +10 -2
- package/cjs/main/custom-chart-context.d.ts.map +1 -1
- package/cjs/main/custom-chart-context.js +117 -2
- package/cjs/main/custom-chart-context.js.map +1 -1
- package/cjs/main/custom-chart-context.spec.js +320 -0
- package/cjs/main/custom-chart-context.spec.js.map +1 -1
- package/cjs/main/post-message-event-bridge.js +1 -1
- package/cjs/main/post-message-event-bridge.js.map +1 -1
- package/cjs/main/post-message-event-bridge.spec.js +5 -3
- package/cjs/main/post-message-event-bridge.spec.js.map +1 -1
- package/cjs/react/mocks/custom-chart-context-mock.d.ts +3 -0
- package/cjs/react/mocks/custom-chart-context-mock.d.ts.map +1 -0
- package/cjs/react/mocks/custom-chart-context-mock.js +100 -0
- package/cjs/react/mocks/custom-chart-context-mock.js.map +1 -0
- package/cjs/react/use-custom-chart-context.d.ts +4 -0
- package/cjs/react/use-custom-chart-context.d.ts.map +1 -0
- package/cjs/react/use-custom-chart-context.js +95 -0
- package/cjs/react/use-custom-chart-context.js.map +1 -0
- package/cjs/react/use-custom-chart-context.spec.d.ts +2 -0
- package/cjs/react/use-custom-chart-context.spec.d.ts.map +1 -0
- package/cjs/react/use-custom-chart-context.spec.js +391 -0
- package/cjs/react/use-custom-chart-context.spec.js.map +1 -0
- package/cjs/react/use-custom-chart-context.util.d.ts +6 -0
- package/cjs/react/use-custom-chart-context.util.d.ts.map +1 -0
- package/cjs/react/use-custom-chart-context.util.js +60 -0
- package/cjs/react/use-custom-chart-context.util.js.map +1 -0
- package/cjs/react/use-custom-chart-types.d.ts +23 -0
- package/cjs/react/use-custom-chart-types.d.ts.map +1 -0
- package/cjs/react/use-custom-chart-types.js +3 -0
- package/cjs/react/use-custom-chart-types.js.map +1 -0
- package/cjs/types/chart-to-ts-event.types.d.ts +54 -4
- package/cjs/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/cjs/types/chart-to-ts-event.types.js +14 -1
- package/cjs/types/chart-to-ts-event.types.js.map +1 -1
- package/cjs/types/common.types.d.ts +2 -0
- package/cjs/types/common.types.d.ts.map +1 -1
- package/cjs/types/ts-to-chart-event.types.d.ts +23 -1
- package/cjs/types/ts-to-chart-event.types.d.ts.map +1 -1
- package/cjs/types/ts-to-chart-event.types.js +2 -0
- package/cjs/types/ts-to-chart-event.types.js.map +1 -1
- package/cjs/types/visual-prop.types.d.ts +27 -1
- package/cjs/types/visual-prop.types.d.ts.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/main/custom-chart-context.d.ts +12 -4
- package/lib/main/custom-chart-context.d.ts.map +1 -1
- package/lib/main/custom-chart-context.js +119 -4
- package/lib/main/custom-chart-context.js.map +1 -1
- package/lib/main/custom-chart-context.spec.js +317 -0
- package/lib/main/custom-chart-context.spec.js.map +1 -1
- package/lib/main/post-message-event-bridge.js +1 -1
- package/lib/main/post-message-event-bridge.js.map +1 -1
- package/lib/main/post-message-event-bridge.spec.js +5 -3
- package/lib/main/post-message-event-bridge.spec.js.map +1 -1
- package/lib/react/mocks/custom-chart-context-mock.d.ts +3 -0
- package/lib/react/mocks/custom-chart-context-mock.d.ts.map +1 -0
- package/lib/react/mocks/custom-chart-context-mock.js +94 -0
- package/lib/react/mocks/custom-chart-context-mock.js.map +1 -0
- package/lib/react/use-custom-chart-context.d.ts +4 -0
- package/lib/react/use-custom-chart-context.d.ts.map +1 -0
- package/lib/react/use-custom-chart-context.js +68 -0
- package/lib/react/use-custom-chart-context.js.map +1 -0
- package/lib/react/use-custom-chart-context.spec.d.ts +2 -0
- package/lib/react/use-custom-chart-context.spec.d.ts.map +1 -0
- package/lib/react/use-custom-chart-context.spec.js +363 -0
- package/lib/react/use-custom-chart-context.spec.js.map +1 -0
- package/lib/react/use-custom-chart-context.util.d.ts +6 -0
- package/lib/react/use-custom-chart-context.util.d.ts.map +1 -0
- package/lib/react/use-custom-chart-context.util.js +51 -0
- package/lib/react/use-custom-chart-context.util.js.map +1 -0
- package/lib/react/use-custom-chart-types.d.ts +23 -0
- package/lib/react/use-custom-chart-types.d.ts.map +1 -0
- package/lib/react/use-custom-chart-types.js +2 -0
- package/lib/react/use-custom-chart-types.js.map +1 -0
- package/lib/types/chart-to-ts-event.types.d.ts +54 -4
- package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/lib/types/chart-to-ts-event.types.js +13 -0
- package/lib/types/chart-to-ts-event.types.js.map +1 -1
- package/lib/types/common.types.d.ts +7 -5
- package/lib/types/common.types.d.ts.map +1 -1
- package/lib/types/ts-to-chart-event.types.d.ts +23 -1
- package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
- package/lib/types/ts-to-chart-event.types.js +2 -0
- package/lib/types/ts-to-chart-event.types.js.map +1 -1
- package/lib/types/visual-prop.types.d.ts +27 -1
- package/lib/types/visual-prop.types.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/index.ts +1 -0
- package/src/main/custom-chart-context.spec.ts +426 -0
- package/src/main/custom-chart-context.ts +249 -4
- package/src/main/post-message-event-bridge.spec.ts +5 -3
- package/src/main/post-message-event-bridge.ts +1 -1
- package/src/react/mocks/custom-chart-context-mock.ts +114 -0
- package/src/react/use-custom-chart-context.spec.tsx +464 -0
- package/src/react/use-custom-chart-context.tsx +180 -0
- package/src/react/use-custom-chart-context.util.ts +101 -0
- package/src/react/use-custom-chart-types.ts +70 -0
- package/src/types/chart-to-ts-event.types.ts +215 -3
- package/src/types/common.types.ts +15 -1
- package/src/types/ts-to-chart-event.types.ts +70 -0
- package/src/types/visual-prop.types.ts +137 -0
- package/dist/ts-chart-sdk.d.ts +0 -312
- package/lib/dist/ts-chart-sdk.d.ts +0 -312
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { CustomChartContext } from '../main/custom-chart-context';
|
|
3
|
+
import {
|
|
4
|
+
ChartToTSEvent,
|
|
5
|
+
ChartToTSEventsPayloadMap,
|
|
6
|
+
} from '../types/chart-to-ts-event.types';
|
|
7
|
+
import {
|
|
8
|
+
TSToChartEvent,
|
|
9
|
+
TSToChartEventsPayloadMap,
|
|
10
|
+
} from '../types/ts-to-chart-event.types';
|
|
11
|
+
import {
|
|
12
|
+
ChartToTSEventEmitters,
|
|
13
|
+
TSToChartEventListener,
|
|
14
|
+
TSToChartEventOffListener,
|
|
15
|
+
} from './use-custom-chart-types';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param ctx Custom Chart Context
|
|
20
|
+
* @returns List of event emitters
|
|
21
|
+
*/
|
|
22
|
+
export const emitter = (ctx: CustomChartContext): ChartToTSEventEmitters => {
|
|
23
|
+
const validEvents = Object.keys(
|
|
24
|
+
ChartToTSEvent,
|
|
25
|
+
) as (keyof ChartToTSEventsPayloadMap)[];
|
|
26
|
+
return validEvents.reduce((acc, eventKey) => {
|
|
27
|
+
const eventName = eventKey as keyof ChartToTSEventsPayloadMap;
|
|
28
|
+
const emitterKey = `emit${eventKey}` as keyof ChartToTSEventEmitters;
|
|
29
|
+
|
|
30
|
+
acc[emitterKey] = (
|
|
31
|
+
...args: ChartToTSEventsPayloadMap[keyof ChartToTSEventsPayloadMap]
|
|
32
|
+
): Promise<void> => {
|
|
33
|
+
if (!ctx || _.isEmpty(ctx)) {
|
|
34
|
+
console.log('Context is not initialized');
|
|
35
|
+
return Promise.reject(new Error('Context not initialized'));
|
|
36
|
+
}
|
|
37
|
+
return ctx.emitEvent(eventName, ...args);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return acc;
|
|
41
|
+
}, {} as ChartToTSEventEmitters);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param ctx Custom Chart Context
|
|
47
|
+
* @returns List of event listeners
|
|
48
|
+
*/
|
|
49
|
+
export const eventListener = (
|
|
50
|
+
ctx: CustomChartContext,
|
|
51
|
+
): TSToChartEventListener => {
|
|
52
|
+
const validEvents = Object.keys(
|
|
53
|
+
TSToChartEvent,
|
|
54
|
+
) as (keyof TSToChartEventsPayloadMap)[];
|
|
55
|
+
return validEvents.reduce((acc, eventKey) => {
|
|
56
|
+
const eventName = eventKey as keyof TSToChartEventsPayloadMap;
|
|
57
|
+
const emitterKey = `setOn${eventKey}` as keyof TSToChartEventListener;
|
|
58
|
+
|
|
59
|
+
acc[emitterKey] = (
|
|
60
|
+
callbackFn: TSToChartEventsPayloadMap[keyof TSToChartEventsPayloadMap],
|
|
61
|
+
): Promise<void> => {
|
|
62
|
+
if (!ctx || _.isEmpty(ctx)) {
|
|
63
|
+
console.log('Context is not initialized');
|
|
64
|
+
return Promise.reject(new Error('Context not initialized'));
|
|
65
|
+
}
|
|
66
|
+
ctx.on(eventName, callbackFn);
|
|
67
|
+
return Promise.resolve();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return acc;
|
|
71
|
+
}, {} as TSToChartEventListener);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @param ctx Custom Chart Context
|
|
77
|
+
* @returns List of event listeners
|
|
78
|
+
*/
|
|
79
|
+
export const eventOffListener = (
|
|
80
|
+
ctx: CustomChartContext,
|
|
81
|
+
): TSToChartEventOffListener => {
|
|
82
|
+
const validEvents = Object.keys(
|
|
83
|
+
TSToChartEvent,
|
|
84
|
+
) as (keyof TSToChartEventsPayloadMap)[];
|
|
85
|
+
return validEvents.reduce((acc, eventKey) => {
|
|
86
|
+
const eventName = eventKey as keyof TSToChartEventsPayloadMap;
|
|
87
|
+
const emitterKey =
|
|
88
|
+
`setOff${eventKey}` as keyof TSToChartEventOffListener;
|
|
89
|
+
|
|
90
|
+
acc[emitterKey] = (): Promise<void> => {
|
|
91
|
+
if (!ctx || _.isEmpty(ctx)) {
|
|
92
|
+
console.log('Context is not initialized');
|
|
93
|
+
return Promise.reject(new Error('Context not initialized'));
|
|
94
|
+
}
|
|
95
|
+
ctx.off(eventName);
|
|
96
|
+
return Promise.resolve();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return acc;
|
|
100
|
+
}, {} as TSToChartEventOffListener);
|
|
101
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChartToTSEventsPayloadMap } from '../types/chart-to-ts-event.types';
|
|
3
|
+
import { ChartModel } from '../types/common.types';
|
|
4
|
+
import { TSToChartEventsPayloadMap } from '../types/ts-to-chart-event.types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* For all events that we trigger from React Chart to TS Host,
|
|
8
|
+
* this enum provides the trigger functions for each event.
|
|
9
|
+
* All the trigger functions have a prefix of emit.
|
|
10
|
+
*/
|
|
11
|
+
export type ChartToTSEventEmitters = {
|
|
12
|
+
[key in keyof ChartToTSEventsPayloadMap as `emit${Capitalize<key>}`]: (
|
|
13
|
+
...args: ChartToTSEventsPayloadMap[key]
|
|
14
|
+
) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* For all events that we trigger from TS Host to React Chart,
|
|
19
|
+
* this enum provides the event listener on functions for each external event listener.
|
|
20
|
+
* All the event listener functions have a prefix of on.
|
|
21
|
+
*/
|
|
22
|
+
export type TSToChartEventListener = {
|
|
23
|
+
[key in keyof TSToChartEventsPayloadMap as `setOn${Capitalize<key>}`]: (
|
|
24
|
+
args: TSToChartEventsPayloadMap[key],
|
|
25
|
+
) => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* For all events that we trigger from TS Host to React Chart,
|
|
30
|
+
* this enum provides the event listener on functions for each external event listener.
|
|
31
|
+
* All the event listener functions have a prefix of on.
|
|
32
|
+
*/
|
|
33
|
+
export type TSToChartEventOffListener = {
|
|
34
|
+
[key in keyof TSToChartEventsPayloadMap as `setOff${Capitalize<key>}`]: () => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export interface TSChartContextProps {
|
|
38
|
+
/**
|
|
39
|
+
* Child App which renders chart
|
|
40
|
+
* wrapper is used to control rendering of child app
|
|
41
|
+
*/
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ChartContextProps
|
|
46
|
+
extends ChartToTSEventEmitters,
|
|
47
|
+
TSToChartEventListener,
|
|
48
|
+
TSToChartEventOffListener {
|
|
49
|
+
/**
|
|
50
|
+
* decides if the chart context is initialzed
|
|
51
|
+
*/
|
|
52
|
+
hasInitialized: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* chart model to be used by client having
|
|
55
|
+
* config, data and visual props
|
|
56
|
+
*/
|
|
57
|
+
chartModel: ChartModel | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* For destroying current chart context
|
|
60
|
+
* @returns void
|
|
61
|
+
*/
|
|
62
|
+
destroy: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Parent component wrapped around chart app
|
|
65
|
+
* for controlling re-rendering of chart
|
|
66
|
+
* @param children
|
|
67
|
+
* @returns React.JSX.Element
|
|
68
|
+
*/
|
|
69
|
+
TSChartContext: ({ children }: TSChartContextProps) => React.JSX.Element;
|
|
70
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { VisualProps } from './common.types';
|
|
2
|
+
import {
|
|
3
|
+
CustomAxisMenuAction,
|
|
4
|
+
CustomContextMenuAction,
|
|
5
|
+
Query,
|
|
6
|
+
} from './ts-to-chart-event.types';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
*
|
|
@@ -25,9 +30,26 @@ export enum ChartToTSEvent {
|
|
|
25
30
|
RenderComplete = 'RenderComplete',
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
|
-
* Visual
|
|
33
|
+
* Visual props update
|
|
29
34
|
*/
|
|
30
35
|
UpdateVisualProps = 'UpdateVisualProps',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* TML events
|
|
39
|
+
*/
|
|
40
|
+
GetTMLString = 'GetTMLString',
|
|
41
|
+
SetTMLString = 'SetTMLString',
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Fetch data for custom query
|
|
45
|
+
*/
|
|
46
|
+
GetDataForQuery = 'GetDataForQuery',
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Tooltip events
|
|
50
|
+
*/
|
|
51
|
+
ShowToolTip = 'ShowToolTip',
|
|
52
|
+
HideToolTip = 'HideToolTip',
|
|
31
53
|
}
|
|
32
54
|
|
|
33
55
|
/**
|
|
@@ -74,13 +96,66 @@ export interface ChartToTSEventsPayloadMap {
|
|
|
74
96
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
75
97
|
*/
|
|
76
98
|
[ChartToTSEvent.UpdateVisualProps]: [UpdateVisualPropsEventPayload];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Trigger to get the TML string
|
|
102
|
+
*
|
|
103
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
104
|
+
*/
|
|
105
|
+
[ChartToTSEvent.GetTMLString]: [];
|
|
106
|
+
/**
|
|
107
|
+
* Trigger to set the TML string
|
|
108
|
+
*
|
|
109
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
110
|
+
*/
|
|
111
|
+
[ChartToTSEvent.SetTMLString]: [SetTMLStringEventPayload];
|
|
112
|
+
/**
|
|
113
|
+
* Trigger to get the data for custom query
|
|
114
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
115
|
+
*/
|
|
116
|
+
[ChartToTSEvent.GetDataForQuery]: [GetDataForQueryEventPayload];
|
|
117
|
+
/**
|
|
118
|
+
* Trigger to update the visual props
|
|
119
|
+
*
|
|
120
|
+
* @version SDK: 0.0.1-alpha.4 | ThoughtSpot:
|
|
121
|
+
*/
|
|
122
|
+
[ChartToTSEvent.ShowToolTip]: [ShowToolTipEventPayload];
|
|
123
|
+
/**
|
|
124
|
+
* Trigger to update the visual props
|
|
125
|
+
*
|
|
126
|
+
* @version SDK: 0.0.1-alpha.4 | ThoughtSpot:
|
|
127
|
+
*/
|
|
128
|
+
[ChartToTSEvent.HideToolTip]: [];
|
|
129
|
+
/**
|
|
130
|
+
* Trigger to open Axis Menu
|
|
131
|
+
*
|
|
132
|
+
* @version SDK: 0.0.1-alpha.7 | ThoughtSpot:
|
|
133
|
+
*/
|
|
134
|
+
[ChartToTSEvent.OpenAxisMenu]: [OpenAxisMenuEventPayload];
|
|
135
|
+
/**
|
|
136
|
+
* Trigger to close Axis Menu
|
|
137
|
+
*
|
|
138
|
+
* @version SDK: 0.0.1-alpha.7 | ThoughtSpot:
|
|
139
|
+
*/
|
|
140
|
+
[ChartToTSEvent.CloseAxisMenu]: [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @group Chart to ThoughtSpot Events
|
|
146
|
+
*/
|
|
147
|
+
export interface UpdateVisualPropsEventPayload {
|
|
148
|
+
visualProps: VisualProps;
|
|
77
149
|
}
|
|
78
150
|
|
|
79
151
|
/**
|
|
80
152
|
*
|
|
81
153
|
* @group Chart to ThoughtSpot Events
|
|
82
154
|
*/
|
|
83
|
-
|
|
155
|
+
export interface SetTMLStringEventPayload {
|
|
156
|
+
// TML string to be set
|
|
157
|
+
tmlString: string;
|
|
158
|
+
}
|
|
84
159
|
|
|
85
160
|
/**
|
|
86
161
|
* @group Chart to ThoughtSpot Events / Context Menu
|
|
@@ -132,14 +207,44 @@ export interface OpenContextMenuEventPayload {
|
|
|
132
207
|
}
|
|
133
208
|
// end - open context menu payload
|
|
134
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Payload for the event triggered to show a tooltip
|
|
212
|
+
*/
|
|
213
|
+
export interface ShowToolTipEventPayload {
|
|
214
|
+
/**
|
|
215
|
+
* The pointer event that triggered the tooltip display
|
|
216
|
+
* It includes the client's X and Y coordinates.
|
|
217
|
+
*/
|
|
218
|
+
event: Pick<PointerEvent, 'clientX' | 'clientY'>;
|
|
219
|
+
/**
|
|
220
|
+
* Optional custom content to display in the tooltip.
|
|
221
|
+
*/
|
|
222
|
+
customTooltipContent?: string[];
|
|
223
|
+
/**
|
|
224
|
+
* Information about the data point associated
|
|
225
|
+
* with the tooltip
|
|
226
|
+
* User can also include both point and customTooltipContent
|
|
227
|
+
* depending upon the requirement
|
|
228
|
+
*/
|
|
229
|
+
point?: Point;
|
|
230
|
+
}
|
|
231
|
+
// end - tooltip payload
|
|
232
|
+
|
|
135
233
|
/**
|
|
136
234
|
* @group Chart to ThoughtSpot Events
|
|
137
235
|
*/
|
|
138
|
-
interface RenderErrorEventPayload {
|
|
236
|
+
export interface RenderErrorEventPayload {
|
|
139
237
|
hasError: boolean;
|
|
140
238
|
error: any;
|
|
141
239
|
}
|
|
142
240
|
|
|
241
|
+
/**
|
|
242
|
+
* @group Chart to ThoughtSpot Events
|
|
243
|
+
*/
|
|
244
|
+
export interface GetDataForQueryEventPayload {
|
|
245
|
+
queries: Query[];
|
|
246
|
+
}
|
|
247
|
+
|
|
143
248
|
/**
|
|
144
249
|
*
|
|
145
250
|
* @group Chart to ThoughtSpot Events
|
|
@@ -147,3 +252,110 @@ interface RenderErrorEventPayload {
|
|
|
147
252
|
export enum ErrorType {
|
|
148
253
|
MultipleContextsNotSupported = 'MultipleContextsNotSupported',
|
|
149
254
|
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* List of supported actions for the menu items in the axis menu
|
|
258
|
+
* @group Chart to ThoughtSpot Events
|
|
259
|
+
*/
|
|
260
|
+
export enum AxisMenuActions {
|
|
261
|
+
/**
|
|
262
|
+
* Change the aggregation of the column from the possible options.
|
|
263
|
+
* Only supported for numeric columns.
|
|
264
|
+
*/
|
|
265
|
+
AGGREGATE = 'AGGREGATE',
|
|
266
|
+
/**
|
|
267
|
+
* Change the bucketing of the date or date time column from the possible options.
|
|
268
|
+
* Only supported for date or date time columns.
|
|
269
|
+
* */
|
|
270
|
+
TIME_BUCKET = 'TIME_BUCKET',
|
|
271
|
+
/**
|
|
272
|
+
* Add or update the filter for the column.
|
|
273
|
+
* */
|
|
274
|
+
FILTER = 'FILTER',
|
|
275
|
+
/**
|
|
276
|
+
* Sort the column in ascending or descending order.
|
|
277
|
+
* */
|
|
278
|
+
SORT = 'SORT',
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* These 2 methods are disabled currently as they are not supported by the backend.
|
|
282
|
+
* Following are the reasons for the same:
|
|
283
|
+
* 1. Remove is ambiguous as it can mean remove from the answer scope or remove from the chart.
|
|
284
|
+
* 2. Rename columns is not supported by the menu for now. If need be, this can be implemented.
|
|
285
|
+
*/
|
|
286
|
+
// /**
|
|
287
|
+
// * Rename the column.
|
|
288
|
+
// * */
|
|
289
|
+
// RENAME = 'RENAME',
|
|
290
|
+
// /**
|
|
291
|
+
// * Remove the column from the answer scope.
|
|
292
|
+
// * */
|
|
293
|
+
// REMOVE = 'REMOVE',
|
|
294
|
+
/**
|
|
295
|
+
* Defines a separator element between the actions.
|
|
296
|
+
* Can be added multiple times.
|
|
297
|
+
* */
|
|
298
|
+
SEPARATOR = 'SEPARATOR',
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface AxisMenuCustomAction {
|
|
302
|
+
/**
|
|
303
|
+
* ID of the custom action.
|
|
304
|
+
* */
|
|
305
|
+
id: string;
|
|
306
|
+
/**
|
|
307
|
+
* Label of the custom action.
|
|
308
|
+
* */
|
|
309
|
+
label: string;
|
|
310
|
+
/**
|
|
311
|
+
* Icon of the custom action.
|
|
312
|
+
* */
|
|
313
|
+
icon?: string;
|
|
314
|
+
/**
|
|
315
|
+
* Callback function that will be triggered when the custom action is clicked.
|
|
316
|
+
* */
|
|
317
|
+
onClick: (...args: any[]) => void;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface OpenAxisMenuEventPayload {
|
|
321
|
+
/**
|
|
322
|
+
* The pointer event that triggered the event to position the axis menu.
|
|
323
|
+
*/
|
|
324
|
+
event: Pick<PointerEvent, 'clientX' | 'clientY'>;
|
|
325
|
+
/**
|
|
326
|
+
* The column IDs of the columns that can be modified via the axis menu.
|
|
327
|
+
* This maps to the columns in chart model.
|
|
328
|
+
* The order of the column IDs is the same as the order of the columns in the axis menu.
|
|
329
|
+
* Atleast one column id is required.
|
|
330
|
+
* */
|
|
331
|
+
columnIds: string[];
|
|
332
|
+
/**
|
|
333
|
+
* The list of actions that are supported for the axis menu for each column.
|
|
334
|
+
* The order of the actions is the same as the order of the columns in the axis menu.
|
|
335
|
+
* If empty, all the supported actions in default order will be available.
|
|
336
|
+
* */
|
|
337
|
+
selectedActions?: AxisMenuActions[];
|
|
338
|
+
/**
|
|
339
|
+
* Custom action defined by the developer of the chart.
|
|
340
|
+
* This action will trigger the callback defined in the custom action payload.
|
|
341
|
+
* can be added multiple times.
|
|
342
|
+
* @hidden
|
|
343
|
+
* */
|
|
344
|
+
customActions?: AxisMenuCustomAction[];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
*
|
|
349
|
+
* @group Custom action callback mapping with action id/ Context Menu
|
|
350
|
+
*/
|
|
351
|
+
export interface ContextMenuActionHandler {
|
|
352
|
+
[key: string]: (args: CustomContextMenuAction) => void;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
*
|
|
357
|
+
* @group Custom action callback mapping with action id/ Axis Menu
|
|
358
|
+
*/
|
|
359
|
+
export interface AxisMenuActionHandler {
|
|
360
|
+
[key: string]: (args: CustomAxisMenuAction) => void;
|
|
361
|
+
}
|
|
@@ -160,12 +160,15 @@ export type VisualProps = JSON;
|
|
|
160
160
|
type CustomStylingConfig = any;
|
|
161
161
|
|
|
162
162
|
export interface AppConfig {
|
|
163
|
+
/**
|
|
164
|
+
* @hidden
|
|
165
|
+
*/
|
|
163
166
|
styleConfig?: CustomStylingConfig;
|
|
164
167
|
|
|
165
168
|
appOptions?: {
|
|
166
169
|
isMobile?: boolean;
|
|
167
170
|
isPrintMode?: boolean; // export mode on/off
|
|
168
|
-
|
|
171
|
+
isLiveboardContext?: boolean; // if chart renders in liveboard context
|
|
169
172
|
// runtime configurations
|
|
170
173
|
isDebugMode?: boolean; // enables debug mode for logging
|
|
171
174
|
};
|
|
@@ -177,8 +180,19 @@ export interface AppConfig {
|
|
|
177
180
|
sessionTimezone: string;
|
|
178
181
|
};
|
|
179
182
|
|
|
183
|
+
/**
|
|
184
|
+
* App url for the custom chart application where the chart app is hosted.
|
|
185
|
+
* This helps the chart developer to access app artifacts relative to this url.
|
|
186
|
+
* There can be different build systems that developers may have used and different ways
|
|
187
|
+
* to host the same. This helps in resolving the same.
|
|
188
|
+
*/
|
|
189
|
+
appUrl?: string;
|
|
190
|
+
|
|
180
191
|
// Idea: we might be able to map this to data and ask user to read data in a
|
|
181
192
|
// certain way the transformations for point during context menu operations
|
|
182
193
|
// need to be explored
|
|
194
|
+
/**
|
|
195
|
+
* @hidden
|
|
196
|
+
*/
|
|
183
197
|
customCalendarConfig?: any; // this is to initialize custom calendar service
|
|
184
198
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChartColumn } from './answer-column.types';
|
|
2
|
+
import { Point } from './chart-to-ts-event.types';
|
|
2
3
|
import {
|
|
3
4
|
AppConfig,
|
|
4
5
|
ChartConfig,
|
|
@@ -57,6 +58,16 @@ export enum TSToChartEvent {
|
|
|
57
58
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
58
59
|
*/
|
|
59
60
|
VisualPropsUpdate = 'VisualPropsUpdate',
|
|
61
|
+
/**
|
|
62
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
ContextMenuActionClick = 'ContextMenuActionClick',
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
69
|
+
*/
|
|
70
|
+
AxisMenuActionClick = 'AxisMenuActionClick',
|
|
60
71
|
}
|
|
61
72
|
|
|
62
73
|
/**
|
|
@@ -104,6 +115,14 @@ export interface TSToChartInternalEventsPayloadMap {
|
|
|
104
115
|
) => ValidationResponse;
|
|
105
116
|
|
|
106
117
|
[TSToChartEvent.TriggerRenderChart]: () => void;
|
|
118
|
+
|
|
119
|
+
[TSToChartEvent.ContextMenuActionClick]: (
|
|
120
|
+
payload: ContextMenuCustomActionPayload,
|
|
121
|
+
) => void;
|
|
122
|
+
|
|
123
|
+
[TSToChartEvent.AxisMenuActionClick]: (
|
|
124
|
+
payload: AxisMenuCustomActionPayload,
|
|
125
|
+
) => void;
|
|
107
126
|
}
|
|
108
127
|
|
|
109
128
|
/**
|
|
@@ -261,3 +280,54 @@ export interface ChartConfigValidateEventPayload {
|
|
|
261
280
|
*/
|
|
262
281
|
chartConfig: ChartConfig[];
|
|
263
282
|
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Custom action dispatched by context menu of the chart
|
|
286
|
+
*
|
|
287
|
+
* @group ThoughtSpot to Chart Events
|
|
288
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
289
|
+
*/
|
|
290
|
+
export interface CustomContextMenuAction {
|
|
291
|
+
id: string;
|
|
292
|
+
clickedPoint: Point;
|
|
293
|
+
selectedPoints?: Point[];
|
|
294
|
+
event: Pick<PointerEvent, 'clientX' | 'clientY'>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
*
|
|
299
|
+
* @group ThoughtSpot to Chart Events
|
|
300
|
+
*/
|
|
301
|
+
export interface ContextMenuCustomActionPayload {
|
|
302
|
+
/**
|
|
303
|
+
* Dispatched custom action from context menu
|
|
304
|
+
*
|
|
305
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
306
|
+
*/
|
|
307
|
+
customAction: CustomContextMenuAction;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Custom action dispatched by axis menu of the chart
|
|
312
|
+
*
|
|
313
|
+
* @group ThoughtSpot to Chart Events
|
|
314
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
315
|
+
*/
|
|
316
|
+
export interface CustomAxisMenuAction {
|
|
317
|
+
id: string;
|
|
318
|
+
columnIds: string[];
|
|
319
|
+
event: Pick<PointerEvent, 'clientX' | 'clientY'>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
*
|
|
324
|
+
* @group ThoughtSpot to Chart Events
|
|
325
|
+
*/
|
|
326
|
+
export interface AxisMenuCustomActionPayload {
|
|
327
|
+
/**
|
|
328
|
+
* Dispatched custom action from context menu
|
|
329
|
+
*
|
|
330
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
331
|
+
*/
|
|
332
|
+
customAction: CustomAxisMenuAction;
|
|
333
|
+
}
|