Skip to content

Commit d6caadf

Browse files
committed
feat(chart): 去除 DoubleOverlapArea cursor 配置,由 markArea 实现
1 parent d32d926 commit d6caadf

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

docs/custom/demo/DoubleOverlapArea/event.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ function Example() {
140140
};
141141

142142
const handleDimensionClick: DoubleOverlapAreaProps['onDimensionClick'] = (e) => {
143-
if (e?.model?.userId === 'area2' || e.node.type === 'line') {
143+
const datum = e.dimensionInfo[0];
144+
145+
// 根据数据判断
146+
if (datum && datum.value >= 2 && datum.value <= 22) {
144147
const val = e.dimensionInfo[0].value;
145148
if (getSelectVal() === val) {
146149
setSelectVal(null);
@@ -156,9 +159,20 @@ function Example() {
156159
return (
157160
<DoubleOverlapArea
158161
{...spec}
159-
cursor="pointer"
160162
markLine={markLine}
161163
onDimensionClick={handleDimensionClick}
164+
markArea={[
165+
{
166+
x: 2,
167+
x1: 22,
168+
area: {
169+
style: {
170+
fillOpacity: 0,
171+
cursor: 'pointer',
172+
},
173+
},
174+
},
175+
]}
162176
crosshair={[
163177
{
164178
xField: {

packages/chart/src/DoubleOverlapArea/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import type { CommonChartProps } from '@visactor/react-vchart';
2-
import type { Cursor } from '@visactor/vchart/esm/typings/cursor';
32
import type { ICartesianAxisSpec } from './types';
43
import { CommonChart } from '@visactor/react-vchart';
54
import { merge } from '@visactor/vutils';
6-
import React, { useMemo } from 'react';
5+
import React from 'react';
76
import { defaultCrosshair, defaultTooltip } from './config';
87
import { getDefaultProps } from './utils';
98

109
export interface DoubleOverlapAreaProps extends CommonChartProps {
1110
xField?: string | string[];
1211
yField?: string | string[];
13-
cursor?: Cursor;
1412
/**
1513
* 坐标轴 X 轴配置
1614
*/
@@ -28,25 +26,23 @@ export function DoubleOverlapArea(props: DoubleOverlapAreaProps) {
2826
yAxes,
2927
xField = 'date',
3028
yField = 'value',
31-
cursor = 'default',
3229
tooltip,
3330
crosshair = defaultCrosshair,
3431
...rest
3532
} = props;
3633

3734
const tooltipProps = merge({}, defaultTooltip, tooltip);
3835

39-
const defaultProps = useMemo(
36+
const defaultProps = React.useMemo(
4037
() => {
4138
return getDefaultProps({
4239
yAxes,
4340
xAxes,
4441
xField,
4542
yField,
46-
cursor,
4743
});
4844
},
49-
[yAxes, xAxes, xField, yField, cursor],
45+
[yAxes, xAxes, xField, yField],
5046
);
5147

5248
return (

packages/chart/src/DoubleOverlapArea/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { CommonChartProps } from '@visactor/react-vchart';
2-
import type { Cursor } from '@visactor/vchart/esm/typings/cursor';
32
import type { ICartesianAxisSpec } from './types';
43
import { colorBlue2, colorGrey04 } from '@sensoro-design/chart-theme';
54
import { merge } from '@visactor/vutils';
@@ -10,11 +9,10 @@ interface Params {
109
yAxes?: Partial<ICartesianAxisSpec>;
1110
xField?: string | string[];
1211
yField?: string | string[];
13-
cursor?: Cursor;
1412
}
1513

1614
export function getDefaultProps(params: Params) {
17-
const { xAxes = {}, yAxes = {}, xField, yField, cursor } = params;
15+
const { xAxes = {}, yAxes = {}, xField, yField } = params;
1816

1917
const defaultXAxes = {
2018
orient: 'bottom',
@@ -75,7 +73,6 @@ export function getDefaultProps(params: Params) {
7573
...defaultArea,
7674
style: {
7775
...defaultArea.style,
78-
cursor,
7976
},
8077
},
8178
point: {

0 commit comments

Comments
 (0)