fix: line chart tooltip when there is only one lien (#103)

* fix: line chart tooltip when there is only one lien

* fix: type

* fix: combine export default
This commit is contained in:
Krist Wongsuphasawat 2019-05-16 23:33:47 -07:00 committed by Yongjie Zhao
parent 04cd5802fb
commit de4c481685

View File

@ -10,7 +10,7 @@ import {
CrossHair, CrossHair,
WithTooltip, WithTooltip,
} from '@data-ui/xy-chart'; } from '@data-ui/xy-chart';
import { chartTheme, ChartTheme } from '@data-ui/theme'; import { chartTheme } from '@data-ui/theme';
import { Margin, Dimension } from '@superset-ui/dimension'; import { Margin, Dimension } from '@superset-ui/dimension';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
@ -35,7 +35,7 @@ export interface TooltipInput {
y: number; y: number;
}; };
}; };
theme: ChartTheme; theme: typeof chartTheme;
} }
const defaultProps = { const defaultProps = {
@ -48,7 +48,7 @@ const defaultProps = {
/** Part of formData that is needed for rendering logic in this file */ /** Part of formData that is needed for rendering logic in this file */
export type RenderingFormData = { export type RenderingFormData = {
margin?: Margin; margin?: Margin;
theme?: ChartTheme; theme?: typeof chartTheme;
} & PartialSpec<Encoding>; } & PartialSpec<Encoding>;
export type Hooks = { export type Hooks = {
@ -81,7 +81,7 @@ export interface SeriesValue {
const CIRCLE_STYLE = { strokeWidth: 1.5 }; const CIRCLE_STYLE = { strokeWidth: 1.5 };
class LineChart extends PureComponent<Props> { export default class LineChart extends PureComponent<Props> {
static defaultProps = defaultProps; static defaultProps = defaultProps;
encoder: Encoder; encoder: Encoder;
@ -119,7 +119,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.definition.field : key, key: key.length === 0 ? channels.y.getTitle() : key,
fill: channels.fill.encode(firstDatum, false), fill: channels.fill.encode(firstDatum, false),
stroke: channels.stroke.encode(firstDatum, '#222'), stroke: channels.stroke.encode(firstDatum, '#222'),
strokeDasharray: channels.strokeDasharray.encode(firstDatum, ''), strokeDasharray: channels.strokeDasharray.encode(firstDatum, ''),
@ -305,5 +305,3 @@ class LineChart extends PureComponent<Props> {
); );
} }
} }
export default LineChart;