Skip to content

y轴类型为log时,启用visualMap,serice配置areaStyle: {}出现如下异常: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite. #14601

@leleccccc

Description

@leleccccc

Version

5.0.2

Steps to reproduce

option = {
  tooltip: {
    trigger: 'axis',
    formatter: function (params) {
      let html = params[0].name
      params.forEach((item, index) => {
        html  = (`<br/>${item.marker   item.seriesName}: ${item.value === 0.1 ? 0 : item.value}`)
      })
      return html
    }
  },
  legend: {
    data: ['pm0.5', 'pm2.5']
  },
  grid: {
    top: '18%',
    left: '3%',
    right: '8%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: ['4-1', '4-2', '4-3', '4-4', '4-5', '4-6']
  },
  yAxis: {
    type: 'log',
    axisLabel: {
      formatter: function (value) {
        return value === 0.1 ? 0 : value
      }
    }
  },
  series: [
    {
      name: 'pm0.5',
      type: 'line',
      areaStyle: {

      },
      emphasis: {
        focus: 'series'
      },
      itemStyle: {
        normal: {
          lineStyle: {
            color: '#FEC171'
          }
        }
      },
      data: [15, 200, 3000, 50000, 1200000],
      markLine: {
        data: [
            {
                name: `Y 轴值为 150 的水平线`,
                yAxis: 150
            }
        ],
        lineStyle: {
          color: '#30B08F'
        }
      }
    },
    {
      name: 'pm2.5',
      type: 'line',
      areaStyle: {

      },
      emphasis: {
        focus: 'series'
      },
      itemStyle: {
        normal: {
          lineStyle: {
            color: '#409EFF'
          }
        }
      },
      data: [1200000, 50000, 3000, 200, 15 ],
      markLine: {
        data: [
             {
                name: `Y 轴值为 150 的水平线`,
                yAxis: 150
            }
        ],
        lineStyle: {
          color: '#30B08F'
        }
      }
    }
  ],
  visualMap: {
    show: false,
    pieces: [{
      gt: 0,
      lte: 150,
      color: '#30B08F'
    }, {
      gt: 150,
      color: '#C03639'
    }],
    left: '55%',
    top: -2,
    orient: 'horizontal'
  }
};

What is expected?

希望在水平线上的区域显示一种颜色,水平线下的区域显示另一种颜色,如果在areaStyle中配置颜色,不会报错但不是我要的效果

What is actually happening?

Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions