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

Theme customisation not working. #6583

Open
ashwin-gairola opened this issue Jan 10, 2025 · 0 comments
Open

Theme customisation not working. #6583

ashwin-gairola opened this issue Jan 10, 2025 · 0 comments

Comments

@ashwin-gairola
Copy link

问题描述

It seems that registerTheme is no longer available as an export from @antv/g2.
I am trying to create a stacked bar chart with a custom palette for bars:

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

    chart
      .interval()
      .data(data)
      .theme({
        // Merely an example to demonstrate that this is not applying.
        category10: [
          "red",
          "red",
          "red",
          "red",
          "red",
          "red",
          "red",
          "red",
          "red",
          "red",
        ],
      })
      .encode("x", xAxis)
      .encode("y", yAxis)
      .encode("color", series)
      .transform({ type: "stackY" })
      .axis({
        x: {
          labelAutoHide: true,
          labelAutoRotate: false,
        },
      })
      .scale("color", { palette: "category10" })
      .interaction("elementHighlight", { background: true })
      .interaction("brushFilter", true);

    chart
      .render()
      .then(() => {})
      .catch(() => {});

The field category10 is not getting updated. Also, on calling chart.getTheme(), I'm seeing undefined. Something's clearly broken here.

Also, can you please update your documentation for theme customization? How do you even create a custom theme anymore if registerTheme no longer exissts? The docs are extremely outdated and reference v4 and not v5.

重现链接

https://codesandbox.io/p/sandbox/333923

重现步骤

Simply create a chart and try to customize the color palette. It will not get applied.

预期行为

As per the above example, all bars in the chart should appear red or whatever custom palette you provide.

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant