echarts [Bug] Heatmap: Item labels don't show when using a 'key-value format' dataset

3z6pesqy  于 2023-02-04  发布在  Echarts
关注(0)|答案(2)|浏览(228)

Version

5.2.2

https://codepen.io/ixonya/pen/NWazQRm

Steps to Reproduce

  1. Create a heatmap chart, and set series.label.show = true, in order to show the values in each item.
  2. Use a 'key-value format' dataset as the data source. The data is like :
var datasetSrc = [
  {
    x: 0, y: 0, value: 1
  },
  {
    x: 1, y: 1, value: 5
  },
  {
    x: 2, y: 2, value: 7
  },
  {
    x: 3, y: 3, value: 10
  },
];

Current Behavior

The heatmap shows correctly, however, all item labels are dashes: "-".
I tried to set "encode" and "dimensions" settings, but didn't help.
The item heat colors are right, and tooltips for each item show correct values, but labels are not working.

Expected Behavior

Item labels show correct values.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

mf98qq94

mf98qq941#

I just found a workaound that using label.formatter to return the correct value.

hivapdat

hivapdat2#

Same issue when the data is specified as an array:

var datasetSrc = [
  [0, 0, 'one', 1],
  [1, 1, 'one', 5],
  [2, 2, 'two', 7],
  [3, 3, 'three', 10],
];

In combination with this option:

visualMap: {
    min: 0,
    max: 10,
    dimension: [3],
    show: false
  },
  series: [{
      type: 'heatmap',
      label: {
        show: true,
      },
      encode: {
        x: 0,
        y: 1,
        value: 3,
      }
  }]

will always display the label from the third element of datasetSrc (index 2; see https://codepen.io/radusuciu/pen/wvXPKao ), and I believe that label.formatter is the only way to override this currently:

label: {
    show: true,
    formatter: (value) => {
      return value.data[3]
    }
  },

相关问题