alphabetabc opened a new issue #14673:
URL: https://github.com/apache/echarts/issues/14673


   ### Version
   5.0.2
   
   ### Steps to reproduce
   
   1. 使用 visualMap 创建一个图表
   2. 根据需求,在下一个类型的时候不使用visualMap
   
   ### What is expected?
   visualMap.disable = true
   
   ### What is actually happening?
   visualMap的配置一直缓存在option中
   
   ### code
   我找到两种解决方案,但是这里面涉及1个问题:
   - 哪些option会被长期缓存,并且不能够被覆盖?
   - 如果我封装组件,需要判断当前的状态需要不要合并option,而这些问题却在文档中无法找到答案
   - 如果一行行去看源码,感觉有点太费时间了
   ```js
       /**
        * 解决方案:
        * 1. 使用 chart.clear() 清除数据
        * chart.clear();
        * chart.setOption({
        *      ...option,
        *      visualMap: null,
        * });
        * 2. 使用notMerge配置项
        * chart.setOption({newOption},true)
        */
      const chart = echarts.init(document.querySelector('#chart'));
       const option = {
           xAxis: {
               type: 'value',
               name: '日期',
               nameGap: 16,
               nameTextStyle: {
                   fontSize: 16,
               },
               max: 31,
               splitLine: {
                   show: false,
               },
           },
           yAxis: {
               type: 'value',
               name: 'AQI指数',
               nameLocation: 'end',
               nameGap: 20,
               nameTextStyle: {
                   fontSize: 16,
               },
               splitLine: {
                   show: false,
               },
           },
           visualMap: [
               {
                   left: 'right',
                   top: '10%',
                   dimension: 2,
                   min: 0,
                   max: 250,
                   itemWidth: 30,
                   itemHeight: 120,
                   calculable: true,
                   precision: 0.1,
                   text: ['圆形大小:PM2.5'],
                   textGap: 30,
                   inRange: {
                       symbolSize: [10, 70],
                   },
                   outOfRange: {
                       symbolSize: [10, 70],
                       color: ['rgba(255,255,255,0)'],
                   },
               },
           ],
           series: [
               {
                   name: '北京',
                   type: 'scatter',
                   itemStyle: {
                       opacity: 0.8,
                       shadowBlur: 10,
                       shadowOffsetX: 0,
                       shadowOffsetY: 0,
                       shadowColor: 'rgba(0,0,0,0.3)',
                   },
                   data: [
                       [1, 55, 9, 56, 0.46, 18, 6, '良'],
                       [2, 25, 11, 21, 0.65, 34, 9, '优'],
                       [3, 56, 7, 63, 0.3, 14, 5, '良'],
                       [4, 33, 7, 29, 0.33, 16, 6, '优'],
                       [5, 42, 24, 44, 0.76, 40, 16, '优'],
                       [6, 82, 58, 90, 1.77, 68, 33, '良'],
                   ],
               },
           ],
       };
       chart.setOption(option);
   
       setTimeout(() => {
           chart.setOption({
               visualMap: null,
           });
       }, 10000);
   ```
   这个issue [14515](https://github.com/apache/echarts/issues/14515) 中也提到这个问题
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->


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