Embedded analytics SDK API
    Preparing search index...

    Interface SdkQuestionProps

    interface SdkQuestionProps {
        className?: string;
        dataPicker?: EmbeddingDataPicker;
        entityTypes?: EmbeddingEntityType[];
        height?: Height<string | number>;
        hiddenParameters?: string[];
        initialCollection?: SdkCollectionId;
        initialSqlParameters?: SqlParameterValues;
        isSaveEnabled?: boolean;
        onBeforeSave?: (
            question: MetabaseQuestion | undefined,
            context: { isNewQuestion: boolean },
        ) => Promise<void>;
        onNavigateBack?: () => void;
        onRun?: (question: MetabaseQuestion | undefined) => void;
        onSave?: (
            question: MetabaseQuestion,
            context: { dashboardTabId?: number; isNewQuestion: boolean },
        ) => void;
        onSqlParametersChange?: (payload: SqlParameterChangePayload) => void;
        onVisualizationChange?: (
            display:
                | "object"
                | "table"
                | "bar"
                | "line"
                | "pie"
                | "scalar"
                | "row"
                | "area"
                | "combo"
                | "pivot"
                | "smartscalar"
                | "gauge"
                | "progress"
                | "funnel"
                | "map"
                | "scatter"
                | "boxplot"
                | "waterfall"
                | "sankey"
                | "list",
        ) => void;
        plugins?: MetabasePluginsConfig;
        questionId?: SdkQuestionId
        | null;
        sqlParameters?: SqlParameterValues;
        style?: CSSProperties;
        targetCollection?: SdkCollectionId;
        title?: SdkQuestionTitleProps;
        token?: string | null;
        width?: Width<string | number>;
        withAlerts?: boolean;
        withChartTypeSelector?: boolean;
        withDownloads?: boolean;
        withEditorButton?: boolean;
    }
    Index

    Properties

    className?: string

    A custom class name to be added to the root element.

    dataPicker?: EmbeddingDataPicker

    Controls the menu for selecting data sources in questions. You can opt for the full data picker by setting dataPicker = "staged".

    entityTypes?: EmbeddingEntityType[]

    An array that specifies which entity types are available in the data picker

    height?: Height<string | number>

    A number or string specifying a CSS size value that specifies the height of the component

    hiddenParameters?: string[]

    A list of parameters to hide.

    initialCollection?: SdkCollectionId

    The collection to preselect in the save modal's collection picker. Unlike targetCollection, the picker remains visible and the user can choose a different collection. Ignored when targetCollection is set.

    initialSqlParameters?: SqlParameterValues

    Initial values for SQL parameters, slug-keyed. Applied once on mount; user widget edits afterwards are not reflected back to the host.
    For each parameter:

    • set to a value: that value is applied.
    • set to null: strictly cleared, ignoring the parameter's default.
    • omitted (or set to undefined): falls back to the parameter's default (or null if it has no default).
    isSaveEnabled?: boolean

    Whether to show the save button.

    onBeforeSave?: (
        question: MetabaseQuestion | undefined,
        context: { isNewQuestion: boolean },
    ) => Promise<void>

    A callback function that triggers before saving. Only relevant when isSaveEnabled = true

    onNavigateBack?: () => void

    A callback function that triggers when a user clicks the back button.

    onRun?: (question: MetabaseQuestion | undefined) => void

    A callback function that triggers when a question is updated, including when a user clicks the Visualize button in the question editor

    onSave?: (
        question: MetabaseQuestion,
        context: { dashboardTabId?: number; isNewQuestion: boolean },
    ) => void

    A callback function that triggers when a user saves the question. Only relevant when isSaveEnabled = true

    onSqlParametersChange?: (payload: SqlParameterChangePayload) => void

    Fires on SQL parameters change. The payload's source distinguishes the initial state on load ('initial-state'), user edits in the UI ('manual-change'), and auto-updates ('auto-change').

    onVisualizationChange?: (
        display:
            | "object"
            | "table"
            | "bar"
            | "line"
            | "pie"
            | "scalar"
            | "row"
            | "area"
            | "combo"
            | "pivot"
            | "smartscalar"
            | "gauge"
            | "progress"
            | "funnel"
            | "map"
            | "scatter"
            | "boxplot"
            | "waterfall"
            | "sankey"
            | "list",
    ) => void

    A callback function that triggers when the visualization type changes.

    Type Declaration

      • (
            display:
                | "object"
                | "table"
                | "bar"
                | "line"
                | "pie"
                | "scalar"
                | "row"
                | "area"
                | "combo"
                | "pivot"
                | "smartscalar"
                | "gauge"
                | "progress"
                | "funnel"
                | "map"
                | "scatter"
                | "boxplot"
                | "waterfall"
                | "sankey"
                | "list",
        ): void
      • Parameters

        • display:
              | "object"
              | "table"
              | "bar"
              | "line"
              | "pie"
              | "scalar"
              | "row"
              | "area"
              | "combo"
              | "pivot"
              | "smartscalar"
              | "gauge"
              | "progress"
              | "funnel"
              | "map"
              | "scatter"
              | "boxplot"
              | "waterfall"
              | "sankey"
              | "list"

          the new display type

        Returns void

    questionId?: SdkQuestionId | null
    sqlParameters?: SqlParameterValues

    Controlled SQL parameter values, slug-keyed. On every render, this object replaces the question's parameter values:

    • a parameter set to a value uses that value.
    • a parameter set to null is cleared, even if it has a default.
    • a parameter omitted from the object (or set to undefined) uses its default (or null if it has no default).

      Pair with onSqlParametersChange to stay in sync with user edits.

    A custom style object to be added to the root element.

    targetCollection?: SdkCollectionId

    The collection to save the question to. This will hide the collection picker from the save modal. Only applicable to interactive questions.

    Determines whether the question title is displayed, and allows a custom title to be displayed instead of the default question title. Shown by default.

    token?: string | null
    width?: Width<string | number>

    A number or string specifying a CSS size value that specifies the width of the component

    withAlerts?: boolean

    Enables the ability to set up alerts on the question.

    withChartTypeSelector?: boolean

    Determines whether the chart type selector and corresponding settings button are shown. Only relevant when using the default layout.

    withDownloads?: boolean

    Enables the ability to download results in the question.

    withEditorButton?: boolean

    Determines whether the editor button is shown. Only relevant when using the default layout.