-
Notifications
You must be signed in to change notification settings - Fork 77
feat: update line chart tooltip and use selector #31
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": ".", | ||
"outDir": "./dist", | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": ["es6", "dom"], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"importHelpers": true, | ||
"jsx": "react", | ||
"lib": ["dom", "esnext"], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmitOnError": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": true, | ||
"importHelpers": true, | ||
"noUnusedLocals": true, | ||
"pretty": true, | ||
"removeComments": false, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"target": "esnext" | ||
}, | ||
"include": ["./storybook/stories/**/*", "../superset-ui-*/src/**/*", "./src/**/*", "./spec/**/*"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ import TooltipTable from '../components/tooltip/TooltipTable'; | |
import { Series, SeriesValue } from './Line'; | ||
import Encoder from './Encoder'; | ||
|
||
const MARK_STYLE = { marginRight: 4 }; | ||
|
||
export default function createTooltip(encoder: Encoder, allSeries: Series[]) { | ||
function LineTooltip({ | ||
datum, | ||
|
@@ -31,13 +33,24 @@ export default function createTooltip(encoder: Encoder, allSeries: Series[]) { | |
.filter(({ key }) => series[key]) | ||
.concat() | ||
.sort((a, b) => series[b.key].y - series[a.key].y) | ||
.map(({ key, color }) => ({ | ||
.map(({ key, color, strokeDasharray }) => ({ | ||
key, | ||
keyStyle: { | ||
color, | ||
fontWeight: series[key] === datum ? 600 : 200, | ||
}, | ||
value: encoder.channels.y.formatValue(series[key].y), | ||
keyColumn: ( | ||
<> | ||
<svg width="12" height="8" style={MARK_STYLE}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this glyph not match the legend? that seems ideal. it's tricky with the dashed line, tho. In that case I wonder if we should update the legend to be lines instead of circles or squares. wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps should update the legend to accept mark type and display line as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making the legend customizable seems like a good chunk of work itself. I will make it a follow-up PR. |
||
<line | ||
x2="12" | ||
y1="3" | ||
y2="3" | ||
stroke={color} | ||
strokeWidth="2" | ||
strokeDasharray={strokeDasharray} | ||
/> | ||
</svg> | ||
{series[key] === datum ? <b>{key}</b> : key} | ||
</> | ||
), | ||
valueColumn: encoder.channels.y.formatValue(series[key].y), | ||
}))} | ||
/> | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React, { CSSProperties, PureComponent } from 'react'; | ||
import React, { CSSProperties, PureComponent, ReactNode } from 'react'; | ||
|
||
type Props = { | ||
className?: string; | ||
data: { | ||
key: string; | ||
key: string | number; | ||
keyColumn: ReactNode; | ||
keyStyle?: CSSProperties; | ||
value: string | number; | ||
valueColumn: ReactNode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are there cases where this is not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to be flexible in case extra formatting is needed or there are unforeseen thing we want to put in the value column. Also to make it same with |
||
valueStyle?: CSSProperties; | ||
}[]; | ||
}; | ||
|
@@ -24,11 +25,11 @@ export default class TooltipTable extends PureComponent<Props, {}> { | |
return ( | ||
<table className={className}> | ||
<tbody> | ||
{data.map(({ key, keyStyle, value, valueStyle }) => ( | ||
{data.map(({ key, keyColumn, keyStyle, valueColumn, valueStyle }, i) => ( | ||
<tr key={key}> | ||
<td style={keyStyle}>{key}</td> | ||
<td style={keyStyle}>{keyColumn}</td> | ||
<td style={valueStyle ? { ...VALUE_CELL_STYLE, ...valueStyle } : VALUE_CELL_STYLE}> | ||
{value} | ||
{valueColumn} | ||
</td> | ||
</tr> | ||
))} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this file not generated by beemo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... true. The one in
demo
is somehow not generated and is also checked in.