8000 [Bug]: 组合折线图在数据为空的时候会出现显示列名的情况 · Issue #6971 · antvis/G2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Bug]: 组合折线图在数据为空的时候会出现显示列名的情况 #6971
Open
@Calmio-Y

Description

@Calmio-Y

Describe the bug / 问题描述

import { Chart } from '@antv/g2'

const chart = new Chart({
  container: 'container',
  autoFit: true,
})

const data1 = [
  {
    period: '一月',
    year: '2024年',
    index004_P: 200631584.493411,
    Pre_index004_P: -456176387.90719,
    _origin: {
      period: '1',
      year: '2024',
    },
  },
  {
    period: '二月',
    year: '2024年',
    index004_P: 64864402.978794,
    Pre_index004_P: -422725221.264479,
    _origin: {
      period: '2',
      year: '2024',
    },
  },
  {
    period: '三月',
    year: '2024年',
    index004_P: 83498516.253724,
    Pre_index004_P: -425515193.941971,
    _origin: {
      period: '3',
      year: '2024',
    },
  },
]

const data2 =[{
		"period": "一月",
		"year": "2024年",
		"index005_P": 0.244242,
		"_origin": {
			"period": "1",
			"year": "2024"
		}
	},
	{
		"period": "二月",
		"year": "2024年",
		"Pre_index005_P": 33.480426,
		"_origin": {
			"period": "2",
			"year": "2024"
		}
	},
	{
		"period": "三月",
		"year": "2024年",
		"index005_P": 0.714506,
		"Pre_index005_P": 690.484725,
		"_origin": {
			"period": "3",
			"year": "2024"
		}
	}
]

chart
  .interval()
  .encode('x', 'period')
  .encode('y', 'index004_P')
  .data(data1)
  .encode('series', () => 'index004_P')
  .encode('color', () => 'index004_P')

chart
  .interval()
  .encode('x', 'period')
  .encode('y', 'Pre_index004_P')
  .data(data1)
  .encode('series', () => 'Pre_index004_P')
  .encode('color', () => 'Pre_index004_P')

// 折线1
chart
  .line()
  .encode('x', 'period')
  .encode('y', 'index005_P')
  .data(data2)
  .encode('shape', 'smooth')
  .style('stroke', '#fdae6b')
  .style('lineWidth', 2)
  .label({
    text: 'index005_P',
    position: 'top',
    fill: 'red', 
    transform: [
      {
        type: 'overlapDodgeY',
      },
    ],
  })
  .scale('y', { independent: true })
  .axis('y', {
    position: 'right',
    grid: null,
    title: 'index005_P',
    titleFill: '#555fff',
  })

// 折线2
chart
  .line()
  .encode('x', 'period')
  .encode('y', 'Pre_index005_P')
  .data(data2)
  .encode('shape', 'smooth')
  .style('stroke', '#fdae6b')
  .style('lineWidth', 2)
  .label({
    text: 'Pre_index005_P',
    position: 'top',
    fill: '#555fff', 
    dy: -10,
    // transform: [
    //   {
    //     type: 'overlapDodgeY',
    //   },
    // ],
  })
  .scale('y', { independent: true })
.axis('y', {
  position: 'right',
  grid: null,
  title: 'Pre_index005_P',
  titleFill: '#fdae6b',
});

chart.render()

Reproduction link / 复现链接

No response

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

Image

组合折线图会出现无数据时,标签显示字段名

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for maintainerTriage or intervention needed from a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0