From 21eb36c93ba346d5c227642139a055a6e45914c9 Mon Sep 17 00:00:00 2001 From: xiezhongfu <458957068@qq.com> Date: Fri, 14 May 2021 23:57:38 +0800 Subject: [PATCH 1/2] feat(plugin-chart-echarts): opt funnel 1: force row_limit default value success by onInit function; 2: rm "show labels"; 3: rm label's textBorderColor; 4: rm "Funnel shape"; 5: rm "legend type" --- .../src/Funnel/controlPanel.tsx | 74 ++++--------------- .../src/Funnel/transformProps.ts | 1 + 2 files changed, 16 insertions(+), 59 deletions(-) diff --git a/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx b/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx index cfa20985c1..569864ffc0 100644 --- a/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx +++ b/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx @@ -20,23 +20,18 @@ import React from 'react'; import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core'; import { ControlPanelConfig, - ControlPanelsContainerProps, D3_FORMAT_OPTIONS, sections, sharedControls, + ControlStateMapping, } from '@superset-ui/chart-controls'; import { DEFAULT_FORM_DATA, EchartsFunnelLabelTypeType } from './types'; import { legendSection } from '../controls'; -const { - sort, - orient, - labelLine, - labelType, - numberFormat, - showLabels, - emitFilter, -} = DEFAULT_FORM_DATA; +const { labelType, numberFormat, showLabels, emitFilter } = DEFAULT_FORM_DATA; + +const funnelLegendSection = [...legendSection]; +funnelLegendSection.splice(2, 1); const config: ControlPanelConfig = { controlPanelSections: [ @@ -89,7 +84,7 @@ const config: ControlPanelConfig = { }, ] : [], - ...legendSection, + ...funnelLegendSection, // eslint-disable-next-line react/jsx-key [

{t('Labels')}

], [ @@ -140,57 +135,18 @@ const config: ControlPanelConfig = { }, }, ], - [ - { - name: 'label_line', - config: { - type: 'CheckboxControl', - label: t('Label Line'), - default: labelLine, - renderTrigger: true, - description: t('Draw line from Funnel to label when labels outside?'), - visibility: ({ controls }: ControlPanelsContainerProps) => - Boolean(controls?.show_labels?.value), - }, - }, - ], - // eslint-disable-next-line react/jsx-key - [

{t('Funnel shape')}

], - [ - { - name: 'sort', - config: { - type: 'SelectControl', - label: t('sort'), - default: sort, - renderTrigger: true, - choices: [ - [null, 'Default'], - ['ascending', 'Ascending'], - ['descending', 'Descending'], - ], - description: t('Sort data'), - }, - }, - { - name: 'orient', - config: { - type: 'SelectControl', - label: t('orient'), - default: orient, - renderTrigger: true, - choices: [ - [null, 'Default'], - ['vertical', 'Vertical'], - ['horizontal', 'Horizontal'], - ], - description: t('Funnel chart orientation. The options are vertical, horizontal'), - }, - }, - ], ], }, ], + onInit: function (state: ControlStateMapping) { + return { + ...state, + row_limit: { + ...state.row_limit, + value: state.row_limit.default, + }, + }; + }, }; export default config; diff --git a/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts b/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts index 0ebbbd76b7..5f15d84998 100644 --- a/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts +++ b/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts @@ -162,6 +162,7 @@ export default function transformProps( label: { ...defaultLabel, position: labelLine ? 'outer' : 'inner', + textBorderColor: 'transparent', }, emphasis: { label: { From a5b362c9cc861bbcdee43f3aeba6d3428a472836 Mon Sep 17 00:00:00 2001 From: xiezhongfu <458957068@qq.com> Date: Sat, 15 May 2021 00:35:59 +0800 Subject: [PATCH 2/2] fix(plugin-chart-echarts): fix method shorthand (object shorthand) --- plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx b/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx index 569864ffc0..decb173a88 100644 --- a/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx +++ b/plugins/plugin-chart-echarts/src/Funnel/controlPanel.tsx @@ -138,7 +138,7 @@ const config: ControlPanelConfig = { ], }, ], - onInit: function (state: ControlStateMapping) { + onInit(state: ControlStateMapping) { return { ...state, row_limit: {