/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import React from 'react'; import { FeatureFlag, isFeatureEnabled, t, validateNonEmpty, } from '@superset-ui/core'; import { columnChoices, ControlPanelConfig, ControlPanelState, formatSelectOptionsForRange, sections, sharedControls, getStandardizedControls, } from '@superset-ui/chart-controls'; const sortAxisChoices = [ ['alpha_asc', t('Axis ascending')], ['alpha_desc', t('Axis descending')], ['value_asc', t('Metric ascending')], ['value_desc', t('Metric descending')], ]; const allColumns = { type: 'SelectControl', default: null, description: t('Columns to display'), mapStateToProps: (state: ControlPanelState) => ({ choices: columnChoices(state.datasource), }), validators: [validateNonEmpty], }; const dndAllColumns = { ...sharedControls.entity, description: t('Columns to display'), }; const columnsConfig = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP) ? dndAllColumns : allColumns; const config: ControlPanelConfig = { controlPanelSections: [ sections.legacyRegularTime, { label: t('Query'), expanded: true, controlSetRows: [ [ { name: 'all_columns_x', config: { ...columnsConfig, label: t('X Axis'), }, }, ], [ { name: 'all_columns_y', config: { ...columnsConfig, label: t('Y Axis'), }, }, ], ['metric'], ['adhoc_filters'], ['row_limit'], [ { name: 'sort_by_metric', config: { type: 'CheckboxControl', label: t('Sort by metric'), description: t( 'Whether to sort results by the selected metric in descending order.', ), }, }, ], ], }, { label: t('Heatmap Options'), expanded: true, tabOverride: 'customize', controlSetRows: [ ['linear_color_scheme'], [ { name: 'xscale_interval', config: { type: 'SelectControl', label: t('XScale Interval'), renderTrigger: true, choices: formatSelectOptionsForRange(1, 50), default: 1, clearable: false, description: t( 'Number of steps to take between ticks when displaying the X scale', ), }, }, ], [ { name: 'yscale_interval', config: { type: 'SelectControl', label: t('YScale Interval'), choices: formatSelectOptionsForRange(1, 50), default: 1, clearable: false, renderTrigger: true, description: t( 'Number of steps to take between ticks when displaying the Y scale', ), }, }, ], [ { name: 'canvas_image_rendering', config: { type: 'SelectControl', label: t('Rendering'), renderTrigger: true, choices: [ ['pixelated', t('pixelated (Sharp)')], ['auto', t('auto (Smooth)')], ], default: 'pixelated', description: t( 'image-rendering CSS attribute of the canvas object that ' + 'defines how the browser scales up the image', ), }, }, ], [ { name: 'normalize_across', config: { type: 'SelectControl', label: t('Normalize Across'), choices: [ ['heatmap', t('heatmap')], ['x', t('x')], ['y', t('y')], ], default: 'heatmap', description: ( <>