Skip to content

Commit

Permalink
fix(legacy-preset-chart-nvd3): bar chart unexpected error (#1276)
Browse files Browse the repository at this point in the history
* fix(legacy-preset-chart-nvd3): bar chart unexpected error

* Add null checks
  • Loading branch information
kgabryje authored and zhaoyongjie committed Nov 26, 2021
1 parent e50f280 commit adff009
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
import { ensureIsArray, t, validateNonEmpty } from '@superset-ui/core';
import {
ColumnMeta,
ControlPanelConfig,
sections,
sharedControls,
} from '@superset-ui/chart-controls';
import {
showLegend,
showControls,
Expand Down Expand Up @@ -107,10 +112,24 @@ const config: ControlPanelConfig = {
groupby: {
label: t('Series'),
validators: [validateNonEmpty],
mapStateToProps: (state, controlState) => {
const groupbyProps = sharedControls.groupby.mapStateToProps?.(state, controlState) || {};
groupbyProps.canDropValue = (column: ColumnMeta) =>
!ensureIsArray(state.controls?.columns?.value).includes(column.column_name);
return groupbyProps;
},
rerender: ['columns'],
},
columns: {
label: t('Breakdowns'),
description: t('Defines how each series is broken down'),
mapStateToProps: (state, controlState) => {
const columnsProps = sharedControls.columns.mapStateToProps?.(state, controlState) || {};
columnsProps.canDropValue = (column: ColumnMeta) =>
!ensureIsArray(state.controls?.groupby?.value).includes(column.column_name);
return columnsProps;
},
rerender: ['groupby'],
},
},
};
Expand Down

0 comments on commit adff009

Please sign in to comment.