3

I am trying to fix the apex charts inside the container with full width like in the below image. I want to take the chart width to the marked space with green color, but I don't know if there is any attribute for the apex chart as I can see that the below month labels are more expanded than the chart. enter image description here

My chart component:

import React from "react";
import Chart from "react-apexcharts";

const BasicArea = ({ height = 350 }) => {
  const [isDark] = useDarkMode();
  const series = [
    { name: "Debit", data: [90, 70, 85, 60, 80, 70, 90, 75, 60, 80] },
    {
      name: "Credit",
      data: [60, 80, 70, 90, 75, 60, 80, 90, 70, 85],
    },
  ];

  const options = {
    chart: {
      toolbar: {
        show: false,
      },
    },
    dataLabels: {
      enabled: false,
    },
    legend: {
      show: true,
      position: "top",
      horizontalAlign: "right",
      fontSize: "12px",
      fontFamily: "Inter",
      offsetY: -0, // adjust this value
      markers: {
        width: 8,
        height: 8,
        offsetY: -1,
        offsetX: -5,
        radius: 12,
      },
      labels: {
        colors: isDark ? "#CBD5E1" : "#475569",
      },
      itemMargin: {
        horizontal: 18,
        vertical: 0,
      },
    },

    stroke: {
      curve: "smooth",
      width: 4,
    },
    colors: ["#4669FA", "#EC4899"], // set the colors for each series
    tooltip: {
      theme: "dark",
      shared: true, // enable shared tooltips to show data for both series
    },
    grid: {
      show: false,
      borderColor: isDark ? "#334155" : "#e2e8f0",
      strokeDashArray: 10,
      position: "back",
    },
    fill: {
      type: "gradient",
      gradient: {
        shadeIntensity: 1,
        opacityFrom: 0.4,
        opacityTo: 0.5,
        stops: [50, 100, 0],
      },
    },
    yaxis: {
      labels: {
        show: false,
        style: {
          colors: isDark ? "#CBD5E1" : "#475569",
          fontFamily: "Inter",
        },
      },
    },
    xaxis: {
      categories: [
        "Jan",
        "Feb",
        "Mar",
        "Apr",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec",
      ],
      labels: {
        style: {
          colors: isDark ? "#CBD5E1" : "#475569",
          fontFamily: "Inter",
        },
      },
      axisBorder: {
        show: false,
      },
      axisTicks: {
        show: false,
      },
    },
    padding: {
      top: 0,
      right: 0,
      bottom: 0,
      left: 0,
    },
  };

  return (
    <div>
      <Chart options={options} series={series} type="area" height={height} />
    </div>
  );
};

export default BasicArea;


And here is the parent component code where I am using this chart:

<div className="lg:col-span-7 xl:col-span-8 2xl:col-span-8 col-span-12">
          <div className="space-y-5 bank-table">
            <Card
              title="Transactions Trend"
              headerslot={<SelectMonth />}
              bodyClass="p-0"
            >
              <BasicArea height={height} />
              
              <div className=" w-4/5 flex justify-center items-center mx-auto">
                <Modal
                  title="Scrollable Content Modal"
                  label="See detailed report"
                  labelClass="btn-outline-primary block-btn mt-6 w-1/2"
                  uncontrol
                  scrollContent
                >
                  <TransactionsTable />
                </Modal>
              </div>
            </Card>
          </div>
        </div>
Steven
  • 231
  • 1
  • 8

0 Answers0