Skip to content

Commit

Permalink
fix(legacy-plugin-chart-sunburst): linear color scheme not work when …
Browse files Browse the repository at this point in the history
…secondary metric is provided (apache#20221)
  • Loading branch information
stephenLYZ authored and philipher29 committed Jun 9, 2022
1 parent 4c73ad8 commit 424af23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ function Sunburst(element, props) {
// For efficiency, filter nodes to keep only those large enough to see.
const nodes = partition.nodes(root).filter(d => d.dx > 0.005); // 0.005 radians = 0.29 degrees

if (metrics[0] !== metrics[1] && metrics[1] && !colorScheme) {
if (metrics[0] !== metrics[1] && metrics[1]) {
colorByCategory = false;
const ext = d3.extent(nodes, d => d.m2 / d.m1);
linearColorScale = getSequentialSchemeRegistry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
sections,
} from '@superset-ui/chart-controls';

const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -71,11 +75,21 @@ const config: ControlPanelConfig = {
description: t(
'When only a primary metric is provided, a categorical color scale is used.',
),
visibility: ({ controls }: ControlPanelsContainerProps) =>
Boolean(
!controls?.secondary_metric?.value ||
controls?.secondary_metric?.value === controls?.metric.value,
),
},
linear_color_scheme: {
description: t(
'When a secondary metric is provided, a linear color scale is used.',
),
visibility: ({ controls }: ControlPanelsContainerProps) =>
Boolean(
controls?.secondary_metric?.value &&
controls?.secondary_metric?.value !== controls?.metric.value,
),
},
groupby: {
label: t('Hierarchy'),
Expand Down

0 comments on commit 424af23

Please sign in to comment.