100pah commented on a change in pull request #11973: fix bug #11528 Modify 
default value of tooltip and label
URL: 
https://github.com/apache/incubator-echarts/pull/11973#discussion_r362718449
 
 

 ##########
 File path: src/chart/helper/labelHelper.js
 ##########
 @@ -25,7 +25,8 @@ import {retrieveRawValue} from 
'../../data/helper/dataProvider';
  * @return {string} label string. Not null/undefined
  */
 export function getDefaultLabel(data, dataIndex) {
-    var labelDims = data.mapDimension('defaultedLabel', true);
+    var dataDimsLen = data.dimensions.length;
+    var labelDims = data.mapDimension(dataDimsLen > 2 ? 
data.dimensions[dataDimsLen - 1] : 'defaultedLabel', true);
 
 Review comment:
   (1) the logic `dataDimsLen > 2 ? data.dimensions[dataDimsLen - 1] : ...` is 
to calculate a "default label" , so the code should be placed on where the 
`defaultedLabel` calculated rather here.
   (2) We should not simply use the last dimension at the default label. 
Consider the dataset case:
   ```js
   dataset: {
       source: [
          //  series0x series0y series1x series1y series2x series2y
              [11,              22,            33,       99,         33,        
  91          ],
              [121,              62,            93,       99,         83,       
   91          ],
              [16,              52,            33,       99,         33,        
  91          ],
       ] 
   }
   ```
   If using the last dimension as the label, all of the series will use the 
`series2y` as their label.
   
   It a little difficulty to guess which dimension can be the default label.
   
   Users can set label dimension by 
   ```js
   encode: {label: 2}   means dimesion 2
   ```
   or 
   ```js
   formatter: '{@[2]}' // means dimesion 2
   ```
   
   So do we need to fix that on code?
   We might only fix #11528 on example?
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to