100pah commented on code in PR #18164:
URL: https://github.com/apache/echarts/pull/18164#discussion_r1991358633
##########
src/component/legend/LegendView.ts:
##########
@@ -223,8 +223,16 @@ class LegendView extends ComponentView {
);
itemGroup.on('click', curry(dispatchSelectAction, name, null,
api, excludeSeriesId))
Review Comment:
From users' perspective, if we use this API style, a complete set of events
is supposed to be exposed to users ('click', 'mouseover', 'mouseout',
'mousedown', 'mouseup', 'mousemove', ...).
If we only expose mouseover and mouseout for legend, it may not be a good
API design.
Whenever users require additional mouse events, we would need to introduce
event names like `legendmousexxx1`, `legendmousexxx2`, `legendmousexxx2`.
Furthermore, considering other components, the number of events we need to
expose would grow significantly due to the orthogonal composition.
At present we already have setting like `title.triggerEvent: true`,
`xAxis.triggerEvent: true`, `radar.triggerEvent`, etc. I think this pattern
(`xxxcomponent.triggerEvent: boolean`) is better to resolve this requirement
and could be a standard way.
```js
option = {
title: {
text: "xxxxx",
tiggerEvent: true,
}
}
const chart = echarts.create(...);
chart.on('mouseover', params => {
if (params.componentType === 'title') {
// do something.
}
});
```
So I think we should implement `legend.triggerEvent` like component `title`
did.
(Incidentally, the implementation is simpler than the current way)
```js
option = {
legend: {
tiggerEvent: true,
// ...
}
}
const chart = echarts.create(...);
chart.on('mouseover', params => {
if (params.componentType === 'legend') {
// do something.
}
});
```
Some relevant details:
- by default value should be `false`, for backward compatibility.
- The event param should follow the convention.
- `componentType: 'legend'`
- `componentIndex: number`
- `dataIndex: number` can be provided in the event param to representing
different legend items. (follow the style of axis label event)
- `value: string` can be provided in the event param to indicate the
legend item value. (follow the style of axis label event)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]