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

SDK support to disable and hide context menu actions #83

Merged
merged 6 commits into from
Jan 26, 2025
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
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
Loading