fix: gradient not working when y axis title has space (#98)

* fix: gradient not working when y axis title has space

* fix: pass theme

* fix: pass theme
This commit is contained in:
Krist Wongsuphasawat 2019-05-15 23:56:45 -07:00 committed by Yongjie Zhao
parent 9a98eb31db
commit 012f5165da
3 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
/* eslint-disable sort-keys, no-magic-numbers, complexity */ /* eslint-disable sort-keys, no-magic-numbers, complexity */
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { kebabCase, groupBy, flatMap, uniqueId, values } from 'lodash';
import { import {
AreaSeries, AreaSeries,
LinearGradient, LinearGradient,
@ -11,7 +12,7 @@ import {
} from '@data-ui/xy-chart'; } from '@data-ui/xy-chart';
import { chartTheme, ChartTheme } from '@data-ui/theme'; import { chartTheme, ChartTheme } from '@data-ui/theme';
import { Margin, Dimension } from '@superset-ui/dimension'; import { Margin, Dimension } from '@superset-ui/dimension';
import { groupBy, flatMap, uniqueId, values } from 'lodash';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import createTooltip from './createTooltip'; import createTooltip from './createTooltip';
import XYChartLayout from '../utils/XYChartLayout'; import XYChartLayout from '../utils/XYChartLayout';
@ -95,7 +96,7 @@ class LineChart extends PureComponent<Props> {
const firstDatum = seriesData[0]; const firstDatum = seriesData[0];
const key = fieldNames.map(f => firstDatum[f]).join(','); const key = fieldNames.map(f => firstDatum[f]).join(',');
const series: Series = { const series: Series = {
key: key.length === 0 ? channels.y.getTitle() : key, key: kebabCase(key.length === 0 ? channels.y.definition.field : key),
color: channels.color.encode(firstDatum, '#222'), color: channels.color.encode(firstDatum, '#222'),
fill: channels.fill.encode(firstDatum, false), fill: channels.fill.encode(firstDatum, false),
strokeDasharray: channels.strokeDasharray.encode(firstDatum, ''), strokeDasharray: channels.strokeDasharray.encode(firstDatum, ''),

View File

@ -4,7 +4,7 @@ import { ChartProps } from '@superset-ui/chart';
export default function transformProps(chartProps: ChartProps) { export default function transformProps(chartProps: ChartProps) {
const { width, height, formData, payload } = chartProps; const { width, height, formData, payload } = chartProps;
const { encoding, margin } = formData; const { encoding, margin, theme } = formData;
const { data } = payload; const { data } = payload;
return { return {
@ -13,5 +13,6 @@ export default function transformProps(chartProps: ChartProps) {
height, height,
encoding, encoding,
margin, margin,
theme,
}; };
} }

View File

@ -4,7 +4,7 @@ import { ChartProps } from '@superset-ui/chart';
export default function transformProps(chartProps: ChartProps) { export default function transformProps(chartProps: ChartProps) {
const { width, height, formData, payload } = chartProps; const { width, height, formData, payload } = chartProps;
const { encoding, commonEncoding, margin } = formData; const { encoding, commonEncoding, margin, theme } = formData;
const { data } = payload; const { data } = payload;
return { return {
@ -14,5 +14,6 @@ export default function transformProps(chartProps: ChartProps) {
encoding, encoding,
commonEncoding, commonEncoding,
margin, margin,
theme,
}; };
} }