import { Question, ItemValue, Event } from "survey-core"; import { IAnswersData, VisualizerBase } from "./visualizerBase"; import { FilterInfo } from "./filterInfo"; export interface ISelectBaseVisualizerOptions { /** * Allows users to toggle between absolute values and percentages in bar charts. Adds a **Show Percentages** button to each bar chart. * * Default value: `false` * @since 3.0.0 * @see showPercentages * @see showOnlyPercentages * @see percentagePrecision */ allowShowPercentages?: boolean; /** * Displays percentages alongside absolute values in bar charts. * * Default value: `false` * * Users can modify this setting in the UI if [`allowShowPercentages`](#allowShowPercentages) is enabled. * @see showOnlyPercentages * @see percentagePrecision */ showPercentages?: boolean; /** * Displays only percentages (without absolute values) in bar charts. Applies only if [`allowShowPercentages`](#allowShowPercentages) or [`showPercentages`](#showPercentages) is enabled. * * Default value: `false` * @see allowShowPercentages * @see showPercentages * @see percentagePrecision */ showOnlyPercentages?: boolean; /** * Number of decimal places used when displaying percentages. * * Default value: `2` * @since 3.0.0 * @see allowShowPercentages * @see showPercentages * @see showOnlyPercentages */ percentagePrecision?: number; /** * Enables sorting answers by response count in [bar charts](https://surveyjs.io/dashboard/documentation/chart-types#bar-chart) and [statistics tables](https://surveyjs.io/dashboard/documentation/chart-types#statistics-table). Adds a **Sorting** dropdown to each supported dashboard item. * * Default value: `true` * @since 3.0.0 * @see answersOrder */ allowSortAnswers?: boolean; /** * @deprecated Use the [`allowSortAnswers`](https://surveyjs.io/dashboard/documentation/api-reference/ivisualizationpaneloptions#allowSortAnswers) property instead. * @hidden * @since 3.0.0 */ allowChangeAnswersOrder?: boolean; /** * Specifies the answer sorting order in [bar charts](https://surveyjs.io/dashboard/documentation/chart-types#bar-chart) and [statistics tables](https://surveyjs.io/dashboard/documentation/chart-types#statistics-table). * * Accepted values: * * - `"default"` (default) – Preserve original order. * - `"asc"` – Sort by ascending response count. * - `"desc"` – Sort by descending response count. * * Users can modify this setting in the UI if [`allowSortAnswers`](#allowSortAnswers) is enabled. */ answersOrder?: "default" | "asc" | "desc"; /** * Enables hiding answers with zero responses in [bar charts](https://surveyjs.io/dashboard/documentation/chart-types#bar-chart) and [statistics tables](https://surveyjs.io/dashboard/documentation/chart-types#statistics-table). Adds a **Hide Empty Answers** button to each supported visualizer. * * Default value: `false` * @since 3.0.0 */ allowHideEmptyAnswers?: boolean; /** * Hides answers with zero responses in [bar charts](https://surveyjs.io/dashboard/documentation/chart-types#bar-chart) and [statistics tables](https://surveyjs.io/dashboard/documentation/chart-types#statistics-table). * * Default value: `false` * * Users can modify this setting in the UI if [`allowHideEmptyAnswers`](#allowHideEmptyAnswers) is enabled. */ hideEmptyAnswers?: boolean; /** * Enables selection of top 5, 10, or 20 answers by response count. Adds a **Top N Answers** dropdown to each chart. * * Default value: `false` * @since 3.0.0 */ allowTopNAnswers?: boolean; /** * Enables displaying the number of respondents who skipped a question. Adds a **Show Missing Answers** button to each chart. * * Default value: `false` * @since 3.0.0 */ allowShowMissingAnswers?: boolean; /** * Enables transposing data for matrix question visualizations. * * Adds a **Transpose** button to supported charts. * * - **Per Values** – Matrix rows become chart arguments, columns become series. * - **Per Columns** – Matrix rows become series, columns become arguments. * * Default value: `false` * @since 3.0.0 */ allowTransposeData?: boolean; /** * Default chart legend position. * * You can override this setting per dashboard item using the [`items`](#items) array. * @since 3.0.0 */ legendPosition?: "left" | "right" | "top" | "bottom"; } export interface IVisualizerWithSelection { selection: ItemValue; onDataItemSelected: (selectedValue: any, selectedText: string) => void; setSelection(item: ItemValue): void; } export declare function hideEmptyAnswersInData(answersData: IAnswersData): IAnswersData; export declare function dataListFormatter(model: SelectBase, text: string, value: string): string; export declare class SelectBase extends VisualizerBase implements IVisualizerWithSelection { protected selectedItem: ItemValue; private choicesOrderSelector; private showPercentageBtn; private emptyAnswersBtn; private transposeDataBtn; private topNSelector; private _showPercentages; private _showOnlyPercentages; private _percentagePrecision; protected _answersOrder: string; private _hideEmptyAnswers; private _topN; static topNValuesDefaults: number[]; topNValues: any[]; _legendPosition: "left" | "right" | "top" | "bottom"; protected _transposeData: boolean; private _showMissingAnswers; private missingAnswersBtn; protected filterInfo: FilterInfo; private initChartTypes; constructor(question: Question, data: Array<{ [index: string]: any; }>, options?: ISelectBaseVisualizerOptions, type?: string); protected chartTypes: string[]; protected _chartType: string; /** * Chart type - current chart type. */ get chartType(): string; set chartType(newChartType: string); private updateEmptyAnswersBtn; private updateTransposeDataBtn; private updateOrderSelector; private updateShowPercentageBtn; private updateTopNSelector; private updateMissingAnswersBtn; protected onChartTypeChanged(): void; protected setChartType(chartType: string): void; protected getCorrectAnswerText(): string; protected isSupportSoftUpdateContent(): boolean; protected softUpdateContent(): void; getSelectedItemByValue(value: any): ItemValue; getSelectedItemByText(itemText: string): any; protected onDataChanged(): void; protected onSelectionChanged(item: ItemValue): void; setSelection(item: ItemValue, quiet?: boolean): void; get selection(): ItemValue; /** * Gets and sets whether chart should show percentages only. */ get showOnlyPercentages(): boolean; set showOnlyPercentages(val: boolean); protected getShowPercentagesDefault(): boolean; get percentagePrecision(): number; /** * Gets and sets whether chart should show values and percentages. */ get showPercentages(): boolean; set showPercentages(val: boolean); /** * Gets and sets chart elements order. */ get answersOrder(): string; set answersOrder(value: string); /** * Set to true if need to hide empty chart elements (e.g. bars vith zero value). */ get hideEmptyAnswers(): boolean; set hideEmptyAnswers(value: boolean); get transposeData(): boolean; set transposeData(value: boolean); /** * Set to some value if need to show top N chart elements. */ get topN(): number; set topN(value: number); protected isSupportAnswersOrder(): boolean; protected isSupportMissingAnswers(): boolean; /** * Set to true if you want to see chart elements for missing answers (e.g. radiogroup items never been selected by surveyee). */ get showMissingAnswers(): boolean; set showMissingAnswers(value: boolean); get legendPosition(): "left" | "right" | "top" | "bottom"; set legendPosition(value: "left" | "right" | "top" | "bottom"); onDataItemSelected: (selectedValue: any, selectedText: string) => void; get showValuesInOriginalOrder(): boolean; valuesSource(): Array; getValues(): Array; getLabels(): Array; getPercentages(data: Array>): Array>; /** * Fires when answer data has been combined before they passed to draw graph. * options - the answers data object containing: datasets, labels, colors, additional texts (percentage). * options fields can be modified */ onAnswersDataReady: Event<(sender: SelectBase, options: any) => any, SelectBase, any>; /** * Returns object with all infotmation for data visualization: datasets, labels, colors, additional texts (percentage). */ getAnswersData(): Promise; protected transpose(data: Array>): Array>; private static _selectBaseDefaultState; getDefaultState(): any; getState(): any; protected setStateCore(state: any): void; resetState(): void; protected onThemeChanged(): void; getYAxisInfo(): {}[]; }