bonedi opened a new issue, #20332:
URL: https://github.com/apache/superset/issues/20332

   The Compare Lag of BigNumberLine Chart is calculating the percentage change. 
In some cases a difference is desired. For example if the number is an 
percantage allready. So it would be great if you can choose between percentage 
change and absolute change. 
   Currently the code for calulating the change is:
   ```    if (compareLag > 0) {
         const compareIndex = compareLag;
         if (compareIndex < sortedData.length) {
           const compareValue = sortedData[compareIndex][1];
           // compare values must both be non-nulls
           if (bigNumber !== null && compareValue !== null && compareValue !== 
0) {
             percentChange = (bigNumber - compareValue) / 
Math.abs(compareValue);
             formattedSubheader = `${formatPercentChange(
               percentChange,
             )} ${compareSuffix}`;
           }
         }
       }
   ```
   
   One way to change it, would be to create a radio button with value 
percentChangeDesired (=True or False). Then the Code would change to:
   ``` if (compareLag > 0) {
         const compareIndex = compareLag;
         if (compareIndex < sortedData.length) {
           const compareValue = sortedData[compareIndex][1];
           // compare values must both be non-nulls
           if (bigNumber !== null && compareValue !== null && compareValue !== 
0) {
             if (percentChangeDesired){
                 percentChange = (bigNumber - compareValue) / 
Math.abs(compareValue);
                 formattedSubheader = `${formatPercentChange(
                   percentChange,
                 )} ${compareSuffix}`;
             }
             else {
                 absoluteChange = bigNumber - compareValue;
                 formattedSubheader = `${absoluteChange} ${compareSuffix}`;
            }
           }
         }
       }
   
   ```
   
   I have no experiance in TypeScript, so the code won't work 100% for sure. 
But I think you get an Idea of what I was thinking of. 


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