Skip to content

[Bug]: 线柱混合时,如果数据为null,图表未渲染对应的标记 #6753

@sanye-huang

Description

@sanye-huang

Describe the bug / 问题描述

import { Chart } from "@antv/g2";

const chart = new Chart({ container: "container" });

const data = [
    { 月份: "Jan.", London: 18.9, Berlin: 12.4, Berlin1: 12, Berlin2: null },
    { 月份: "Feb.", London: 28.8, Berlin: 23.2, Berlin1: 24, Berlin2: null },
    { 月份: "Mar.", London: 39.3, Berlin: 81.4, Berlin1: 36, Berlin2: null },
    { 月份: "Apr.", London: 81.4, Berlin: 47, Berlin1: 48, Berlin2: null },
    { 月份: "May", London: 47, Berlin: 20.3, Berlin1: 36, Berlin2: null },
    { 月份: "Jun.", London: 20.3, Berlin: 18.9, Berlin1: 12, Berlin2: null },
  ];
chart.options({
  type: "view",
  autoFit: true,
  data: data,
  // scale: {
  //   color: {
  //     independent: true,
  //   }
  // },
  children: [
    {
      type: "interval",
      data: {
        type: "inline",
        transform: [
          {
            type: "fold",
            fields: ["London", "Berlin"],
            key: "leftYIds",
            value: "leftYValue",
          },
        ],
      },
      encode: {
        x: "月份",
        y: "leftYValue",
        color: "leftYIds",
        // series: "leftYIds",
      },
      transform: [{
        type: 'dodgeX'
      }],
      interaction: { elementHighlight: { background: true } },
    },
    {
      type: "line",
      data: {
        type: "inline",
        transform: [
          {
            type: "fold",
            fields: ["Berlin1", "Berlin2"],
            key: "leftYIds",
            value: "leftYValue",
          },
        ],
      },
      encode: {
        x: "月份",
        y: "leftYValue",
        color: "leftYIds",
        series: "leftYIds",
      },
      interaction: { elementHighlight: { background: true } },
    }
  ],
});

chart.render();

实际:
Image
期望:
Image

Reproduction link / 复现链接

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

Version / 版本

🆕 5.x

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

Metadata

Metadata

Assignees

No one assigned

    Labels

    OSCPAntV Open Source Contribution Planbug 🐛Something isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions