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: [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]