@alitajs/f2
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -300,4 +300,9 @@ import React, { useMemo, forwardRef, useImperativeHandle, useState, useRef, useEffect, Fragment } from 'react'; | ||
onEnd && onEnd(clickedShape, coord, canvas); // drawLabel(clickedShape, coord, canvas, x, y, total); | ||
} // canvas.draw(); | ||
} | ||
return { | ||
clickedShape: clickedShape, | ||
coord: coord, | ||
canvas: canvas | ||
}; | ||
}); | ||
@@ -572,5 +577,13 @@ } | ||
disable = props.disable, | ||
_onClick = props.onClick, | ||
onClick = props.onClick, | ||
reset = _objectWithoutProperties(props, ["chart", "disable", "onClick"]); | ||
var onLegendClick = function onLegendClick(e) { | ||
var selectShapeByLegend = chart.get('selectShapeByLegendName'); | ||
onClick && onClick(_objectSpread2(_objectSpread2({}, e), {}, { | ||
chart: chart, | ||
selectShapeByLegend: selectShapeByLegend | ||
})); | ||
}; | ||
useMemo(function () { | ||
@@ -583,7 +596,3 @@ if (!chart) return; | ||
chart.legend(_objectSpread2(_objectSpread2({}, reset), {}, { | ||
onClick: function onClick(e) { | ||
_onClick && _onClick(_objectSpread2(_objectSpread2({}, e), {}, { | ||
chart: chart | ||
})); | ||
} | ||
onClick: onLegendClick | ||
})); | ||
@@ -590,0 +599,0 @@ } |
@@ -308,4 +308,9 @@ 'use strict'; | ||
onEnd && onEnd(clickedShape, coord, canvas); // drawLabel(clickedShape, coord, canvas, x, y, total); | ||
} // canvas.draw(); | ||
} | ||
return { | ||
clickedShape: clickedShape, | ||
coord: coord, | ||
canvas: canvas | ||
}; | ||
}); | ||
@@ -580,5 +585,13 @@ } | ||
disable = props.disable, | ||
_onClick = props.onClick, | ||
onClick = props.onClick, | ||
reset = _objectWithoutProperties(props, ["chart", "disable", "onClick"]); | ||
var onLegendClick = function onLegendClick(e) { | ||
var selectShapeByLegend = chart.get('selectShapeByLegendName'); | ||
onClick && onClick(_objectSpread2(_objectSpread2({}, e), {}, { | ||
chart: chart, | ||
selectShapeByLegend: selectShapeByLegend | ||
})); | ||
}; | ||
React.useMemo(function () { | ||
@@ -591,7 +604,3 @@ if (!chart) return; | ||
chart.legend(_objectSpread2(_objectSpread2({}, reset), {}, { | ||
onClick: function onClick(e) { | ||
_onClick && _onClick(_objectSpread2(_objectSpread2({}, e), {}, { | ||
chart: chart | ||
})); | ||
} | ||
onClick: onLegendClick | ||
})); | ||
@@ -598,0 +607,0 @@ } |
@@ -9,2 +9,9 @@ import React from 'react'; | ||
disable?: boolean; | ||
/** | ||
* 用于自定义鼠标点击图例项的交互,当 clickable 为 false 时不生效。 | ||
*/ | ||
onClick?: ({ clickedItem, selectShapeByLegend }: { | ||
clickedItem: any; | ||
selectShapeByLegend: (name: string, onEnd?: (clickedShape: any, coord: any, canvas: any) => void) => void; | ||
}) => any; | ||
[key: string]: any; | ||
@@ -11,0 +18,0 @@ } |
{ | ||
"name": "@alitajs/f2", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "start": "dumi dev", |
@@ -85,3 +85,3 @@ import F2 from '../../F2'; | ||
} | ||
// canvas.draw(); | ||
return { clickedShape, coord, canvas } | ||
}); | ||
@@ -88,0 +88,0 @@ } |
import { useMemo } from 'react'; | ||
import { LegendProps } from './'; | ||
export interface UseLegend extends LegendProps {} | ||
export interface UseLegend extends LegendProps { } | ||
export default (props = {} as UseLegend) => { | ||
const { chart, disable,onClick, ...reset } = props; | ||
const { chart, disable, onClick, ...reset } = props; | ||
const onLegendClick = (e: any) => { | ||
const selectShapeByLegend = chart.get('selectShapeByLegendName') | ||
onClick && onClick({ ...e, chart, selectShapeByLegend }) | ||
} | ||
useMemo(() => { | ||
@@ -13,3 +17,3 @@ if (!chart) return; | ||
} else { | ||
chart.legend({...reset,onClick:(e)=>{onClick&&onClick({...e,chart})}}); | ||
chart.legend({ ...reset, onClick: onLegendClick }); | ||
} | ||
@@ -16,0 +20,0 @@ }, [chart]); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130933
4270