Skip to content

Commit

Permalink
Merge pull request #83 from thoughtspot/feat/visible-hidden-disabled-…
Browse files Browse the repository at this point in the history
…context-menu-actions

SDK support to disable and hide context menu actions
  • Loading branch information
harshmeetTS authored Jan 26, 2025
2 parents e34db7b + 327f231 commit e81a470
Show file tree
Hide file tree
Showing 6 changed files with 1,096 additions and 12 deletions.
36 changes: 25 additions & 11 deletions example/custom-bar-chart/custom-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
VisualPropEditorDefinition,
VisualProps,
} from '@thoughtspot/ts-chart-sdk';
import { Action } from '@thoughtspot/ts-chart-sdk/lib/types/actions.types';
import { ChartConfigEditorDefinition } from '@thoughtspot/ts-chart-sdk/src';
import {
generateMapOptions,
Expand Down Expand Up @@ -340,27 +341,36 @@ function render(ctx: CustomChartContext) {
const currentVisualProps = JSON.parse(
JSON.stringify({
...chartModel.visualProps!,
// Assign updated client state values as string.
// Assign updated client state
// values as string.
clientState: JSON.stringify({
// JSON parse previous client state values from a string (if any, if not parse null object).
// JSON parse previous client
// state values from a string
// (if any, if not parse null
// object).
...JSON.parse(
(
chartModel.visualProps as {
clientState: string;
}
).clientState || '{}',
),
// Used to store any local state specific to chart, only string allowed.
// This will be preserved when you update visual props with an event.
// Assign new values to a client state using object rest destruct.
// Used to store any local state
// specific to chart, only
// string allowed. This will be
// preserved when you update
// visual props with an event.
// Assign new values to a client
// state using object rest
// destruct.
...exampleClientState,
// To assign, and update new value.
// id: 'new-chart-id',
// To assign, and update new
// value. id: 'new-chart-id',
}),
// this will throw warning in console, as this must
// be stringified.
// clientStateChart2: {
// ...chartModel.visualProps?.clientStateChart2,
// this will throw warning in
// console, as this must be
// stringified. clientStateChart2: {
// ...chartModel.visualProps?.clientStateChart2,
// ...exampleClientStatChart2,
// },
clientStateChart2: JSON.stringify({
Expand Down Expand Up @@ -618,6 +628,10 @@ const renderChart = async (ctx: CustomChartContext): Promise<void> => {
measureValueColumnAlias: 'Value',
},
batchSizeLimit: 20000,
customChartVisualConfig: {
customChartDisabledActions: [],
customChartHiddenActions: [Action.Download],
},
},
});

Expand Down
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": "1.1.1",
"version": "1.2.0",
"module": "lib/index",
"main": "lib/index",
"types": "lib/index",
Expand Down
8 changes: 8 additions & 0 deletions src/main/custom-chart-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
ChartModel,
SuccessValidationResponse,
ValidationResponse,
VisualConfig,
VisualProps,
} from '../types/common.types';
import {
Expand Down Expand Up @@ -173,6 +174,13 @@ export type ChartConfigParameters = {
* @version SDK: 0.1 | ThoughtSpot:
*/
batchSizeLimit?: number;
/**
* @description
* Optional parameter to control certain visual elements on the chart For example visibleAction
* array if Passed will only show those actions in context menu/Action menu of the chart on answer page
* @type {VisualConfig}
*/
customChartVisualConfig?: VisualConfig;
};

export type CustomChartContextProps = {
Expand Down
Loading

0 comments on commit e81a470

Please sign in to comment.