Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCAL-211470] add support for measure names and values #51

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thoughtspot/ts-chart-sdk",
"private": false,
"version": "0.0.2-alpha.8",
"version": "0.0.2-alpha.9",
"module": "lib/index",
"main": "lib/index",
"types": "lib/index",
Expand Down
1 change: 1 addition & 0 deletions src/main/custom-chart-context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ describe('CustomChartContext', () => {
allowedConfigurations: {
allowColumnNumberFormatting: false,
allowColumnConditionalFormatting: false,
allowMeasureNamesAndValues: false,
},
});
expect(mockPostMessageToHost).not.toHaveBeenCalled();
Expand Down
2 changes: 2 additions & 0 deletions src/main/custom-chart-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import _ from 'lodash';
import {

Check warning on line 10 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Dependency cycle via ./ts-to-chart-event.types:6
AxisMenuActionHandler,
ChartToTSEvent,
ChartToTSEventsPayloadMap,
Expand All @@ -25,7 +25,7 @@
ValidationResponse,
VisualProps,
} from '../types/common.types';
import {

Check warning on line 28 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Dependency cycle detected
ChartConfigEditorDefinition,
ConfigEditorDefinitionSetter,
} from '../types/configurator.types';
Expand All @@ -46,7 +46,7 @@
VisualPropsUpdateEventPayload,
VisualPropsValidateEventPayload,
} from '../types/ts-to-chart-event.types';
import {

Check warning on line 49 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Dependency cycle detected
VisualEditorDefinitionSetter,
VisualPropEditorDefinition,
} from '../types/visual-prop.types';
Expand All @@ -59,6 +59,7 @@
export type AllowedConfigurations = {
allowColumnNumberFormatting: boolean;
allowColumnConditionalFormatting: boolean;
allowMeasureNamesAndValues: boolean;
};

export type CustomChartContextProps = {
Expand Down Expand Up @@ -158,6 +159,7 @@
allowedConfigurations: {
allowColumnNumberFormatting: false,
allowColumnConditionalFormatting: false,
allowMeasureNamesAndValues: false,
},
};

Expand Down Expand Up @@ -277,7 +279,7 @@
* @version SDK: 0.1 | ThoughtSpot:
*/
public initialize = (): Promise<void> => {
console.log('Chart Context: initialization start');

Check warning on line 282 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
return this.hasInitializedPromise;
};

Expand Down Expand Up @@ -309,7 +311,7 @@
*/
public off<T extends keyof TSToChartEventsPayloadMap>(eventType: T): void {
if (_.isNil(this.eventListeners[eventType])) {
console.log('No event listener found to remove');

Check warning on line 314 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
this.eventListeners[eventType] = [];
return;
}
Expand Down Expand Up @@ -526,7 +528,7 @@
...eventPayload: ChartToTSEventsPayloadMap[T]
): Promise<any> {
if (!globalThis.isInitialized) {
console.log(

Check warning on line 531 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'Chart Context: not initialized the context, something went wrong',
);
return Promise.reject(new Error('Context not initialized'));
Expand All @@ -549,7 +551,7 @@
*/
private registerEventProcessor = () => {
if (globalThis.isInitialized) {
console.error(

Check warning on line 554 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'The context is already initialized. you cannot have multiple contexts',
);
throw new Error(ErrorType.MultipleContextsNotSupported);
Expand All @@ -565,7 +567,7 @@
* @param event : Message Event Object
*/
private eventProcessor = (data: any) => {
console.log('Chart Context: message received:', data.eventType, data);

Check warning on line 570 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

const messageResponse = this.executeEventListenerCBs(data);

Expand Down Expand Up @@ -726,7 +728,7 @@
isValid: true,
};
} catch (error: unknown) {
console.log(

Check warning on line 731 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'ContextMenuCustomAction: payload recieved:',
payload,
'CustomActionCallbackStore:',
Expand Down Expand Up @@ -769,7 +771,7 @@
isValid: true,
};
} catch (error: unknown) {
console.log(

Check warning on line 774 in src/main/custom-chart-context.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'AxisMenuCustomAction: payload recieved:',
payload,
'CustomActionCallbackStore:',
Expand Down
20 changes: 20 additions & 0 deletions src/types/answer-column.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ export enum ColumnType {
UNKNOWN,
MEASURE,
ATTRIBUTE,
// Virtual columns that are measure name/value columns
VIRTUAL,
}

/**
* When the column is generated for the chart for creating views,
* on top of measure columns from the worksheet which are part of answer query.
*/
export enum ChartSpecificColumnType {
UNKNOWN,
MEASURE_NAMES,
MEASURE_VALUES,
}

/**
Expand Down Expand Up @@ -249,4 +261,12 @@ export interface ChartColumn {
* @version SDK: 0.1 | ThoughtSpot: sdcwdc
*/
calenderGuid?: string;

/**
* Type of arbitrary column, can be measure names or measure values
* also, unknown if regular column
*
* @version SDK: 0.1 | ThoughtSpot:
*/
chartSpecificColumnType: ChartSpecificColumnType;
}
14 changes: 14 additions & 0 deletions src/types/configurator.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ export interface ChartConfigSection {
* @version SDK: 0.1 | ThoughtSpot:
*/
allowTimeSeriesColumns?: boolean;
/**
* Allow measure name Column on the Section
*
* @default true
* @version SDK: 0.1 | ThoughtSpot:
*/
allowMeasureNameColumn?: boolean;
/**
* Allow measure value Column on the Section
*
* @default true
* @version SDK: 0.1 | ThoughtSpot:
*/
allowMeasureValueColumn?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../../test/test-conditional-formatting-utils';
import {
ChartColumn,
ChartSpecificColumnType,
ColumnTimeBucket,
ColumnType,
DataType,
Expand Down Expand Up @@ -190,6 +191,7 @@ describe('getCfForColumn', () => {
id: 'col3',
name: '',
type: ColumnType.MEASURE,
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
timeBucket: ColumnTimeBucket.AUTO,
dataType: DataType.UNKNOWN,
columnProperties: {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/date-formatting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import {
ChartColumn,
ChartSpecificColumnType,
ColumnTimeBucket,
ColumnType,
DataType,
Expand All @@ -33,6 +34,7 @@ describe('date-formatting', () => {
id: 'testId',
name: 'test',
type: ColumnType.MEASURE,
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
timeBucket: ColumnTimeBucket.AUTO,
dataType: DataType.UNKNOWN,
calenderGuid: '12345',
Expand Down
Loading