@thoughtspot/ts-chart-sdk 2.5.7 → 2.6.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/dist/ts-chart-sdk.d.ts +71 -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 +3 -1
- package/lib/main/custom-chart-context.d.ts.map +1 -1
- package/lib/main/custom-chart-context.js +46 -1
- package/lib/main/custom-chart-context.js.map +1 -1
- package/lib/main/custom-chart-context.spec.js +64 -1
- package/lib/main/custom-chart-context.spec.js.map +1 -1
- package/lib/react/mocks/custom-chart-context-mock.d.ts.map +1 -1
- package/lib/react/mocks/custom-chart-context-mock.js +3 -7
- package/lib/react/mocks/custom-chart-context-mock.js.map +1 -1
- package/lib/react/use-custom-chart-context.spec.js +67 -1
- package/lib/react/use-custom-chart-context.spec.js.map +1 -1
- package/lib/types/chart-to-ts-event.types.d.ts +27 -0
- package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/lib/types/chart-to-ts-event.types.js +7 -0
- package/lib/types/chart-to-ts-event.types.js.map +1 -1
- package/lib/types/common.types.d.ts +31 -1
- package/lib/types/common.types.d.ts.map +1 -1
- package/lib/types/common.types.js +11 -0
- package/lib/types/common.types.js.map +1 -1
- package/lib/types/conditional-formatting.types.d.ts +1 -0
- package/lib/types/conditional-formatting.types.d.ts.map +1 -1
- package/lib/types/conditional-formatting.types.js.map +1 -1
- package/lib/types/ts-to-chart-event.types.d.ts +6 -1
- 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/utils/chart-config.d.ts +8 -0
- package/lib/utils/chart-config.d.ts.map +1 -0
- package/lib/utils/chart-config.js +56 -0
- package/lib/utils/chart-config.js.map +1 -0
- package/lib/utils/chart-config.spec.d.ts +2 -0
- package/lib/utils/chart-config.spec.d.ts.map +1 -0
- package/lib/utils/chart-config.spec.js +574 -0
- package/lib/utils/chart-config.spec.js.map +1 -0
- package/package.json +2 -1
- package/src/index.ts +1 -0
- package/src/main/custom-chart-context.spec.ts +106 -1
- package/src/main/custom-chart-context.ts +69 -1
- package/src/react/mocks/custom-chart-context-mock.ts +4 -13
- package/src/react/use-custom-chart-context.spec.tsx +81 -1
- package/src/types/chart-to-ts-event.types.ts +86 -2
- package/src/types/common.types.ts +116 -7
- package/src/types/conditional-formatting.types.ts +1 -0
- package/src/types/ts-to-chart-event.types.ts +16 -1
- package/src/utils/chart-config.spec.ts +680 -0
- package/src/utils/chart-config.ts +100 -0
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
import _ from 'lodash';
|
|
8
8
|
import { mockInitializeContextPayload } from '../test/test-utils';
|
|
9
9
|
import { ColumnType } from '../types/answer-column.types';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ActionEventType,
|
|
12
|
+
ChartToTSEvent,
|
|
13
|
+
ErrorType,
|
|
14
|
+
OpenContextMenuEventPayload,
|
|
15
|
+
} from '../types/chart-to-ts-event.types';
|
|
11
16
|
import {
|
|
12
17
|
DownloadExcelTriggerPayload,
|
|
13
18
|
DownloadExcelTriggerResponse,
|
|
@@ -1595,6 +1600,7 @@ describe('CustomChartContext', () => {
|
|
|
1595
1600
|
selectedPoints: [{}],
|
|
1596
1601
|
});
|
|
1597
1602
|
});
|
|
1603
|
+
|
|
1598
1604
|
test('should process the event payload for axis menu custom actions', async () => {
|
|
1599
1605
|
const mockCustomAction = jest.fn();
|
|
1600
1606
|
let resolve: any;
|
|
@@ -1968,4 +1974,103 @@ describe('CustomChartContext', () => {
|
|
|
1968
1974
|
});
|
|
1969
1975
|
});
|
|
1970
1976
|
});
|
|
1977
|
+
|
|
1978
|
+
describe('showGlobalAlertToast', () => {
|
|
1979
|
+
let customChartContext: CustomChartContext;
|
|
1980
|
+
|
|
1981
|
+
beforeEach(() => {
|
|
1982
|
+
customChartContext = new CustomChartContext({
|
|
1983
|
+
getDefaultChartConfig,
|
|
1984
|
+
getQueriesFromChartConfig,
|
|
1985
|
+
renderChart,
|
|
1986
|
+
});
|
|
1987
|
+
eventProcessor({
|
|
1988
|
+
payload: mockInitializeContextPayload,
|
|
1989
|
+
eventType: TSToChartEvent.Initialize,
|
|
1990
|
+
});
|
|
1991
|
+
eventProcessor({
|
|
1992
|
+
payload: {},
|
|
1993
|
+
eventType: TSToChartEvent.InitializeComplete,
|
|
1994
|
+
});
|
|
1995
|
+
customChartContext.initialize();
|
|
1996
|
+
});
|
|
1997
|
+
|
|
1998
|
+
afterEach(() => {
|
|
1999
|
+
customChartContext.destroy();
|
|
2000
|
+
eventProcessor = null;
|
|
2001
|
+
jest.resetAllMocks();
|
|
2002
|
+
});
|
|
2003
|
+
|
|
2004
|
+
test('should process ShowGlobalAlertToast event and handle action click', async () => {
|
|
2005
|
+
const mockOnClick = jest.fn();
|
|
2006
|
+
const toastPayload = {
|
|
2007
|
+
alertMessage: 'Test message',
|
|
2008
|
+
primaryActionButton: {
|
|
2009
|
+
id: 'test-action',
|
|
2010
|
+
label: 'Test Action',
|
|
2011
|
+
onClick: mockOnClick,
|
|
2012
|
+
},
|
|
2013
|
+
};
|
|
2014
|
+
|
|
2015
|
+
customChartContext.emitEvent(
|
|
2016
|
+
ChartToTSEvent.ShowGlobalAlertToast,
|
|
2017
|
+
toastPayload,
|
|
2018
|
+
);
|
|
2019
|
+
|
|
2020
|
+
expect(mockPostMessageToHost).toHaveBeenCalledWith(
|
|
2021
|
+
mockInitializeContextPayload.componentId,
|
|
2022
|
+
mockInitializeContextPayload.hostUrl,
|
|
2023
|
+
{
|
|
2024
|
+
alertMessage: 'Test message',
|
|
2025
|
+
primaryActionButton: {
|
|
2026
|
+
id: 'test-action',
|
|
2027
|
+
label: 'Test Action',
|
|
2028
|
+
tooltip: undefined,
|
|
2029
|
+
type: undefined,
|
|
2030
|
+
},
|
|
2031
|
+
},
|
|
2032
|
+
ChartToTSEvent.ShowGlobalAlertToast,
|
|
2033
|
+
);
|
|
2034
|
+
|
|
2035
|
+
// Check if the handler is stored
|
|
2036
|
+
expect(
|
|
2037
|
+
(customChartContext as any).globalToastActionHandler[
|
|
2038
|
+
'test-action'
|
|
2039
|
+
],
|
|
2040
|
+
).toBe(mockOnClick);
|
|
2041
|
+
|
|
2042
|
+
// Simulate the action click from host
|
|
2043
|
+
await eventProcessor({
|
|
2044
|
+
eventType: TSToChartEvent.GlobalToastActionClick,
|
|
2045
|
+
payload: {
|
|
2046
|
+
alertAction: {
|
|
2047
|
+
id: 'test-action',
|
|
2048
|
+
},
|
|
2049
|
+
},
|
|
2050
|
+
});
|
|
2051
|
+
|
|
2052
|
+
expect(mockOnClick).toHaveBeenCalled();
|
|
2053
|
+
});
|
|
2054
|
+
|
|
2055
|
+
test('should process ShowGlobalAlertToast without primary action', () => {
|
|
2056
|
+
const toastPayload = {
|
|
2057
|
+
alertMessage: 'Test message without action',
|
|
2058
|
+
};
|
|
2059
|
+
|
|
2060
|
+
customChartContext.emitEvent(
|
|
2061
|
+
ChartToTSEvent.ShowGlobalAlertToast,
|
|
2062
|
+
toastPayload,
|
|
2063
|
+
);
|
|
2064
|
+
|
|
2065
|
+
expect(mockPostMessageToHost).toHaveBeenCalledWith(
|
|
2066
|
+
mockInitializeContextPayload.componentId,
|
|
2067
|
+
mockInitializeContextPayload.hostUrl,
|
|
2068
|
+
toastPayload,
|
|
2069
|
+
ChartToTSEvent.ShowGlobalAlertToast,
|
|
2070
|
+
);
|
|
2071
|
+
expect(
|
|
2072
|
+
(customChartContext as any).globalToastActionHandler,
|
|
2073
|
+
).toEqual({});
|
|
2074
|
+
});
|
|
2075
|
+
});
|
|
1971
2076
|
});
|
|
@@ -15,8 +15,10 @@ import {
|
|
|
15
15
|
CustomAction,
|
|
16
16
|
CustomActionMenuItemGroup,
|
|
17
17
|
ErrorType,
|
|
18
|
+
GlobalToastActionHandler,
|
|
18
19
|
OpenAxisMenuEventPayload,
|
|
19
20
|
OpenContextMenuEventPayload,
|
|
21
|
+
ShowGlobalAlertToastEventPayload,
|
|
20
22
|
} from '../types/chart-to-ts-event.types';
|
|
21
23
|
import {
|
|
22
24
|
AppConfig,
|
|
@@ -57,6 +59,7 @@ import {
|
|
|
57
59
|
VisualEditorDefinitionSetter,
|
|
58
60
|
VisualPropEditorDefinition,
|
|
59
61
|
} from '../types/visual-prop.types';
|
|
62
|
+
import { validateAllChartConfigs } from '../utils/chart-config';
|
|
60
63
|
import { setLocaleBasedStringFormats } from '../utils/number-formatting/number-formatting-utils';
|
|
61
64
|
import { create } from './logger';
|
|
62
65
|
import {
|
|
@@ -66,6 +69,7 @@ import {
|
|
|
66
69
|
} from './post-message-event-bridge';
|
|
67
70
|
|
|
68
71
|
const logger = create('TsChartSDKContext');
|
|
72
|
+
|
|
69
73
|
/**
|
|
70
74
|
* Configuration for allowing or disallowing specific TS UI features.
|
|
71
75
|
*
|
|
@@ -438,6 +442,8 @@ export class CustomChartContext {
|
|
|
438
442
|
*/
|
|
439
443
|
private axisMenuActionHandler: AxisMenuActionHandler = {};
|
|
440
444
|
|
|
445
|
+
private globalToastActionHandler: GlobalToastActionHandler = {};
|
|
446
|
+
|
|
441
447
|
public containerEl: HTMLElement | null = null;
|
|
442
448
|
|
|
443
449
|
/**
|
|
@@ -684,12 +690,41 @@ export class CustomChartContext {
|
|
|
684
690
|
return processedPayload;
|
|
685
691
|
}
|
|
686
692
|
|
|
693
|
+
/**
|
|
694
|
+
* Function to store the global toast primary action mapped with action id
|
|
695
|
+
* @param {[ShowGlobalAlertToastEventPayload]} eventPayload Event payload bound
|
|
696
|
+
* to the type of the event
|
|
697
|
+
* @returns payload
|
|
698
|
+
*/
|
|
699
|
+
public showGlobalAlertToastPreProcessor(
|
|
700
|
+
eventPayload: [ShowGlobalAlertToastEventPayload],
|
|
701
|
+
): [ShowGlobalAlertToastEventPayload] {
|
|
702
|
+
this.globalToastActionHandler = {};
|
|
703
|
+
if (!eventPayload?.[0]?.primaryActionButton) {
|
|
704
|
+
return eventPayload;
|
|
705
|
+
}
|
|
706
|
+
const primaryActionButtonProp = eventPayload?.[0]?.primaryActionButton;
|
|
707
|
+
this.globalToastActionHandler[primaryActionButtonProp.id] =
|
|
708
|
+
primaryActionButtonProp.onClick ?? _.noop;
|
|
709
|
+
return [
|
|
710
|
+
{
|
|
711
|
+
...eventPayload[0],
|
|
712
|
+
primaryActionButton: {
|
|
713
|
+
id: primaryActionButtonProp.id,
|
|
714
|
+
label: primaryActionButtonProp.label,
|
|
715
|
+
tooltip: primaryActionButtonProp.tooltip,
|
|
716
|
+
type: primaryActionButtonProp.type,
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
];
|
|
720
|
+
}
|
|
687
721
|
/**
|
|
688
722
|
* Function to process the event payload based on event type
|
|
689
723
|
* @param {ChartToTSEventsPayloadMap[T]} eventPayload Event payload bound
|
|
690
724
|
* to the type of the event
|
|
691
725
|
* @returns payload
|
|
692
726
|
*/
|
|
727
|
+
|
|
693
728
|
private eventPayloadPreProcessor<T extends keyof ChartToTSEventsPayloadMap>(
|
|
694
729
|
eventType: T,
|
|
695
730
|
eventPayload: ChartToTSEventsPayloadMap[T],
|
|
@@ -703,6 +738,10 @@ export class CustomChartContext {
|
|
|
703
738
|
return this.axisMenuCustomActionPreProcessor(
|
|
704
739
|
eventPayload as [OpenAxisMenuEventPayload],
|
|
705
740
|
) as ChartToTSEventsPayloadMap[T];
|
|
741
|
+
case ChartToTSEvent.ShowGlobalAlertToast:
|
|
742
|
+
return this.showGlobalAlertToastPreProcessor(
|
|
743
|
+
eventPayload as [ShowGlobalAlertToastEventPayload],
|
|
744
|
+
) as ChartToTSEventsPayloadMap[T];
|
|
706
745
|
default:
|
|
707
746
|
return eventPayload;
|
|
708
747
|
}
|
|
@@ -977,7 +1016,35 @@ export class CustomChartContext {
|
|
|
977
1016
|
'ContextMenuCustomAction: payload recieved:',
|
|
978
1017
|
payload,
|
|
979
1018
|
'CustomActionCallbackStore:',
|
|
980
|
-
this.
|
|
1019
|
+
this.contextMenuActionHandler,
|
|
1020
|
+
);
|
|
1021
|
+
return {
|
|
1022
|
+
isValid: false,
|
|
1023
|
+
error,
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
},
|
|
1027
|
+
);
|
|
1028
|
+
this.onInternal(
|
|
1029
|
+
TSToChartEvent.GlobalToastActionClick,
|
|
1030
|
+
(payload): { isValid: boolean; error?: unknown } => {
|
|
1031
|
+
try {
|
|
1032
|
+
const { id: customActionCallback } = payload.alertAction;
|
|
1033
|
+
const customActionCallbackArgs = {
|
|
1034
|
+
id: customActionCallback,
|
|
1035
|
+
};
|
|
1036
|
+
this.globalToastActionHandler[customActionCallback](
|
|
1037
|
+
customActionCallbackArgs,
|
|
1038
|
+
);
|
|
1039
|
+
return {
|
|
1040
|
+
isValid: true,
|
|
1041
|
+
};
|
|
1042
|
+
} catch (error: unknown) {
|
|
1043
|
+
logger.log(
|
|
1044
|
+
'GlobalToastActionClick: payload recieved:',
|
|
1045
|
+
payload,
|
|
1046
|
+
'GlobalToastActionClick:',
|
|
1047
|
+
this.globalToastActionHandler,
|
|
981
1048
|
);
|
|
982
1049
|
return {
|
|
983
1050
|
isValid: false,
|
|
@@ -1209,6 +1276,7 @@ export class CustomChartContext {
|
|
|
1209
1276
|
this.appConfig,
|
|
1210
1277
|
);
|
|
1211
1278
|
}
|
|
1279
|
+
validateAllChartConfigs(defaultChartConfig);
|
|
1212
1280
|
return {
|
|
1213
1281
|
isConfigValid: isValid,
|
|
1214
1282
|
defaultChartConfig,
|
|
@@ -3,6 +3,7 @@ import { CustomChartContextProps } from '../../main/custom-chart-context';
|
|
|
3
3
|
import { ColumnType } from '../../types/answer-column.types';
|
|
4
4
|
import { ChartConfig, ChartModel } from '../../types/common.types';
|
|
5
5
|
import { Query } from '../../types/ts-to-chart-event.types';
|
|
6
|
+
import { fetchQueryColumns } from '../../utils/chart-config';
|
|
6
7
|
|
|
7
8
|
export const contextChartProps: CustomChartContextProps = {
|
|
8
9
|
getDefaultChartConfig: (chartModel: ChartModel): ChartConfig[] => {
|
|
@@ -35,19 +36,9 @@ export const contextChartProps: CustomChartContextProps = {
|
|
|
35
36
|
},
|
|
36
37
|
getQueriesFromChartConfig: (chartConfig: ChartConfig[]): Array<Query> => {
|
|
37
38
|
const queries = chartConfig.map(
|
|
38
|
-
(config: ChartConfig): Query =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
(acc: Query, dimension) => ({
|
|
42
|
-
queryColumns: [
|
|
43
|
-
...acc.queryColumns,
|
|
44
|
-
...dimension.columns,
|
|
45
|
-
],
|
|
46
|
-
}),
|
|
47
|
-
{
|
|
48
|
-
queryColumns: [],
|
|
49
|
-
} as Query,
|
|
50
|
-
),
|
|
39
|
+
(config: ChartConfig): Query => ({
|
|
40
|
+
queryColumns: fetchQueryColumns(config),
|
|
41
|
+
}),
|
|
51
42
|
);
|
|
52
43
|
return queries;
|
|
53
44
|
},
|
|
@@ -5,6 +5,7 @@ import * as PostMessageEventBridge from '../main/post-message-event-bridge';
|
|
|
5
5
|
import { mockInitializeContextPayload } from '../test/test-utils';
|
|
6
6
|
import { ColumnType } from '../types/answer-column.types';
|
|
7
7
|
import { ChartToTSEvent } from '../types/chart-to-ts-event.types';
|
|
8
|
+
import { AxisType, ChartConfigMode } from '../types/common.types';
|
|
8
9
|
import { TSToChartEvent } from '../types/ts-to-chart-event.types';
|
|
9
10
|
import { contextChartProps } from './mocks/custom-chart-context-mock';
|
|
10
11
|
import { useChartContext } from './use-custom-chart-context';
|
|
@@ -71,7 +72,7 @@ describe('useChartContext initialization', () => {
|
|
|
71
72
|
});
|
|
72
73
|
});
|
|
73
74
|
|
|
74
|
-
test('should trigger getDataQuery and fetch correct query response', async () => {
|
|
75
|
+
test('should trigger getDataQuery and fetch correct query response for column driven dimension config', async () => {
|
|
75
76
|
// Render the hook with the custom chart context props
|
|
76
77
|
const { result, waitFor } = renderHook(() =>
|
|
77
78
|
useChartContext(contextChartProps),
|
|
@@ -131,6 +132,85 @@ describe('useChartContext initialization', () => {
|
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
134
|
|
|
135
|
+
test('should trigger getDataQuery and fetch correct query response for config driven dimension config', async () => {
|
|
136
|
+
// Render the hook with the custom chart context props
|
|
137
|
+
const { result, waitFor } = renderHook(() =>
|
|
138
|
+
useChartContext(contextChartProps),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// Assert that the context is not initialized initially
|
|
142
|
+
expect(result.current.hasInitialized).toBe(false);
|
|
143
|
+
expect(result.current.chartModel).toBeUndefined();
|
|
144
|
+
await eventProcessor({
|
|
145
|
+
payload: {
|
|
146
|
+
componentId: 'COMPONENT_ID',
|
|
147
|
+
hostUrl: 'https://some.chart.app',
|
|
148
|
+
chartModel: mockedChartModel,
|
|
149
|
+
},
|
|
150
|
+
eventType: TSToChartEvent.Initialize,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const response = await eventProcessor({
|
|
154
|
+
payload: {
|
|
155
|
+
config: [
|
|
156
|
+
{
|
|
157
|
+
key: 'column',
|
|
158
|
+
dimensions: [
|
|
159
|
+
{
|
|
160
|
+
key: 'x',
|
|
161
|
+
mode: ChartConfigMode.AXIS_DRIVEN,
|
|
162
|
+
axes: [
|
|
163
|
+
{
|
|
164
|
+
type: AxisType.FLAT,
|
|
165
|
+
column: mockedChartModel.columns[0],
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: 'y',
|
|
171
|
+
mode: ChartConfigMode.AXIS_DRIVEN,
|
|
172
|
+
axes: [
|
|
173
|
+
{
|
|
174
|
+
type: AxisType.MERGED,
|
|
175
|
+
columns: [
|
|
176
|
+
mockedChartModel.columns[1],
|
|
177
|
+
mockedChartModel.columns[2],
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
eventType: TSToChartEvent.GetDataQuery,
|
|
187
|
+
source: 'ts-host-app',
|
|
188
|
+
});
|
|
189
|
+
await eventProcessor({
|
|
190
|
+
payload: {},
|
|
191
|
+
eventType: TSToChartEvent.TriggerRenderChart,
|
|
192
|
+
source: 'ts-host-app',
|
|
193
|
+
});
|
|
194
|
+
await eventProcessor({
|
|
195
|
+
payload: {},
|
|
196
|
+
eventType: TSToChartEvent.InitializeComplete,
|
|
197
|
+
source: 'ts-host-app',
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
await waitFor(() => {
|
|
201
|
+
expect(response.queries[0].queryColumns[0]).toBe(
|
|
202
|
+
mockedChartModel.columns[0],
|
|
203
|
+
);
|
|
204
|
+
expect(response.queries[0].queryColumns[1]).toBe(
|
|
205
|
+
mockedChartModel.columns[1],
|
|
206
|
+
);
|
|
207
|
+
expect(response.queries[0].queryColumns[2]).toBe(
|
|
208
|
+
mockedChartModel.columns[2],
|
|
209
|
+
);
|
|
210
|
+
expect(result.current.hasInitialized).toBeTruthy();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
134
214
|
test('should make sure hasInitialized to remain false when context initialization failed', async () => {
|
|
135
215
|
jest.mock('../main/custom-chart-context', () => ({
|
|
136
216
|
CustomChartContext: jest.fn().mockImplementation(() => ({
|
|
@@ -57,6 +57,10 @@ export enum ChartToTSEvent {
|
|
|
57
57
|
*/
|
|
58
58
|
ShowToolTip = 'ShowToolTip',
|
|
59
59
|
HideToolTip = 'HideToolTip',
|
|
60
|
+
/**
|
|
61
|
+
* Global toast alert event
|
|
62
|
+
*/
|
|
63
|
+
ShowGlobalAlertToast = 'ShowGlobalAlertToast',
|
|
60
64
|
/**
|
|
61
65
|
* Label translation events.
|
|
62
66
|
*/
|
|
@@ -140,11 +144,17 @@ export interface ChartToTSEventsPayloadMap {
|
|
|
140
144
|
*/
|
|
141
145
|
[ChartToTSEvent.GetDataForQuery]: [GetDataForQueryEventPayload];
|
|
142
146
|
/**
|
|
143
|
-
* Trigger to update the
|
|
147
|
+
* Trigger to update the show tooltips
|
|
144
148
|
*
|
|
145
149
|
* @version SDK: 0.0.1-alpha.4 | ThoughtSpot:
|
|
146
150
|
*/
|
|
147
151
|
[ChartToTSEvent.ShowToolTip]: [ShowToolTipEventPayload];
|
|
152
|
+
/**
|
|
153
|
+
* Trigger to update the show toast alerts
|
|
154
|
+
*
|
|
155
|
+
* @version SDK: 0.0.1-alpha.4 | ThoughtSpot:
|
|
156
|
+
*/
|
|
157
|
+
[ChartToTSEvent.ShowGlobalAlertToast]: [ShowGlobalAlertToastEventPayload];
|
|
148
158
|
/**
|
|
149
159
|
* Trigger to update the visual props
|
|
150
160
|
*
|
|
@@ -199,6 +209,11 @@ export interface ChartToTSEventsPayloadMap {
|
|
|
199
209
|
*/
|
|
200
210
|
export interface UpdateVisualPropsEventPayload {
|
|
201
211
|
visualProps: VisualProps;
|
|
212
|
+
/**
|
|
213
|
+
* If passed true, the action is a system action
|
|
214
|
+
* and will not be considered in the history context
|
|
215
|
+
* */
|
|
216
|
+
isSystemAction?: boolean;
|
|
202
217
|
}
|
|
203
218
|
|
|
204
219
|
/**
|
|
@@ -335,7 +350,72 @@ export interface ShowToolTipEventPayload {
|
|
|
335
350
|
*/
|
|
336
351
|
point?: Point;
|
|
337
352
|
}
|
|
338
|
-
|
|
353
|
+
|
|
354
|
+
export enum ButtonType {
|
|
355
|
+
PRIMARY = 'primary',
|
|
356
|
+
SECONDARY = 'secondary',
|
|
357
|
+
TERTIARY = 'tertiary',
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface AlertActionButton {
|
|
361
|
+
/*
|
|
362
|
+
* ID of the user-defined action
|
|
363
|
+
*/
|
|
364
|
+
id: string;
|
|
365
|
+
/**
|
|
366
|
+
* Label for action button
|
|
367
|
+
*/
|
|
368
|
+
label: string;
|
|
369
|
+
/**
|
|
370
|
+
* Callback for when the user clicks on action button
|
|
371
|
+
*/
|
|
372
|
+
onClick?: () => any;
|
|
373
|
+
/**
|
|
374
|
+
* If the action button is disabled
|
|
375
|
+
*/
|
|
376
|
+
isDisabled?: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* i18ned Tooltip to show on the button
|
|
379
|
+
*/
|
|
380
|
+
tooltip?: string;
|
|
381
|
+
/**
|
|
382
|
+
* Type of button
|
|
383
|
+
* @default 'primary'
|
|
384
|
+
*/
|
|
385
|
+
type?: ButtonType;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface ShowGlobalAlertToastEventPayload {
|
|
389
|
+
/**
|
|
390
|
+
* i18n message that will be shown.
|
|
391
|
+
*
|
|
392
|
+
*/
|
|
393
|
+
alertMessage: string;
|
|
394
|
+
/**
|
|
395
|
+
* label translation id's defined in thoughtspot
|
|
396
|
+
*/
|
|
397
|
+
labelTranslation?: string;
|
|
398
|
+
/**
|
|
399
|
+
* enable close button in toast alert component.
|
|
400
|
+
* @default true
|
|
401
|
+
*/
|
|
402
|
+
showCloseButton?: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* want to show checkmark icon in Toast by default set to `true`.
|
|
405
|
+
* @default true
|
|
406
|
+
*/
|
|
407
|
+
showCheckmarkIcon?: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Whether or not to auto hide the alert after a delay (4.8s)
|
|
410
|
+
*
|
|
411
|
+
* @default true
|
|
412
|
+
*/
|
|
413
|
+
autoHide?: boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Show a primary button with callback
|
|
416
|
+
*/
|
|
417
|
+
primaryActionButton?: AlertActionButton;
|
|
418
|
+
}
|
|
339
419
|
|
|
340
420
|
/**
|
|
341
421
|
* @group Chart to ThoughtSpot Events
|
|
@@ -492,3 +572,7 @@ export interface ContextMenuActionHandler {
|
|
|
492
572
|
export interface AxisMenuActionHandler {
|
|
493
573
|
[key: string]: (args: CustomAxisMenuAction) => void;
|
|
494
574
|
}
|
|
575
|
+
|
|
576
|
+
export interface GlobalToastActionHandler {
|
|
577
|
+
[key: string]: (args: any) => void;
|
|
578
|
+
}
|
|
@@ -59,14 +59,78 @@ export enum CustomizableChartFeature {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
* Associated with the key defined in the chart config editor definition
|
|
64
|
-
* Relates to ChartConfigSection
|
|
62
|
+
* Enum to indicate the type of dimension config
|
|
65
63
|
*
|
|
66
|
-
* @version SDK: 0
|
|
64
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
65
|
+
* @group Chart Model
|
|
66
|
+
*/
|
|
67
|
+
export enum AxisType {
|
|
68
|
+
FLAT = 'flat',
|
|
69
|
+
MERGED = 'merged',
|
|
70
|
+
DUAL = 'dual',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Flat axis config: single column, unmodified.
|
|
75
|
+
*
|
|
76
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
67
77
|
* @group Chart Model
|
|
68
78
|
*/
|
|
69
|
-
export interface
|
|
79
|
+
export interface FlatAxis {
|
|
80
|
+
type: AxisType.FLAT;
|
|
81
|
+
/** Single column for this axis slot */
|
|
82
|
+
column: ChartColumn;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Merged axis config: multiple columns combined into one logical series.
|
|
87
|
+
*
|
|
88
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
89
|
+
* @group Chart Model
|
|
90
|
+
*/
|
|
91
|
+
export interface MergedAxis {
|
|
92
|
+
type: AxisType.MERGED;
|
|
93
|
+
/** Columns that are merged into one axis slot */
|
|
94
|
+
columns: ChartColumn[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Dual axis config: primary and secondary axis, each can be flat or merged.
|
|
99
|
+
*
|
|
100
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
101
|
+
* @group Chart Model
|
|
102
|
+
*/
|
|
103
|
+
export interface DualAxis {
|
|
104
|
+
type: AxisType.DUAL;
|
|
105
|
+
/** Primary axis config (flat or merged) */
|
|
106
|
+
primary: FlatAxis | MergedAxis;
|
|
107
|
+
/** Secondary axis config (flat or merged) */
|
|
108
|
+
secondary: FlatAxis | MergedAxis;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Union of all supported axis types for a dimension.
|
|
113
|
+
*/
|
|
114
|
+
export type AxisConfig = FlatAxis | MergedAxis | DualAxis;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Enum to indicate whether dimension config uses columns or structured config
|
|
118
|
+
*
|
|
119
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
120
|
+
* @group Chart Model
|
|
121
|
+
*/
|
|
122
|
+
export enum ChartConfigMode {
|
|
123
|
+
COLUMN_DRIVEN = 'COLUMN_DRIVEN',
|
|
124
|
+
AXIS_DRIVEN = 'AXIS_DRIVEN',
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Column driven dimension config: single column or multiple columns.
|
|
129
|
+
*
|
|
130
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
131
|
+
* @group Chart Model
|
|
132
|
+
*/
|
|
133
|
+
export interface ColumnDrivenChartConfigDimension {
|
|
70
134
|
/**
|
|
71
135
|
* Key for the dimension in the chart config
|
|
72
136
|
*
|
|
@@ -74,13 +138,58 @@ export interface ChartConfigDimension {
|
|
|
74
138
|
*/
|
|
75
139
|
key: string;
|
|
76
140
|
/**
|
|
77
|
-
*
|
|
141
|
+
* Mode of the chart config
|
|
78
142
|
*
|
|
79
|
-
* @version SDK: 0
|
|
143
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
144
|
+
*/
|
|
145
|
+
mode?: ChartConfigMode.COLUMN_DRIVEN;
|
|
146
|
+
/**
|
|
147
|
+
* List of columns added for the dimension
|
|
148
|
+
* If chart config mode is COLUMN_DRIVEN, this is required
|
|
149
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
80
150
|
*/
|
|
81
151
|
columns: ChartColumn[];
|
|
82
152
|
}
|
|
83
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Axis driven dimension config: multiple axes, each can be flat or merged.
|
|
156
|
+
*
|
|
157
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
158
|
+
* @group Chart Model
|
|
159
|
+
*/
|
|
160
|
+
export interface AxisDrivenChartConfigDimension {
|
|
161
|
+
/**
|
|
162
|
+
* Key for the dimension in the chart config
|
|
163
|
+
*
|
|
164
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
165
|
+
*/
|
|
166
|
+
key: string;
|
|
167
|
+
/**
|
|
168
|
+
* Mode of the chart config
|
|
169
|
+
*
|
|
170
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
171
|
+
*/
|
|
172
|
+
mode: ChartConfigMode.AXIS_DRIVEN;
|
|
173
|
+
/**
|
|
174
|
+
* Axis config of the dimension
|
|
175
|
+
*
|
|
176
|
+
* @version SDK: 2.6.0 | ThoughtSpot:
|
|
177
|
+
*/
|
|
178
|
+
axes: AxisConfig[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* List of Columns for a dimension in the Custom Chart Config.
|
|
183
|
+
* Associated with the key defined in the chart config editor definition
|
|
184
|
+
* Relates to ChartConfigSection
|
|
185
|
+
*
|
|
186
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
187
|
+
* @group Chart Model
|
|
188
|
+
*/
|
|
189
|
+
export type ChartConfigDimension =
|
|
190
|
+
| ColumnDrivenChartConfigDimension
|
|
191
|
+
| AxisDrivenChartConfigDimension;
|
|
192
|
+
|
|
84
193
|
/**
|
|
85
194
|
* Custom Chart Config values stored in the metadata
|
|
86
195
|
* Relates to ChartConfigEditorDefinition
|
|
@@ -34,6 +34,7 @@ export type GradientBackgroundAttrs = {
|
|
|
34
34
|
backgroundFormatMidpoint?: Maybe<Scalars['Float']>;
|
|
35
35
|
backgroundFormatRange?: Maybe<Array<Maybe<Scalars['Float']>>>;
|
|
36
36
|
colors?: Maybe<Array<Maybe<Scalars['String']>>>;
|
|
37
|
+
isAutoScaled?: Maybe<Scalars['Boolean']>;
|
|
37
38
|
};
|
|
38
39
|
export enum Operators {
|
|
39
40
|
Contains = 'CONTAINS',
|