pissang commented on a change in pull request #16243:
URL: https://github.com/apache/echarts/pull/16243#discussion_r774843458



##########
File path: src/view/Chart.ts
##########
@@ -152,14 +152,14 @@ class ChartView {
      * Highlight series or specified data item.
      */
     highlight(seriesModel: SeriesModel, ecModel: GlobalModel, api: 
ExtensionAPI, payload: Payload): void {
-        toggleHighlight(seriesModel.getData(), payload, 'emphasis');
+        toggleHighlight(seriesModel.getData(payload && payload.dataType), 
payload, 'emphasis');

Review comment:
       If we need to do null checking. We should always do it at the place 
where it is used. In this case is before we passing it as a parameter to 
`toggleHighlight`. What if `seriesModel.getData()` has other methods to fetch 
the data if you do null checking in the `getLinkedData`. ? 
   
   Here is an example:
   
   ```ts
   const data = seriesModel.getData(payload && payload.dataType)
   if (!data) {
       if (__DEV__) {
           error(`Unkown dataType ${dataType}`);
       }
       return;
   }
   toggleHighlight(data, payload, 'emphasis');
   ```
   
   Null checking in the `getLinkedData` can be removed to simplify the code.
   
   




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

Reply via email to