From 511b8e2de45caef884a8fabfcc11d3e8e6c98960 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Thu, 14 Mar 2019 16:35:52 -0700 Subject: [PATCH] fix: dual line chart color consistency for secondary y axis (#18) --- .../src/utils.js | 1 + .../DualLine/Stories.jsx | 47 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js index 0b7cb49f2b6a5..4c2d72ee39d45 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js @@ -33,6 +33,7 @@ export function cleanColorInput(value) { // for superset series that should have the same color return String(value) .trim() + .replace(' (right axis)', '') .split(', ') .filter(k => !TIME_SHIFT_PATTERN.test(k)) .join(', '); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-preset-chart-nvd3/DualLine/Stories.jsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-preset-chart-nvd3/DualLine/Stories.jsx index 6e6b92ad39117..4518e9dcbaae2 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-preset-chart-nvd3/DualLine/Stories.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-plugins-demo/storybook/stories/legacy-preset-chart-nvd3/DualLine/Stories.jsx @@ -3,6 +3,11 @@ import React from 'react'; import { SuperChart } from '@superset-ui/chart'; import data from './data'; +const reverseData = data.map(series => ({ + ...series, + yAxis: series.yAxis === 1 ? 2 : 1, +})); + export default [ { renderStory: () => ( @@ -12,8 +17,6 @@ export default [ datasource: { verboseMap: {} }, formData: { colorScheme: 'd3Category10', - metric: 'avg__num', - metric2: 'sum__num', vizType: 'dual_line', xAxisFormat: 'smart_date', yAxis2Format: '.3s', @@ -28,4 +31,44 @@ export default [ storyName: 'Basic', storyPath: 'legacy-|preset-chart-nvd3|DualLineChartPlugin', }, + { + renderStory: () => ( +
+ + +
+ ), + storyName: 'Swap y-axis with consistent color', + storyPath: 'legacy-|preset-chart-nvd3|DualLineChartPlugin', + }, ];