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

Mixed charts - Zoomable time series & Multiple series – Group rows #639

Open
Stephen-Strange opened this issue Oct 21, 2024 · 3 comments

Comments

@Stephen-Strange
Copy link

Is it possible to combine Zoomable time series (type "line") & Multiple series – Group rows (type "rangeBar") to create a graph similar to this?

Screenshot 2024-10-21 at 12 01 55 PM

I have a sample code, but this is not working.

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

const MixedChart = () => {
  const options = {
    chart: {
      type: 'line',
      zoom: {
        enabled: true,
        type: 'x', // Zoom in on the x-axis (time axis)
        autoScaleYaxis: true,
      },
    },
    xaxis: {
      type: 'datetime', // Time-based x-axis for both charts
    },
    plotOptions: {
      bar: {
        horizontal: true, // Used for grouped rows (timeline)
      },
    },
    stroke: {
      width: [2, 2],
    },
    tooltip: {
      shared: true,
    },
    yaxis: [
      {
        title: {
          text: 'Time Series',
        },
      },
      {
        opposite: true,
        title: {
          text: 'Grouped Rows',
        },
      },
    ],
  };

  const series = [
    {
      name: 'Zoomable Time Series',
      type: 'line', // Time series as a line chart
      data: [
        [new Date('2023-01-01').getTime(), 30],
        [new Date('2023-01-02').getTime(), 40],
        [new Date('2023-01-03').getTime(), 35],
        [new Date('2023-01-04').getTime(), 50],
      ],
    },
    {
      name: 'Group Rows',
      type: 'rangeBar', // Group rows as rangeBar (timeline)
      data: [
        {
          x: 'Task 1',
          y: [
            new Date('2023-01-01').getTime(),
            new Date('2023-01-02').getTime(),
          ],
        },
        {
          x: 'Task 2',
          y: [
            new Date('2023-01-03').getTime(),
            new Date('2023-01-04').getTime(),
          ],
        },
      ],
    },
  ];

  return <Chart options={options} series={series} type="line" height={350} />;
};

export default MixedChart;

The following error is shown :

Screenshot 2024-10-21 at 12 08 14 PM

Versions used :
"react-apexcharts": "1.4.1",
"react": "17.0.1"
"next": "10.0.5",

@khjabir
Copy link

khjabir commented Oct 21, 2024

+1

1 similar comment
@steve-ragors
Copy link

+1

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants