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

Issue with Legend Filters Resetting and Not Graying Out After Bar Click in <Column /> Chart #2678

Open
MadiAbhilash opened this issue Aug 30, 2024 · 1 comment

Comments

@MadiAbhilash
Copy link

Description: I am currently using the chart from the Ant Design Plots library. I am encountering the following issues:

Legend Filters Reset on Bar Click: When I click on a bar within the chart, the legend filters reset to their initial state, which is not the expected behavior.

Legend Items Not Graying Out After Filtering: After filtering by clicking on a legend item, the selected option does not gray out as expected. This creates confusion, as it's unclear which items have been filtered out.

Expected Behavior:
The legend filters should not reset to the initial state when a bar in the chart is clicked.
The legend items should properly gray out to reflect the current filter state, providing clear visual feedback on which items are active or inactive.

Steps to Reproduce:

  • Implement a chart with multiple legend items.
  • Click on a legend item to filter the data.
  • Observe that the filtered legend item is not grayed out.
  • Click on any bar in the chart and notice that the filters reset.
  • Screenshots: Here’s a screenshot showing the issue:

image

Environment:
Ant Design Plots Version: V2

Config

  const config: ColumnConfig = {
    data,
    theme,
    xField: ServerKeys.OBSERVATION_DATE,
    yField: ServerKeys.PRICE_INC,
    colorField: ServerKeys.OB_CARRIER,
    group: true,
    label: {
      textBaseline: "bottom",
      //@ts-ignore
      formatter: (v: number) => v ? `${CurrencySet?.[currencyCode] ?? currencyCode} ${v?.toLocaleString()}` : "",
    },
    axis: {
      y: { title: `${labels.price} (${currencyCode})` },
      x: { title: `${labels.observation} ${labels.date}` }
    },
    style: { width: 30, cursor: "pointer" },
    scale: {
      x: {
        type: "band",
        padding: 0.5,
      }
    },
    interaction: {
      tooltip: {
        wait: 300,
        render: (_: unknown, { title, items }: { title: string; items: { name: string; value: number; color: string }[] }) => {
          return `<div class="text-[10px] dark:text-white">
        <p>${title}</p>
        <ul>${items.map((o) => `<li class="flex justify-between items-center">
              <p class="flex justify-between items-center">
              <span style="background:${o.color}" class="size-2 mr-1"></span>
              <span>${o.name}</span></p>
              <span>${o.value.toLocaleString()}</span>
            </li>`).join(" ")}
        </ul>
      </div>`},
      },
      legendHighlight: true,
    },
    onReady: ({ chart }) => {
      chart.on("element:click", (e: PlotEvent) => {
        const { nativeEvent, data } = e;
        if (!nativeEvent) return;
        handleTargetModel(e);
      });
    },
    // annotations: [
    //   {
    //     type: "text",
    //     data: ["2024-08-27", 20_211],
    //     encode: {
    //       text: `▬▬▬`
    //     },
    //     style: { fill: "black", textAlign: "center" },
    //   }
    // ]
  };```
@lxfu1
Copy link
Member

lxfu1 commented Sep 6, 2024

Provide a reproduction link,please.

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

2 participants