0

question for Nivo library users.

I'm trying to implement a feature where you can brush and zoom line charts, something like this: https://bl.ocks.org/mbostock/34f08d5e11952a80609169b7917d4172

Since Nivo doesn't support this, has anyone found a solution to have dynamic dates(meaning you don't have to manually add X nodes), as AxisX where they are populated by dates that comes from backend.

export const LineChart = () => {
const data = [
    {
      id: "japan",
      color: "blue",

      data: [
        {
          x: "Jan",
          y: 100,
        },
        {
          x: "Feb",
          y: 130,
        },
        {
          x: "Mar",
          y: 80,
        },
        {
          x: "Apr",
          y: 130,
        },
        {
          x: "May",
          y: 30,
        },
        {
          x: "Jun",
          y: 90,
        },
        {
          x: "Jul",
          y: 110,
        },
      ],
    },
  ];

  return (
        <ChartCard title="Meetings">
          <ResponsiveLine
            data={data}
            colors="#156C79"
            lineWidth={1}
            margin={{ top: 30, right: 30, bottom: 50, left: 60 }}
            axisBottom={{
              tickSize: 0,
              tickPadding: 10,
            }}
            axisLeft={{
              tickSize: 0,
              tickPadding: 25,
            }}
            enableGridY={false}
            enablePoints={false}
            enableArea={true}
            areaOpacity={1}
            curve="cardinal"
            theme={{
              textColor: "#9C9C9C",
            }}
            defs={[
              {
                id: "gradientC",
                type: "linearGradient",
                colors: [
                  { offset: 20, color: "#13807E" },
                  { offset: 100, color: "#00EA96" },
                ],
              },
            ]}
            fill={[{ match: "*", id: "gradientC" }]}
          />
        </ChartCard>
  );
};

Thanks

  • Please provide enough code so others can better understand or reproduce the problem. – Jay Nov 21 '22 at 07:12

0 Answers0