Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
fix: dual line chart color consistency for secondary y axis (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored Mar 14, 2019
1 parent 2f35d0c commit 1ef0d68
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/superset-ui-legacy-preset-chart-nvd3/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => (
Expand All @@ -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',
Expand All @@ -28,4 +31,44 @@ export default [
storyName: 'Basic',
storyPath: 'legacy-|preset-chart-nvd3|DualLineChartPlugin',
},
{
renderStory: () => (
<div>
<SuperChart
chartType="dual-line"
chartProps={{
datasource: { verboseMap: {} },
formData: {
colorScheme: 'd3Category10',
vizType: 'dual_line',
xAxisFormat: 'smart_date',
yAxis2Format: '.3s',
yAxisFormat: '.3s',
},
height: 400,
payload: { data },
width: 400,
}}
/>
<SuperChart
chartType="dual-line"
chartProps={{
datasource: { verboseMap: {} },
formData: {
colorScheme: 'd3Category10',
vizType: 'dual_line',
xAxisFormat: 'smart_date',
yAxis2Format: '.3s',
yAxisFormat: '.3s',
},
height: 400,
payload: { data: reverseData },
width: 400,
}}
/>
</div>
),
storyName: 'Swap y-axis with consistent color',
storyPath: 'legacy-|preset-chart-nvd3|DualLineChartPlugin',
},
];

0 comments on commit 1ef0d68

Please sign in to comment.