Skip to content

Commit

Permalink
fix(plugin-chart-echarts): funnel chart improvements (apache#1110)
Browse files Browse the repository at this point in the history
* 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"

* fix(plugin-chart-echarts): fix method shorthand (object shorthand)
  • Loading branch information
xiezhongfu authored and zhaoyongjie committed Nov 25, 2021
1 parent 30d4324 commit 07d750a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -89,7 +84,7 @@ const config: ControlPanelConfig = {
},
]
: [],
...legendSection,
...funnelLegendSection,
// eslint-disable-next-line react/jsx-key
[<h1 className="section-header">{t('Labels')}</h1>],
[
Expand Down Expand Up @@ -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
[<h1 className="section-header">{t('Funnel shape')}</h1>],
[
{
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(state: ControlStateMapping) {
return {
...state,
row_limit: {
...state.row_limit,
value: state.row_limit.default,
},
};
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export default function transformProps(
label: {
...defaultLabel,
position: labelLine ? 'outer' : 'inner',
textBorderColor: 'transparent',
},
emphasis: {
label: {
Expand Down

0 comments on commit 07d750a

Please sign in to comment.