plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.2k stars 1.03k forks source link

gridXValues and theme are not working on nivo/bar server side rendering #2368

Closed LinaLiao2021 closed 11 months ago

LinaLiao2021 commented 1 year ago

Describe/explain the bug It doesn't seem like the prop gridXValues and theme work on the @nivo/bar server side rendering. I tried version 0.60.0, 0.74.1 and 0.83.0

Example code

const barChartData = [
  { missedCallsCount: 54, outgoingCallsCount: 78, inComingCallsCount: 78, Name: "Olivia Bennett" },
  { missedCallsCount: 147, outgoingCallsCount: 153, inComingCallsCount: 153, Name: "Mason Sinclair" },
  { missedCallsCount: 125, outgoingCallsCount: 223, inComingCallsCount: 223, Name: "Isabella Morgan" },
  { missedCallsCount: 60, outgoingCallsCount: 64, inComingCallsCount: 64, Name: "Amelia Jenkins" },
  { missedCallsCount: 4, outgoingCallsCount: 102, inComingCallsCount: 102, Name: "Ethan Blackwood" },
]

const renderBarChart = () => {
  const props = {
    data: barChartData,
    width: 700,
    height: 400,
    indexBy: 'Name',
    keys: ['inComingCallsCount', 'outgoingCallsCount', 'missedCallsCount'],
    minValue: 'auto',
    maxValue: 'auto',
    colors: ["pink", "grey", "blue"],
    layout: 'horizontal',
    enableLabel: false,
    enableGridX: true,
    enableGridY: false,
    gridXValues: [0, 100, 200, 300, 400, 500],
    theme: {
      axis: {
        ticks: {
          text: {
            fontSize: 17,
            fill: "green",
            fontFamily: 'Arial, sans-serif',
            fontWeight: 500
          }
        }
      }
    },
    margin: {
      top: 100,
      right: 100,
      bottom: 40,
      left: 200
    },
    axisBottom: {
      tickValues: [0, 500]
    },

  }

  const rendered = renderToStaticMarkup(
    React.createElement(
      Bar,
      Object.assign(
        {
          animate: false,
          isInteractive: false,
        },
        props,
      )
    )
  );

  return `<?xml version="1.0" ?>${rendered}`;
};

Expected behavior

Screenshots Here is the svg generated on the server

Screenshot 2023-06-20 at 12 23 00 PM

stale[bot] commented 1 year ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] commented 11 months ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!