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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃Display last axis label on Column plot when having many entries #2492

Open
aniov opened this issue Apr 9, 2024 · 0 comments
Open

馃Display last axis label on Column plot when having many entries #2492

aniov opened this issue Apr 9, 2024 · 0 comments

Comments

@aniov
Copy link

aniov commented Apr 9, 2024

馃 When having many entries in column chart last axis X label is not rendered. Depending on number of items generated the last label is either displayed or partially or not at all.

My question is how to display first and last X axis label that will work with any amount of data.
Thank you.

version: "@ant-design/plots": "2.1.15"

馃捇 https://stackblitz.com/edit/react-q41buy?file=index.js

馃殤

image

function generateData(numEntries) {
  const dataEntries = [];
  let currentDate = new Date(); // Start with today's date

  // Generate data entries with consecutive dates
  for (let i = 0; i < numEntries; i++) {
    const newValue = Math.random() * 100; // Random value between 0 and 100
    const dataEntry = {
      date: new Date(currentDate).toLocaleDateString(),
      value: newValue,
    };
    dataEntries.push(dataEntry);
    currentDate.setDate(currentDate.getDate() + 1); // Increment date by one day
  }

  return dataEntries;
}

const DemoColumn = () => {
  const config = {
    data: generateData(250),
    xField: 'date',
    yField: 'value',
    axis: {
      x: {
        labelAutoRotate: false,
        labelAutoHide: true,
        labelFilter: (d, index, data) =>
          index === 0 || index === data?.length - 1,
        tick: false,
      },
    },
  };
  return <Column {...config} />;
};
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