Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(legacy-plugin-chart-sunburst): linear color scheme not work when secondary metric is provided #20221

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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