From 1903d07bf55172ac3c19d113c65351ba464e6e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=A2=E4=B8=98?= Date: Wed, 15 Feb 2023 17:46:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20gauge=20=E6=94=AF=E6=8C=81=20view=20?= =?UTF-8?q?=E7=9A=84=20props=20ts=20=E7=B1=BB=E5=9E=8B=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/f2/src/components/gauge/gaugeView.tsx | 12 ++---------- packages/f2/src/components/gauge/index.tsx | 8 ++++---- packages/f2/src/components/gauge/withGauge.tsx | 11 +++++++---- packages/f2/src/components/index.ts | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/f2/src/components/gauge/gaugeView.tsx b/packages/f2/src/components/gauge/gaugeView.tsx index 2208bb1fe..411822498 100644 --- a/packages/f2/src/components/gauge/gaugeView.tsx +++ b/packages/f2/src/components/gauge/gaugeView.tsx @@ -1,4 +1,5 @@ import { jsx } from '@antv/f-engine'; +import { GaugeProps } from './withGauge'; export interface Point { x: number; @@ -11,16 +12,7 @@ export interface Tick { end: Point; } -export interface GaugeViewProps { - center: Point; - startAngle: number; - endAngle: number; - r: number | string; - percent: number; - ticks: Tick[]; -} - -export default (props: GaugeViewProps) => { +export default (props: GaugeProps) => { const { center, startAngle, endAngle, r, percent, ticks } = props; const { x, y } = center; const diff = endAngle - startAngle; diff --git a/packages/f2/src/components/gauge/index.tsx b/packages/f2/src/components/gauge/index.tsx index 12b3d2a7e..9ef8f41a2 100644 --- a/packages/f2/src/components/gauge/index.tsx +++ b/packages/f2/src/components/gauge/index.tsx @@ -1,5 +1,5 @@ -import withGauge, { GuageProps } from './withGauge'; -import GaugeView from './gaugeView'; +import withGauge from './withGauge'; +import GaugeView, { GaugeProps } from './gaugeView'; -export { GuageProps, withGauge, GaugeView }; -export default withGauge(GaugeView); +export { GaugeProps, withGauge, GaugeView }; +export default withGauge(GaugeView); diff --git a/packages/f2/src/components/gauge/withGauge.tsx b/packages/f2/src/components/gauge/withGauge.tsx index 67d2093f2..42c14fa66 100644 --- a/packages/f2/src/components/gauge/withGauge.tsx +++ b/packages/f2/src/components/gauge/withGauge.tsx @@ -31,7 +31,7 @@ const getTicks = ( return ticks; }; -export interface GuageProps { +export interface GaugeProps { startAngle?: number; endAngle?: number; tickCount?: number; @@ -40,11 +40,12 @@ export interface GuageProps { r?: number | string; r0?: number | string; center?: Point; - percent?: number; + ticks?: Tick[]; + percent: number; } -export default (View: ComponentType) => { - return class Guage extends Component { +const withGauge = (View: ComponentType) => { + return class Gauge

extends Component

{ render() { const { props, context } = this; const { startAngle, endAngle, tickCount, center, r, tickOffset, tickLength } = props; @@ -62,3 +63,5 @@ export default (View: ComponentType) => { } }; }; + +export default withGauge; diff --git a/packages/f2/src/components/index.ts b/packages/f2/src/components/index.ts index 415991a0d..748c126ac 100644 --- a/packages/f2/src/components/index.ts +++ b/packages/f2/src/components/index.ts @@ -22,6 +22,6 @@ export { default as Tooltip, TooltipProps, withTooltip, TooltipView } from './to export { default as Treemap, TreemapProps, withTreemap, TreemapView } from './treemap'; export { default as Sunburst, SunburstProps, withSunburst, SunburstView } from './sunburst'; export { default as PieLabel, PieLabelProps, withPieLabel, PieLabelView } from './pieLabel'; -export { default as Gauge, GuageProps, withGauge, GaugeView } from './gauge'; +export { default as Gauge, GaugeProps, withGauge, GaugeView } from './gauge'; export { default as Zoom, ZoomProps } from './zoom'; export { default as ScrollBar, ScrollBarProps, withScrollBar, ScrollBarView } from './scrollBar';