Skip to content

[Bug] VisualMap with string category not working #17267

Description

@DavidMarquezF

Version

5.3.3

Link to Minimal Reproduction

repro link

Steps to Reproduce

When using visualMap with categories set to strings I cannot get the bar charts to paint the inRange bars. This is the config I use:

option = {
  dataset: {
    source: [
      ['score', 'amount', 'product'],
      [89.3, 58212, 'Matcha Latte'],
      [57.1, 78254, 'Milk Tea'],
      [74.4, 41032, 'Cheese Cocoa'],
      [50.1, 12755, 'Cheese Brownie'],
      [89.7, 20145, 'Matcha Cocoa'],
      [68.1, 79146, 'Tea'],
      [19.6, 91852, 'Orange Juice'],
      [10.6, 101852, 'Lemon Juice'],
      [32.7, 20112, 'Walnut Brownie']
    ]
  },
  grid: { containLabel: true },
  xAxis: { name: 'amount' },
  yAxis: { type: 'category' },
  visualMap: {
    type: "piecewise",
    categories: ['Milk Tea'],
    left: 'center',
    text: ['High Score', 'Low Score'],
    // Map the score column to color
    dimension: 2,
    inRange: {
      color: '#FFCE34'
    },
    outOfRange: {
      color: '#65B581'
    }
  },
  series: [
    {
      type: 'bar',
      encode: {
        // Map the "amount" column to X axis.
        x: 'amount',
        // Map the "product" column to Y axis
        y: 'product'
      }
    }
  ]
};

If instead I use a numeric value in categories (such as using dimension: 0 and categories: [89.3]) it paints the bar correctly. You can view a demo of the problem in the current behavior section.

If I use another column as the category axis the value map works. (reproduction link)

The strange thing is that if I duplicate the category column in data and use that to do the valueMap it works (repro link). So it looks like it might be related to the fact that the data column is being used in the axis

The same can be reproduced with the scatter chart

Current Behavior

Using a number in categories reproduction

image

Using a string in categories reproduction

image

Expected Behavior

The result should always be
image

The fact that the category is used in the axis or not shouldn't affect the value map

Environment

- OS: Windows 11
- Browser: Microsoft edge Version 102.0.1245.44 (Official build) (64-bit)
- Framework: None

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions