@thoughtspot/ts-chart-sdk 0.0.1-alpha.3 → 0.0.1-alpha.6
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 +2 -1
- package/cjs/main/custom-chart-context.d.ts.map +1 -1
- package/cjs/main/custom-chart-context.js +10 -2
- package/cjs/main/custom-chart-context.js.map +1 -1
- package/cjs/main/custom-chart-context.spec.js +77 -0
- package/cjs/main/custom-chart-context.spec.js.map +1 -1
- package/cjs/react/custom-chart-context-hook.d.ts +22 -0
- package/cjs/react/custom-chart-context-hook.d.ts.map +1 -0
- package/cjs/react/custom-chart-context-hook.js +116 -0
- package/cjs/react/custom-chart-context-hook.js.map +1 -0
- package/cjs/react/custom-chart-context-hook.spec.d.ts +2 -0
- package/cjs/react/custom-chart-context-hook.spec.d.ts.map +1 -0
- package/cjs/react/custom-chart-context-hook.spec.js +343 -0
- package/cjs/react/custom-chart-context-hook.spec.js.map +1 -0
- package/cjs/react/custom-chart-context-service.d.ts +5 -16
- package/cjs/react/custom-chart-context-service.d.ts.map +1 -1
- package/cjs/react/custom-chart-context-service.js +34 -35
- package/cjs/react/custom-chart-context-service.js.map +1 -1
- package/cjs/react/custom-chart.spec.js +282 -53
- package/cjs/react/custom-chart.spec.js.map +1 -1
- package/cjs/react/mocks/custom-chart-context-hook.d.ts +3 -0
- package/cjs/react/mocks/custom-chart-context-hook.d.ts.map +1 -0
- package/cjs/react/mocks/custom-chart-context-hook.js +100 -0
- package/cjs/react/mocks/custom-chart-context-hook.js.map +1 -0
- 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 +102 -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 +12 -4
- package/cjs/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/cjs/types/chart-to-ts-event.types.js +2 -0
- package/cjs/types/chart-to-ts-event.types.js.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 +2 -1
- package/lib/main/custom-chart-context.d.ts.map +1 -1
- package/lib/main/custom-chart-context.js +10 -2
- package/lib/main/custom-chart-context.js.map +1 -1
- package/lib/main/custom-chart-context.spec.js +77 -0
- package/lib/main/custom-chart-context.spec.js.map +1 -1
- package/lib/react/custom-chart-context-hook.d.ts +22 -0
- package/lib/react/custom-chart-context-hook.d.ts.map +1 -0
- package/lib/react/custom-chart-context-hook.js +86 -0
- package/lib/react/custom-chart-context-hook.js.map +1 -0
- package/lib/react/custom-chart-context-hook.spec.d.ts +2 -0
- package/lib/react/custom-chart-context-hook.spec.d.ts.map +1 -0
- package/lib/react/custom-chart-context-hook.spec.js +315 -0
- package/lib/react/custom-chart-context-hook.spec.js.map +1 -0
- package/lib/react/custom-chart-context-service.d.ts +5 -16
- package/lib/react/custom-chart-context-service.d.ts.map +1 -1
- package/lib/react/custom-chart-context-service.js +34 -35
- package/lib/react/custom-chart-context-service.js.map +1 -1
- package/lib/react/custom-chart.spec.js +260 -54
- package/lib/react/custom-chart.spec.js.map +1 -1
- package/lib/react/mocks/custom-chart-context-hook.d.ts +3 -0
- package/lib/react/mocks/custom-chart-context-hook.d.ts.map +1 -0
- package/lib/react/mocks/custom-chart-context-hook.js +94 -0
- package/lib/react/mocks/custom-chart-context-hook.js.map +1 -0
- 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 +96 -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 +12 -4
- package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/lib/types/chart-to-ts-event.types.js +2 -0
- package/lib/types/chart-to-ts-event.types.js.map +1 -1
- package/package.json +8 -2
- package/src/index.ts +1 -0
- package/src/main/custom-chart-context.spec.ts +124 -0
- package/src/main/custom-chart-context.ts +24 -4
- package/src/react/mocks/custom-chart-context-mock.ts +116 -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 +47 -2
- 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
|
+
}
|
|
@@ -40,6 +40,16 @@ export enum ChartToTSEvent {
|
|
|
40
40
|
* Fetch data for custom query
|
|
41
41
|
*/
|
|
42
42
|
GetDataForQuery = 'GetDataForQuery',
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Show Tooltip events
|
|
46
|
+
*/
|
|
47
|
+
ShowToolTip = 'ShowToolTip',
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Hide Tooltip events
|
|
51
|
+
*/
|
|
52
|
+
HideToolTip = 'HideToolTip',
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
/**
|
|
@@ -104,13 +114,25 @@ export interface ChartToTSEventsPayloadMap {
|
|
|
104
114
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
105
115
|
*/
|
|
106
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]: [];
|
|
107
129
|
}
|
|
108
130
|
|
|
109
131
|
/**
|
|
110
132
|
*
|
|
111
133
|
* @group Chart to ThoughtSpot Events
|
|
112
134
|
*/
|
|
113
|
-
interface UpdateVisualPropsEventPayload {
|
|
135
|
+
export interface UpdateVisualPropsEventPayload {
|
|
114
136
|
visualProps: VisualProps;
|
|
115
137
|
}
|
|
116
138
|
|
|
@@ -173,10 +195,33 @@ export interface OpenContextMenuEventPayload {
|
|
|
173
195
|
}
|
|
174
196
|
// end - open context menu payload
|
|
175
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Payload for the event triggered to show a tooltip
|
|
200
|
+
*/
|
|
201
|
+
export interface ShowToolTipEventPayload {
|
|
202
|
+
/**
|
|
203
|
+
* The pointer event that triggered the tooltip display
|
|
204
|
+
* It includes the client's X and Y coordinates.
|
|
205
|
+
*/
|
|
206
|
+
event: Pick<PointerEvent, 'clientX' | 'clientY'>;
|
|
207
|
+
/**
|
|
208
|
+
* Optional custom content to display in the tooltip.
|
|
209
|
+
*/
|
|
210
|
+
customTooltipContent?: string[];
|
|
211
|
+
/**
|
|
212
|
+
* Information about the data point associated
|
|
213
|
+
* with the tooltip
|
|
214
|
+
* User can also include both point and customTooltipContent
|
|
215
|
+
* depending upon the requirement
|
|
216
|
+
*/
|
|
217
|
+
point?: Point;
|
|
218
|
+
}
|
|
219
|
+
// end - tooltip payload
|
|
220
|
+
|
|
176
221
|
/**
|
|
177
222
|
* @group Chart to ThoughtSpot Events
|
|
178
223
|
*/
|
|
179
|
-
interface RenderErrorEventPayload {
|
|
224
|
+
export interface RenderErrorEventPayload {
|
|
180
225
|
hasError: boolean;
|
|
181
226
|
error: any;
|
|
182
227
|
}
|
package/dist/ts-chart-sdk.d.ts
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle v0.7.3
|
|
2
|
-
|
|
3
|
-
export interface ChartConfigDimension {
|
|
4
|
-
key: string;
|
|
5
|
-
columns: ChartColumn[];
|
|
6
|
-
}
|
|
7
|
-
export interface ChartConfig {
|
|
8
|
-
key: string;
|
|
9
|
-
dimensions: ChartConfigDimension[];
|
|
10
|
-
}
|
|
11
|
-
export type DataArray = {
|
|
12
|
-
columnId: string;
|
|
13
|
-
columnDataType: DataType;
|
|
14
|
-
dataValue: any[];
|
|
15
|
-
};
|
|
16
|
-
export type QueryData = {
|
|
17
|
-
data: DataArray[];
|
|
18
|
-
completionRatio: number;
|
|
19
|
-
samplingRatio: number;
|
|
20
|
-
totalRowCount: number;
|
|
21
|
-
};
|
|
22
|
-
export interface ChartModel {
|
|
23
|
-
columns: ChartColumn[];
|
|
24
|
-
data?: QueryData[];
|
|
25
|
-
sortInfo?: any;
|
|
26
|
-
visualProps?: VisualProps;
|
|
27
|
-
config: {
|
|
28
|
-
chartConfig?: ChartConfig[];
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export type ValidationResponse = {
|
|
32
|
-
isValid: boolean;
|
|
33
|
-
validationErrorMessage?: string[];
|
|
34
|
-
};
|
|
35
|
-
export type VisualProps = JSON;
|
|
36
|
-
type CustomStylingConfig = any;
|
|
37
|
-
export interface AppConfig {
|
|
38
|
-
styleConfig?: CustomStylingConfig;
|
|
39
|
-
appOptions?: {
|
|
40
|
-
isMobile?: boolean;
|
|
41
|
-
isPrintMode?: boolean;
|
|
42
|
-
isDebugMode?: boolean;
|
|
43
|
-
};
|
|
44
|
-
localeOptions?: {
|
|
45
|
-
locale: string;
|
|
46
|
-
quarterStartMonth: string;
|
|
47
|
-
sessionTimezone: string;
|
|
48
|
-
};
|
|
49
|
-
customCalendarConfig?: any;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
52
|
-
|
|
53
|
-
export interface ChartConfigSection {
|
|
54
|
-
key: string;
|
|
55
|
-
label: string;
|
|
56
|
-
maxColumnCount?: number;
|
|
57
|
-
allowMeasureColumns?: boolean;
|
|
58
|
-
allowAttributeColumns?: boolean;
|
|
59
|
-
allowTimeSeriesColumns?: boolean;
|
|
60
|
-
}
|
|
61
|
-
export interface ChartConfigEditorDefinition {
|
|
62
|
-
key: string;
|
|
63
|
-
label?: string;
|
|
64
|
-
descriptionText?: string;
|
|
65
|
-
columnSections: ChartConfigSection[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface TextInputFormDetail {
|
|
69
|
-
type: 'text';
|
|
70
|
-
key: string;
|
|
71
|
-
label?: string;
|
|
72
|
-
password?: boolean;
|
|
73
|
-
multiline?: boolean;
|
|
74
|
-
placeholder?: string;
|
|
75
|
-
defaultValue?: string;
|
|
76
|
-
}
|
|
77
|
-
export interface ToggleFormDetail {
|
|
78
|
-
type: 'toggle';
|
|
79
|
-
key: string;
|
|
80
|
-
label?: string;
|
|
81
|
-
defaultValue?: boolean;
|
|
82
|
-
}
|
|
83
|
-
export interface CheckboxFormDetail {
|
|
84
|
-
type: 'checkbox';
|
|
85
|
-
key: string;
|
|
86
|
-
label?: string;
|
|
87
|
-
defaultValue?: boolean;
|
|
88
|
-
}
|
|
89
|
-
export interface RadioButtonFormDetail {
|
|
90
|
-
type: 'radio';
|
|
91
|
-
key: string;
|
|
92
|
-
label?: string;
|
|
93
|
-
defaultValue?: string;
|
|
94
|
-
values: string[];
|
|
95
|
-
}
|
|
96
|
-
export interface DropDownFormDetail {
|
|
97
|
-
type: 'dropdown';
|
|
98
|
-
key: string;
|
|
99
|
-
label?: string;
|
|
100
|
-
defaultValue?: string;
|
|
101
|
-
values: string[];
|
|
102
|
-
}
|
|
103
|
-
export interface Section {
|
|
104
|
-
type: 'section';
|
|
105
|
-
key: string;
|
|
106
|
-
label?: string;
|
|
107
|
-
children?: PropElement[];
|
|
108
|
-
alignment?: 'row' | 'column';
|
|
109
|
-
}
|
|
110
|
-
export type PropElement = Section | TextInputFormDetail | ToggleFormDetail | CheckboxFormDetail | RadioButtonFormDetail | DropDownFormDetail;
|
|
111
|
-
export interface VisualPropEditorDefinition {
|
|
112
|
-
elements: PropElement[];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export enum ColumnType {
|
|
116
|
-
UNKNOWN = 0,
|
|
117
|
-
MEASURE = 1,
|
|
118
|
-
ATTRIBUTE = 2
|
|
119
|
-
}
|
|
120
|
-
export enum DataType {
|
|
121
|
-
UNKNOWN = 0,
|
|
122
|
-
BOOL = 1,
|
|
123
|
-
CHAR = 2,
|
|
124
|
-
INT32 = 3,
|
|
125
|
-
INT64 = 4,
|
|
126
|
-
FLOAT = 5,
|
|
127
|
-
DOUBLE = 6,
|
|
128
|
-
DATE = 7,
|
|
129
|
-
DATE_TIME = 8,
|
|
130
|
-
TIME = 9,
|
|
131
|
-
MAX_TYPE = 10
|
|
132
|
-
}
|
|
133
|
-
export enum ColumnTimeBucket {
|
|
134
|
-
NO_BUCKET = 0,
|
|
135
|
-
DAILY = 1,
|
|
136
|
-
WEEKLY = 2,
|
|
137
|
-
MONTHLY = 3,
|
|
138
|
-
QUARTERLY = 4,
|
|
139
|
-
YEARLY = 5,
|
|
140
|
-
HOURLY = 6,
|
|
141
|
-
AUTO = 7,
|
|
142
|
-
HOUR_OF_DAY = 8,
|
|
143
|
-
DAY_OF_WEEK = 9,
|
|
144
|
-
DAY_OF_MONTH = 10,
|
|
145
|
-
DAY_OF_QUARTER = 11,
|
|
146
|
-
DAY_OF_YEAR = 12,
|
|
147
|
-
WEEK_OF_MONTH = 13,
|
|
148
|
-
WEEK_OF_QUARTER = 14,
|
|
149
|
-
WEEK_OF_YEAR = 15,
|
|
150
|
-
MONTH_OF_QUARTER = 16,
|
|
151
|
-
MONTH_OF_YEAR = 17,
|
|
152
|
-
QUARTER_OF_YEAR = 18
|
|
153
|
-
}
|
|
154
|
-
export enum FormatType {
|
|
155
|
-
NONE = 0,
|
|
156
|
-
PATTERN = 1,
|
|
157
|
-
PERCENTAGE = 2,
|
|
158
|
-
CURRENCY = 3
|
|
159
|
-
}
|
|
160
|
-
export enum CurrencyFormatType {
|
|
161
|
-
USER_LOCALE = 0,
|
|
162
|
-
COLUMN = 1,
|
|
163
|
-
ISO_CODE = 2
|
|
164
|
-
}
|
|
165
|
-
export interface CurrencyFormat {
|
|
166
|
-
type: CurrencyFormatType;
|
|
167
|
-
column: string;
|
|
168
|
-
isoCode: string;
|
|
169
|
-
}
|
|
170
|
-
export interface ColumnFormat {
|
|
171
|
-
type: FormatType;
|
|
172
|
-
pattern?: string;
|
|
173
|
-
currencyFormat?: CurrencyFormat;
|
|
174
|
-
}
|
|
175
|
-
export interface ChartColumn {
|
|
176
|
-
id: string;
|
|
177
|
-
name: string;
|
|
178
|
-
type: ColumnType;
|
|
179
|
-
timeBucket: ColumnTimeBucket;
|
|
180
|
-
dataType: DataType;
|
|
181
|
-
format?: ColumnFormat;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export enum ChartToTSEvent {
|
|
185
|
-
OpenContextMenu = "OpenContextMenu",
|
|
186
|
-
CloseContextMenu = "CloseContextMenu",
|
|
187
|
-
OpenAxisMenu = "OpenAxisMenu",
|
|
188
|
-
CloseAxisMenu = "CloseAxisMenu",
|
|
189
|
-
RenderStart = "RenderStart",
|
|
190
|
-
RenderError = "RenderError",
|
|
191
|
-
RenderComplete = "RenderComplete",
|
|
192
|
-
UpdateVisualProps = "UpdateVisualProps"
|
|
193
|
-
}
|
|
194
|
-
export interface ChartToTSEventsPayloadMap {
|
|
195
|
-
[ChartToTSEvent.OpenContextMenu]: OpenContextMenuEventPayload;
|
|
196
|
-
[ChartToTSEvent.CloseContextMenu]: null;
|
|
197
|
-
[ChartToTSEvent.RenderStart]: null;
|
|
198
|
-
[ChartToTSEvent.RenderComplete]: null;
|
|
199
|
-
[ChartToTSEvent.RenderError]: RenderErrorEventPayload;
|
|
200
|
-
[ChartToTSEvent.UpdateVisualProps]: UpdateVisualPropsEventPayload;
|
|
201
|
-
}
|
|
202
|
-
type UpdateVisualPropsEventPayload = VisualProps;
|
|
203
|
-
export interface PointVal {
|
|
204
|
-
columnId: string;
|
|
205
|
-
value: any;
|
|
206
|
-
}
|
|
207
|
-
export interface Point {
|
|
208
|
-
tuple: PointVal[];
|
|
209
|
-
}
|
|
210
|
-
export interface CustomAction {
|
|
211
|
-
id: string;
|
|
212
|
-
label: string;
|
|
213
|
-
icon: string;
|
|
214
|
-
onClick: (...args: any[]) => void;
|
|
215
|
-
}
|
|
216
|
-
export interface OpenContextMenuEventPayload {
|
|
217
|
-
event: Pick<PointerEvent, 'x' | 'y' | 'clientX' | 'clientY' | 'pageX' | 'pageY' | 'screenX' | 'screenY'>;
|
|
218
|
-
clickedPoint: Point;
|
|
219
|
-
selectedPoints?: Point[];
|
|
220
|
-
customActions?: CustomAction[];
|
|
221
|
-
}
|
|
222
|
-
interface RenderErrorEventPayload {
|
|
223
|
-
hasError: boolean;
|
|
224
|
-
error: any;
|
|
225
|
-
}
|
|
226
|
-
export enum ErrorType {
|
|
227
|
-
MultipleContextsNotSupported = "MultipleContextsNotSupported"
|
|
228
|
-
}
|
|
229
|
-
export {};
|
|
230
|
-
|
|
231
|
-
export enum TSToChartEvent {
|
|
232
|
-
Initialize = "Initialize",
|
|
233
|
-
GetDataQuery = "GetDataQuery",
|
|
234
|
-
ChartConfigValidate = "ChartConfigValidate",
|
|
235
|
-
ChartModelUpdate = "ChartModelUpdate",
|
|
236
|
-
DataUpdate = "DataUpdate",
|
|
237
|
-
TriggerRenderChart = "TriggerRenderChart",
|
|
238
|
-
VisualPropsValidate = "VisualPropsValidate",
|
|
239
|
-
VisualPropsUpdate = "VisualPropsUpdate"
|
|
240
|
-
}
|
|
241
|
-
export interface TSToChartEventsPayloadMap {
|
|
242
|
-
[TSToChartEvent.ChartModelUpdate]: (payload: ChartModelUpdateEventPayload) => void;
|
|
243
|
-
[TSToChartEvent.DataUpdate]: (payload: DataUpdateEventPayload) => void;
|
|
244
|
-
[TSToChartEvent.VisualPropsUpdate]: (payload: VisualPropsUpdateEventPayload) => void;
|
|
245
|
-
}
|
|
246
|
-
export interface TSToChartInternalEventsPayloadMap {
|
|
247
|
-
[TSToChartEvent.Initialize]: (payload: InitializeEventPayload) => InitializeEventResponsePayload;
|
|
248
|
-
[TSToChartEvent.GetDataQuery]: (payload: GetDataQueryPayload) => GetDataQueryResponsePayload;
|
|
249
|
-
[TSToChartEvent.ChartConfigValidate]: (payload: ChartConfigValidateEventPayload) => ValidationResponse;
|
|
250
|
-
[TSToChartEvent.VisualPropsValidate]: (payload: VisualPropsValidateEventPayload) => ValidationResponse;
|
|
251
|
-
[TSToChartEvent.TriggerRenderChart]: () => void;
|
|
252
|
-
}
|
|
253
|
-
export interface InitializeEventPayload {
|
|
254
|
-
chartModel: ChartModel;
|
|
255
|
-
appConfig?: AppConfig;
|
|
256
|
-
componentId: string;
|
|
257
|
-
hostUrl: string;
|
|
258
|
-
}
|
|
259
|
-
export interface InitializeEventResponsePayload {
|
|
260
|
-
isConfigValid: boolean;
|
|
261
|
-
defaultChartConfig: ChartConfig[];
|
|
262
|
-
chartConfigEditorDefinition?: ChartConfigEditorDefinition[];
|
|
263
|
-
visualPropEditorDefinition?: VisualPropEditorDefinition;
|
|
264
|
-
}
|
|
265
|
-
export interface GetDataQueryPayload {
|
|
266
|
-
config: ChartConfig[];
|
|
267
|
-
}
|
|
268
|
-
export interface Query {
|
|
269
|
-
queryColumns: ChartColumn[];
|
|
270
|
-
queryParams?: {
|
|
271
|
-
offset?: number;
|
|
272
|
-
size?: number;
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
export interface GetDataQueryResponsePayload {
|
|
276
|
-
queries: Query[];
|
|
277
|
-
}
|
|
278
|
-
export interface ChartModelUpdateEventPayload {
|
|
279
|
-
chartModel: ChartModel;
|
|
280
|
-
}
|
|
281
|
-
export interface DataUpdateEventPayload {
|
|
282
|
-
data: QueryData[];
|
|
283
|
-
}
|
|
284
|
-
export interface VisualPropsUpdateEventPayload {
|
|
285
|
-
visualProps: VisualProps;
|
|
286
|
-
}
|
|
287
|
-
export interface VisualPropsValidateEventPayload {
|
|
288
|
-
visualProps: VisualProps;
|
|
289
|
-
}
|
|
290
|
-
export interface ChartConfigValidateEventPayload {
|
|
291
|
-
chartConfig: ChartConfig[];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export type CustomChartContextProps = {
|
|
295
|
-
getDefaultChartConfig: (chartModel: ChartModel) => ChartConfig[];
|
|
296
|
-
getQueriesFromChartConfig: (chartConfig: ChartConfig[]) => Query[];
|
|
297
|
-
renderChart: (ctx: CustomChartContext) => Promise<void>;
|
|
298
|
-
validateConfig?: (updatedConfig: ChartConfig[], chartModel: ChartModel) => ValidationResponse;
|
|
299
|
-
validateVisualProps?: (updatedVisualProps: VisualProps, chartModel: ChartModel) => ValidationResponse;
|
|
300
|
-
chartConfigEditorDefinition?: ChartConfigEditorDefinition[];
|
|
301
|
-
visualPropEditorDefinition?: VisualPropEditorDefinition;
|
|
302
|
-
};
|
|
303
|
-
export class CustomChartContext {
|
|
304
|
-
constructor(chartContextProps: CustomChartContextProps);
|
|
305
|
-
initialize: () => Promise<void>;
|
|
306
|
-
on<T extends keyof TSToChartEventsPayloadMap>(eventType: T, callbackFn: TSToChartEventsPayloadMap[T]): void;
|
|
307
|
-
destroy(): void;
|
|
308
|
-
getChartModel: () => ChartModel;
|
|
309
|
-
emitEvent<T extends keyof ChartToTSEventsPayloadMap>(eventType: T, eventPayload: ChartToTSEventsPayloadMap[T]): Promise<any>;
|
|
310
|
-
}
|
|
311
|
-
export const getChartContext: (customChartConfig: CustomChartContextProps) => Promise<CustomChartContext>;
|
|
312
|
-
|