Skip to content

Commit

Permalink
fix: line chart tooltip when there is only one lien (#103)
Browse files Browse the repository at this point in the history
* fix: line chart tooltip when there is only one lien

* fix: type

* fix: combine export default
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 24, 2021
1 parent dcfae29 commit da2abc7
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CrossHair,
WithTooltip,
} 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 { createSelector } from 'reselect';
Expand All @@ -35,7 +35,7 @@ export interface TooltipInput {
y: number;
};
};
theme: ChartTheme;
theme: typeof chartTheme;
}

const defaultProps = {
Expand All @@ -48,7 +48,7 @@ const defaultProps = {
/** Part of formData that is needed for rendering logic in this file */
export type RenderingFormData = {
margin?: Margin;
theme?: ChartTheme;
theme?: typeof chartTheme;
} & PartialSpec<Encoding>;

export type Hooks = {
Expand Down Expand Up @@ -81,7 +81,7 @@ export interface SeriesValue {

const CIRCLE_STYLE = { strokeWidth: 1.5 };

class LineChart extends PureComponent<Props> {
export default class LineChart extends PureComponent<Props> {
static defaultProps = defaultProps;

encoder: Encoder;
Expand Down Expand Up @@ -119,7 +119,7 @@ class LineChart extends PureComponent<Props> {
const firstDatum = seriesData[0];
const key = fieldNames.map(f => firstDatum[f]).join(',');
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),
stroke: channels.stroke.encode(firstDatum, '#222'),
strokeDasharray: channels.strokeDasharray.encode(firstDatum, ''),
Expand Down Expand Up @@ -305,5 +305,3 @@ class LineChart extends PureComponent<Props> {
);
}
}

export default LineChart;

0 comments on commit da2abc7

Please sign in to comment.