fondoger opened a new issue, #19565:
URL: https://github.com/apache/echarts/issues/19565

   ### What problem does this feature solve?
   
   Hi Echarts team,
   
   I  want to have a KMB style yAxis label formatter for large numeric label 
values. Eg: "100M" for "100,000,000".
   
   **Current style:**
   [Demo 
Link](https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5AMYCGYVA5sAE7m0A0J6AE2aMiAbVoBZGL1i0AKgFcqM2gHUqAlXIAWClQDEOEFQGVmphdFoBdEgF8-6cjnxFUpMpRqyAbowA2SrT2jrB4VEZUhLCi_MQegsJiAIwArAAMPLAATADMmTnZACxZ2ckAHFnJualVRQDspQBs6a1trdahHhTUdP4Q0MpxdiS2dgDcQA)
   <img width="592" alt="image" 
src="https://github.com/apache/echarts/assets/22270677/06378a82-e04f-4a4b-98cc-cba883e18c8f";>
   
   **Expected Style**
   <img width="658" alt="image" 
src="https://github.com/apache/echarts/assets/22270677/ba596ab2-c4c3-4cd2-bdd5-0286876014e3";>
   
   
   Currently, there is option 
[`yAxis.axisLabel.formatter`](https://echarts.apache.org/en/option.html#yAxis.axisLabel.formatter)
 to customize yAxis labels. We can provide a callback function to customize 
label. However, this callback function lacks some important information. I need 
at least Axis min value, max value to determine whether to show as K or M or B. 
   
   
   ### What does the proposed API look like?
   
   
https://github.com/susiwen8/echarts/blob/b69e1637e8117aa210f88cbd5073c43862c26f31/src/coord/axisHelper.ts#L269
   
   ```ts
       else if (zrUtil.isFunction(labelFormatter)) {
           return (function (cb) {
               return function (tick: ScaleTick, idx: number) {
                   // The original intention of `idx` is "the index of the tick 
in all ticks".
                   // But the previous implementation of category axis do not 
consider the
                   // `axisLabel.interval`, which cause that, for example, the 
`interval` is
                   // `1`, then the ticks "name5", "name7", "name9" are 
displayed, where the
                   // corresponding `idx` are `0`, `2`, `4`, but not `0`, `1`, 
`2`. So we keep
                   // the definition here for back compatibility.
                   if (categoryTickStart != null) {
                       idx = tick.value - categoryTickStart;
                   }
                   return cb(
                       getAxisRawValue(axis, tick) as number,
                       idx,
                       (tick as TimeScaleTick).level != null ? {
                           level: (tick as TimeScaleTick).level
                       } : null,
   // ADDED INFORMATION, MIN AND MAX VALUE
   // ADDED INFORMATION, MIN AND MAX VALUE
   // ADDED INFORMATION, MIN AND MAX VALUE
                       { min: axisMinValue, max: axisMaxValue },
                   );
               };
           })(labelFormatter as (...args: any[]) => string);
       }
       ```


-- 
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-unsubscr...@echarts.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to