mirror of
https://github.com/apache/superset.git
synced 2024-09-19 20:19:37 -04:00
refactor: rename props
This commit is contained in:
parent
d3e140c3ae
commit
41fc7dc75c
@ -1,6 +1,6 @@
|
||||
import { ChartFormData } from '@superset-ui/chart';
|
||||
import { RenderingFormData } from './Line';
|
||||
import { FormDataProps } from './Line';
|
||||
|
||||
type CombinedFormData = ChartFormData & RenderingFormData;
|
||||
type CombinedFormData = ChartFormData & FormDataProps;
|
||||
|
||||
export default CombinedFormData;
|
||||
|
@ -3,7 +3,7 @@
|
||||
import React from 'react';
|
||||
import { TooltipFrame, TooltipTable } from '@superset-ui/chart-composition';
|
||||
import { chartTheme } from '@data-ui/theme';
|
||||
import { TooltipInput } from './Line';
|
||||
import { TooltipProps } from './Line';
|
||||
|
||||
const MARK_STYLE = { marginRight: 4 };
|
||||
|
||||
@ -13,7 +13,7 @@ export default function DefaultTooltipRenderer({
|
||||
encoder,
|
||||
series = {},
|
||||
theme = chartTheme,
|
||||
}: TooltipInput) {
|
||||
}: TooltipProps) {
|
||||
return (
|
||||
<TooltipFrame>
|
||||
<>
|
||||
|
@ -25,7 +25,7 @@ chartTheme.gridStyles.stroke = '#f1f3f5';
|
||||
|
||||
const DEFAULT_MARGIN = { top: 20, right: 20, left: 20, bottom: 20 };
|
||||
|
||||
export interface TooltipInput {
|
||||
export interface TooltipProps {
|
||||
encoder: Encoder;
|
||||
allSeries: Series[];
|
||||
datum: SeriesValue;
|
||||
@ -45,13 +45,13 @@ const defaultProps = {
|
||||
};
|
||||
|
||||
/** Part of formData that is needed for rendering logic in this file */
|
||||
export type RenderingFormData = {
|
||||
export type FormDataProps = {
|
||||
margin?: Margin;
|
||||
theme?: typeof chartTheme;
|
||||
} & PartialSpec<Encoding>;
|
||||
|
||||
export type Hooks = {
|
||||
TooltipRenderer?: React.ComponentType<TooltipInput>;
|
||||
export type HookProps = {
|
||||
TooltipRenderer?: React.ComponentType<TooltipProps>;
|
||||
} & LegendHooks<ChannelTypes>;
|
||||
|
||||
type Props = {
|
||||
@ -59,8 +59,8 @@ type Props = {
|
||||
width: string | number;
|
||||
height: string | number;
|
||||
data: Dataset;
|
||||
} & Hooks &
|
||||
RenderingFormData &
|
||||
} & HookProps &
|
||||
FormDataProps &
|
||||
Readonly<typeof defaultProps>;
|
||||
|
||||
export interface Series {
|
||||
|
@ -1,20 +1,20 @@
|
||||
import { pick } from 'lodash';
|
||||
import { ChartProps } from '@superset-ui/chart';
|
||||
import { Hooks, RenderingFormData } from './Line';
|
||||
import { HookProps, FormDataProps } from './Line';
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
export default function transformProps(chartProps: ChartProps) {
|
||||
const { width, height, payload } = chartProps;
|
||||
const { data } = payload;
|
||||
const formData = chartProps.formData as RenderingFormData;
|
||||
const hooks = chartProps.hooks as Hooks;
|
||||
const formData = chartProps.formData as FormDataProps;
|
||||
const hooks = chartProps.hooks as HookProps;
|
||||
|
||||
/**
|
||||
* 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)[] = [
|
||||
const fieldsFromFormData: (keyof FormDataProps)[] = [
|
||||
'commonEncoding',
|
||||
'encoding',
|
||||
'margin',
|
||||
@ -22,7 +22,7 @@ export default function transformProps(chartProps: ChartProps) {
|
||||
'theme',
|
||||
];
|
||||
|
||||
const fieldsFromHooks: (keyof Hooks)[] = [
|
||||
const fieldsFromHooks: (keyof HookProps)[] = [
|
||||
'TooltipRenderer',
|
||||
'LegendGroupRenderer',
|
||||
'LegendItemRenderer',
|
||||
|
Loading…
Reference in New Issue
Block a user