You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/10/09 15:12:02 UTC
[GitHub] [echarts] susiwen8 opened a new pull request #15847: Feat(line): mouse event on polyline and polygon
susiwen8 opened a new pull request #15847:
URL: https://github.com/apache/echarts/pull/15847
<!-- Please fill in the following information to help us review your PR more efficiently. -->
## Brief Information
This pull request is in the type of:
- [ ] bug fixing
- [x] new feature
- [ ] others
### What does this PR do?
Add `click` and `mouseover` for `polyline` and `polygon`
### Fixed issues
Close #13637
Close #13843
## Details
### Before: What was the problem?
<!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->
<!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
### After: How is it fixed in this PR?
![Kapture 2021-10-09 at 23 10 17](https://user-images.githubusercontent.com/20318608/136663896-8b085b3b-4ab0-498b-95da-2ad38ea560c0.gif)
## Misc
<!-- ADD RELATED ISSUE ID WHEN APPLICABLE -->
- [ ] The API has been changed (apache/echarts-doc#xxx).
- [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
### Related test cases or examples to use the new APIs
`polyline-gon-event.html`
## Others
### Merging options
- [ ] Please squash the commits into a single one when merge.
### Other information
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] pissang commented on pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
pissang commented on pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#issuecomment-945035971
I think we need an option to enable this event. It may break the apps that don't check if `dataIndex` exists in their event handler.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] susiwen8 commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
susiwen8 commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730933497
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +879,23 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+
+ if (seriesModel.get('triggerLineEvent')) {
+ this.packEventData(seriesModel, polyline);
+ polygon && this.packEventData(seriesModel, polygon);
+ }
}
- dispose() {}
+ private packEventData(seriesModel: LineSeriesModel, el: Element) {
+ getECData(el).eventData = {
+ componentType: 'series',
+ componentSubType: 'line',
+ componentIndex: seriesModel.componentIndex,
+ seriesIndex: seriesModel.componentIndex,
Review comment:
Both have changed
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] echarts-bot[bot] commented on pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#issuecomment-939312312
Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
The pull request is marked to be `PR: author is committer` because you are a committer of this project.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] plainheart commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
plainheart commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730375600
##########
File path: src/chart/line/LineSeries.ts
##########
@@ -118,6 +118,8 @@ export interface LineSeriesOption extends SeriesOption<LineStateOption<CallbackD
showAllSymbol?: 'auto' | boolean
data?: (LineDataValue | LineDataItemOption)[]
+
+ enableLineEvent?: boolean
Review comment:
How about naming it `triggerEvent`? It has been used somewhere.
And will it be confusing if someone uses both this option and the present `silent` option...?
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] plainheart commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
plainheart commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730375600
##########
File path: src/chart/line/LineSeries.ts
##########
@@ -118,6 +118,8 @@ export interface LineSeriesOption extends SeriesOption<LineStateOption<CallbackD
showAllSymbol?: 'auto' | boolean
data?: (LineDataValue | LineDataItemOption)[]
+
+ enableLineEvent?: boolean
Review comment:
How about naming it `triggerEvent`? It has been used somewhere.
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +879,23 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+
+ if (seriesModel.get('enableLineEvent')) {
+ this._mouseEvent(seriesModel, polyline);
+ polygon && this._mouseEvent(seriesModel, polygon);
+ }
}
- dispose() {}
+ private _mouseEvent(seriesModel: LineSeriesModel, el: Element) {
Review comment:
Also, it may be better to name it `packEventData`.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] susiwen8 commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
susiwen8 commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730381938
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +879,23 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+
+ if (seriesModel.get('enableLineEvent')) {
+ this._mouseEvent(seriesModel, polyline);
+ polygon && this._mouseEvent(seriesModel, polygon);
+ }
}
- dispose() {}
+ private _mouseEvent(seriesModel: LineSeriesModel, el: Element) {
Review comment:
Thanks, I have changed it
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] pissang commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730376387
##########
File path: src/chart/line/LineSeries.ts
##########
@@ -118,6 +118,8 @@ export interface LineSeriesOption extends SeriesOption<LineStateOption<CallbackD
showAllSymbol?: 'auto' | boolean
data?: (LineDataValue | LineDataItemOption)[]
+
+ enableLineEvent?: boolean
Review comment:
More specifically it can be `triggerLineEvent` or `lineTriggerEvent`
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] pissang commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730339460
##########
File path: src/chart/line/LineView.ts
##########
@@ -882,45 +881,22 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
- this.mouseEvent(seriesModel, api);
- }
-
- dispose() {
- this._polyline.off('click').off('mouseover');
- this._polygon && this._polygon.off('click').off('mouseover');
+ this.mouseEvent(seriesModel, polyline, 'polyline');
+ polygon && this.mouseEvent(seriesModel, polygon, 'polygon');
}
- mouseEvent(seriesModel: LineSeriesModel, api: ExtensionAPI) {
- const bindEvent = (poly: Path, eventName: 'click' | 'mouseover', ecEventName: string) => {
- poly.off(eventName).on(eventName, (e) => {
- const el = e.target;
- let params: CallbackSerieParams;
- const dispatcher = findEventDispatcher(el, (parent) => {
- const ecData = getECData(parent);
- if (ecData && ecData.seriesIndex != null) {
- params = seriesModel.getSerieParams();
- return true;
- }
- }, true);
-
- if (dispatcher) {
- api.dispatchAction({
- ...params,
- type: ecEventName,
- });
- }
- });
- }
-
- const polyline = this._polyline;
- bindEvent(polyline, 'click', 'polyLineClick');
- bindEvent(polyline, 'mouseover', 'polyLineMouseover');
-
- const polygon = this._polygon;
- if (polygon) {
- bindEvent(polygon, 'click', 'polygonClick');
- bindEvent(polygon, 'mouseover', 'polygonMouseover');
- }
+ dispose() { }
Review comment:
Empty method can be removed
##########
File path: src/chart/line/LineView.ts
##########
@@ -882,45 +881,22 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
- this.mouseEvent(seriesModel, api);
- }
-
- dispose() {
- this._polyline.off('click').off('mouseover');
- this._polygon && this._polygon.off('click').off('mouseover');
+ this.mouseEvent(seriesModel, polyline, 'polyline');
Review comment:
`mouseEvent` is better to be a private method
##########
File path: src/chart/line/LineView.ts
##########
@@ -882,45 +881,22 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
- this.mouseEvent(seriesModel, api);
- }
-
- dispose() {
- this._polyline.off('click').off('mouseover');
- this._polygon && this._polygon.off('click').off('mouseover');
+ this.mouseEvent(seriesModel, polyline, 'polyline');
+ polygon && this.mouseEvent(seriesModel, polygon, 'polygon');
}
- mouseEvent(seriesModel: LineSeriesModel, api: ExtensionAPI) {
- const bindEvent = (poly: Path, eventName: 'click' | 'mouseover', ecEventName: string) => {
- poly.off(eventName).on(eventName, (e) => {
- const el = e.target;
- let params: CallbackSerieParams;
- const dispatcher = findEventDispatcher(el, (parent) => {
- const ecData = getECData(parent);
- if (ecData && ecData.seriesIndex != null) {
- params = seriesModel.getSerieParams();
- return true;
- }
- }, true);
-
- if (dispatcher) {
- api.dispatchAction({
- ...params,
- type: ecEventName,
- });
- }
- });
- }
-
- const polyline = this._polyline;
- bindEvent(polyline, 'click', 'polyLineClick');
- bindEvent(polyline, 'mouseover', 'polyLineMouseover');
-
- const polygon = this._polygon;
- if (polygon) {
- bindEvent(polygon, 'click', 'polygonClick');
- bindEvent(polygon, 'mouseover', 'polygonMouseover');
- }
+ dispose() { }
+
+ mouseEvent(seriesModel: LineSeriesModel, el: Element, areaType: string) {
+ getECData(el).eventData = {
+ componentType: 'series',
+ componentSubType: 'line',
+ componentIndex: seriesModel.componentIndex,
+ seriesIndex: seriesModel.componentIndex,
+ seriesName: seriesModel.name,
+ seriesType: 'line',
+ areaType,
Review comment:
`areaType` is not a very good name. Other custom events may also need similar property. We can hold on to provide such property before we thinking of a better name.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] plainheart commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
plainheart commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730793998
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +879,23 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+
+ if (seriesModel.get('triggerLineEvent')) {
+ this.packEventData(seriesModel, polyline);
+ polygon && this.packEventData(seriesModel, polygon);
+ }
}
- dispose() {}
+ private packEventData(seriesModel: LineSeriesModel, el: Element) {
+ getECData(el).eventData = {
+ componentType: 'series',
+ componentSubType: 'line',
+ componentIndex: seriesModel.componentIndex,
+ seriesIndex: seriesModel.componentIndex,
Review comment:
Then we may also need to do this at [chart/treemap/Breadcrumb.ts#L220](https://github.com/apache/echarts/blob/c803311c86/src/chart/treemap/Breadcrumb.ts#L220).
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] susiwen8 commented on pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
susiwen8 commented on pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#issuecomment-945039216
> I think we need an option to enable this event. It may break the apps that don't check if `dataIndex` exists in their event handler.
Add `enableLineEvent` option
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] pissang commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r725748215
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +882,46 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+ this.mouseEvent(seriesModel, api);
}
- dispose() {}
+ dispose() {
+ this._polyline.off('click').off('mouseover');
+ this._polygon && this._polygon.off('click').off('mouseover');
+ }
+
+ mouseEvent(seriesModel: LineSeriesModel, api: ExtensionAPI) {
Review comment:
There is no need to bind event manually in the series. ECharts will trigger events for elements with `eventData ` data. Check the reference usage in:
https://github.com/apache/echarts/blob/fde66eca74144f78c4299ac101f3c434bc57e5c1/src/component/axis/AxisBuilder.ts#L464
https://github.com/apache/echarts/blob/8f48ad285134a0a5907c19e479ae6c5bc270228a/src/chart/treemap/Breadcrumb.ts#L191
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] susiwen8 commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
susiwen8 commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r729809717
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +882,46 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+ this.mouseEvent(seriesModel, api);
}
- dispose() {}
+ dispose() {
+ this._polyline.off('click').off('mouseover');
+ this._polygon && this._polygon.off('click').off('mouseover');
+ }
+
+ mouseEvent(seriesModel: LineSeriesModel, api: ExtensionAPI) {
Review comment:
Right, that much easy.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] pissang commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730524254
##########
File path: src/chart/line/LineView.ts
##########
@@ -877,9 +879,23 @@ class LineView extends ChartView {
this._points = points;
this._step = step;
this._valueOrigin = valueOrigin;
+
+ if (seriesModel.get('triggerLineEvent')) {
+ this.packEventData(seriesModel, polyline);
+ polygon && this.packEventData(seriesModel, polygon);
+ }
}
- dispose() {}
+ private packEventData(seriesModel: LineSeriesModel, el: Element) {
+ getECData(el).eventData = {
+ componentType: 'series',
+ componentSubType: 'line',
+ componentIndex: seriesModel.componentIndex,
+ seriesIndex: seriesModel.componentIndex,
Review comment:
Will be slightly better to use `seriesModel.seriesIndex` here
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] pissang merged pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
pissang merged pull request #15847:
URL: https://github.com/apache/echarts/pull/15847
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] echarts-bot[bot] commented on pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#issuecomment-946364999
Congratulations! Your PR has been merged. Thanks for your contribution! 👍
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[GitHub] [echarts] plainheart commented on a change in pull request #15847: Feat(line): mouse event on polyline and polygon
Posted by GitBox <gi...@apache.org>.
plainheart commented on a change in pull request #15847:
URL: https://github.com/apache/echarts/pull/15847#discussion_r730376942
##########
File path: src/chart/line/LineSeries.ts
##########
@@ -118,6 +118,8 @@ export interface LineSeriesOption extends SeriesOption<LineStateOption<CallbackD
showAllSymbol?: 'auto' | boolean
data?: (LineDataValue | LineDataItemOption)[]
+
+ enableLineEvent?: boolean
Review comment:
I prefer `triggerLineEvent`. It won't be confusing.
--
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org