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

fix: dual line chart color consistency for secondary y axis #18

Merged
merged 1 commit into from
Mar 14, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
},
];