Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] series.encode maps to incorrect values when key is missing in first datapoint #20340

Closed
jamesp-v opened this issue Sep 12, 2024 · 1 comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.

Comments

@jamesp-v
Copy link

Version

5.5.1

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=PYBwLglsB2AEC8sDeAoWsDOBTAThLGAXLANprrLkWzQCGAtlsQEQCCGEtzANFRVtADGwACZNK1agE8WtDlz7oAvr0mwwUkOOYAjWjmZ8VfVGrqMWrAGZ5BXVZIHCxxU2tgzYzWjYh3DasZqGlosegZGDuhu1ObaAKIArjigWDyKsE6i4jGSnsxYyakBkkGSIdrhJcrkALoOAB6sDRBEEhQVLHZgWADmwDhSJWVSza2ufJ1eAG60ADaJaeRlYMDAc5AgE9RgeL29uLItGMMOIrRgclhgxGTUuegYwMmC4nfuD3lY-iwAjACcAFYAAzpdwUOScYgANgATFF3D5bLRiABmAAsCLUAHpsZkiqFYAAOLGSXH4lKExLQMRWCDQLAiUnKZntcFSb44P7_aGg1noSEo2DQkkZahIvxC1H_fkU1LEX7A1llNSfaSc7kAdj5Yoh8mIRKVuoFvjsxEB8ONcsJv1huqUGVqRjqKCUQA

Steps to Reproduce

Use chart option:

option = {
  series: [
    {
      name: "Asia",
      encode: {
        y: "asia"
      },
      type: "bar"
    },
    {
      name: "Africa",
      encode: {
        y: "africa"
      },
      type: "bar"
    },
    {
      name: "Europe",
      encode: {
        y: "europe"
      },
      type: "bar"
    }
  ],
  xAxis: {
    type: "category"
  },
  yAxis: {
    type: "value"
  },
  tooltip: {
    trigger: "axis"
  },
  dataset: [
    {
      source: [
        {
          year: "1950",
          asia: 62,
          africa: 34,
          // europe: 8,
          // europe: undefined,
        },
        {
          year: "1960",
          asia: 68,
          africa: 39,
          europe: 10,
        },
        {
          year: "1970",
          asia: 80,
          africa: 52,
          europe: 12
        }
      ]
    }
  ]
}

Current Behavior

Given this source dataset where one of the keys is missing on the first datapoint:

[
  {
    year: "1950",
    asia: 62,
    africa: 34,
    // europe: 8,
    // europe: undefined,
  },
  {
    year: "1960",
    asia: 68,
    africa: 39,
    europe: 10,
  },
  {
    year: "1970",
    asia: 80,
    africa: 52,
    europe: 12
  }
]

The "Europe" series will incorrectly use the values of the "Asia" series.

Expected Behavior

The "Europe" series should display as if it were undefined ("-") for year 1950, and should display its correct values (10 and 12) for 1960 and 1970 respectively.

Environment

- OS: macOS Sonoma
- Browser: Chrome 128.0.6613.121
- Framework: N/A

Any additional comments?

No response

@jamesp-v jamesp-v added the bug label Sep 12, 2024
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Sep 12, 2024
@helgasoft
Copy link

encode needs dimensions to work correctly. Please see official example for a simpler way of using dataset.
📌 please close issue if problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.
Projects
None yet
Development

No branches or pull requests

2 participants