You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/08/25 13:29:26 UTC

[GitHub] [echarts] drumslave-git commented on issue #12374: visualMap piecewise not work on dimension x/y in some kind of configurations

drumslave-git commented on issue #12374:
URL: https://github.com/apache/echarts/issues/12374#issuecomment-905502628


   Still actual for me in echarts 4.9.0. Dont know what happened with #11847, but based on that I did my own dirty hack fix
   
   ```
   import VisualMapModel from 'echarts/lib/component/visualMap/VisualMapModel';
   import OriginPiecewiseModel from 'echarts/src/component/visualMap/PiecewiseModel';
   import * as zrUtil from 'zrender/src/core/util';
   
   const PiecewiseModel = OriginPiecewiseModel.prototype;
   const originGetVisualMeta =  OriginPiecewiseModel.prototype.getVisualMeta;
   
   PiecewiseModel.getVisualMeta = function (getColorVisual){
       const {stops, outerColors} = originGetVisualMeta.call(this, getColorVisual);
       // stop needs to have something
       if (!stops.length) {
           // get value axis
           const visualMapModel = this;
           const pieceList = this._pieceList.slice();
           const cartesian = visualMapModel.ecModel.getComponent('series').coordinateSystem;
           const baseAxis = cartesian.getBaseAxis();
           const valueAxis = cartesian.getOtherAxis(baseAxis);
           const extent = valueAxis.scale.getExtent();
           zrUtil.each(pieceList, function (piece) {
               for (let i = 0; i < piece.interval.length; i++) {
                   // Because CanvasRenderingContext2D doesn't support Infinity
                   // So set stop value to axis end.
                   let value = piece.interval[i] === -Infinity
                       ? extent[0]
                       : piece.interval[i] === Infinity
                           ? extent[1]
                           : piece.interval[i];
                   stops.push({
                       value: value,
                       color: piece.visual.color
                   });
               }
           });
       }
   
       return {stops, outerColors};
   };
   
   VisualMapModel.extend(PiecewiseModel);
   ```
   
   Use  
   `import './PiecewiseModel';`  
   after  
   `import echarts from 'echarts';`


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

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



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