forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename channel color to stroke (#100)
* refactor: rename channel color to stroke * fix: legend item color and types * feat: can override createTooltip * refactor: renderTooltip
- Loading branch information
1 parent
6cb8e28
commit 6f79361
Showing
13 changed files
with
126 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ export default [ | |
), | ||
}, | ||
}, | ||
color: { | ||
stroke: { | ||
field: 'name', | ||
type: 'nominal', | ||
legend: true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...lugins/superset-ui-plugins/packages/superset-ui-preset-chart-xy/src/Line/ChartFormData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { ChartFormData } from '@superset-ui/chart'; | ||
import { Margin } from '@superset-ui/dimension'; | ||
import { ChartTheme } from '@data-ui/theme'; | ||
import { Encoding } from './Encoder'; | ||
|
||
type LineFormData = ChartFormData & { | ||
encoding: Encoding; | ||
margin?: Margin; | ||
theme?: ChartTheme; | ||
}; | ||
|
||
export default LineFormData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
...ugins/superset-ui-plugins/packages/superset-ui-preset-chart-xy/src/Line/createTooltip.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ugins/superset-ui-plugins/packages/superset-ui-preset-chart-xy/src/Line/renderTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable no-magic-numbers */ | ||
|
||
import React from 'react'; | ||
import { chartTheme } from '@data-ui/theme'; | ||
import TooltipFrame from '../components/tooltip/TooltipFrame'; | ||
import TooltipTable from '../components/tooltip/TooltipTable'; | ||
import { TooltipInput } from './Line'; | ||
|
||
const MARK_STYLE = { marginRight: 4 }; | ||
|
||
export default function renderTooltip({ | ||
allSeries, | ||
datum, | ||
encoder, | ||
series = {}, | ||
theme = chartTheme, | ||
}: TooltipInput) { | ||
return ( | ||
<TooltipFrame> | ||
<> | ||
<div style={{ fontFamily: theme.labelStyles.fontFamily }}> | ||
<strong>{encoder.channels.x.formatValue(datum.x)}</strong> | ||
</div> | ||
<br /> | ||
{series && ( | ||
<TooltipTable | ||
data={allSeries | ||
.filter(({ key }) => series[key]) | ||
.concat() | ||
.sort((a, b) => series[b.key].y - series[a.key].y) | ||
.map(({ key, stroke, strokeDasharray }) => ({ | ||
key, | ||
keyColumn: ( | ||
<> | ||
<svg width="12" height="8" style={MARK_STYLE}> | ||
<line | ||
x2="12" | ||
y1="3" | ||
y2="3" | ||
stroke={stroke} | ||
strokeWidth="2" | ||
strokeDasharray={strokeDasharray} | ||
/> | ||
</svg> | ||
{series[key] === datum ? <b>{key}</b> : key} | ||
</> | ||
), | ||
valueColumn: encoder.channels.y.formatValue(series[key].y), | ||
}))} | ||
/> | ||
)} | ||
</> | ||
</TooltipFrame> | ||
); | ||
} |
4 changes: 3 additions & 1 deletion
4
...ugins/superset-ui-plugins/packages/superset-ui-preset-chart-xy/src/Line/transformProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.