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.
feat: support tooltip and legend overrides (#101)
- Loading branch information
1 parent
3389048
commit 753f995
Showing
7 changed files
with
82 additions
and
42 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
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
12 changes: 3 additions & 9 deletions
12
...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,12 +1,6 @@ | ||
import { ChartFormData } from '@superset-ui/chart'; | ||
import { Margin } from '@superset-ui/dimension'; | ||
import { ChartTheme } from '@data-ui/theme'; | ||
import { Encoding } from './Encoder'; | ||
import { RenderingFormData } from './Line'; | ||
|
||
type LineFormData = ChartFormData & { | ||
encoding: Encoding; | ||
margin?: Margin; | ||
theme?: ChartTheme; | ||
}; | ||
type CombinedFormData = ChartFormData & RenderingFormData; | ||
|
||
export default LineFormData; | ||
export default CombinedFormData; |
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
32 changes: 26 additions & 6 deletions
32
...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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
import { pick } from 'lodash'; | ||
import { ChartProps } from '@superset-ui/chart'; | ||
import ChartFormData from './ChartFormData'; | ||
import { Hooks, RenderingFormData } from './Line'; | ||
|
||
/* eslint-disable sort-keys */ | ||
|
||
export default function transformProps(chartProps: ChartProps) { | ||
const { width, height, payload } = chartProps; | ||
const formData = chartProps.formData as ChartFormData; | ||
const { encoding, margin, theme } = formData; | ||
const { data } = payload; | ||
const formData = chartProps.formData as RenderingFormData; | ||
const hooks = chartProps.hooks as Hooks; | ||
|
||
/** | ||
* Use type-check to make sure the field names are expected ones | ||
* and only pick these fields to pass to the chart. | ||
*/ | ||
const fieldsFromFormData: (keyof RenderingFormData)[] = [ | ||
'commonEncoding', | ||
'encoding', | ||
'margin', | ||
'options', | ||
'theme', | ||
]; | ||
|
||
const fieldsFromHooks: (keyof Hooks)[] = [ | ||
'TooltipRenderer', | ||
'LegendGroupRenderer', | ||
'LegendItemRenderer', | ||
'LegendItemMarkRenderer', | ||
'LegendItemLabelRenderer', | ||
]; | ||
|
||
return { | ||
data, | ||
width, | ||
height, | ||
encoding, | ||
margin, | ||
theme, | ||
...pick(formData, fieldsFromFormData), | ||
...pick(hooks, fieldsFromHooks), | ||
}; | ||
} |