import React from 'react';
import { Box } from '@mui/material';
import { Bubble } from 'react-chartjs-2';
import { registerChartJS, commonChartOptions } from './chartutils';

registerChartJS();

const BubbleChart = () => {
  const data = {
    datasets: [
      {
        data: [
          { x: 10, y: 10, r: 10 },
          { x: 15, y: 5, r: 15 },
          { x: 26, y: 12, r: 23 },
          { x: 7, y: 8, r: 8 },
        ],
        label: 'Investment Equities',
        backgroundColor: 'rgba(255, 0, 0, 0.6)',
        borderColor: 'blue',
      },
      {
        data: [
          { x: 5, y: 15, r: 12 },
          { x: 20, y: 7, r: 8 },
          { x: 12, y: 18, r: 15 },
          { x: 8, y: 6, r: 10 },
        ],
        label: 'Investment Bonds',
        backgroundColor: 'rgba(0, 255, 0, 0.6)',
        borderColor: 'green',
      },
    ],
  };

  const options = {
    ...commonChartOptions,
    plugins: {
      title: {
        display: true,
        text: 'Bubble Chart',
      },
    },
    scales: {
      x: { min: 0, max: 30 },
      y: { min: 0, max: 30 },
    },
  };

  return (
    <Box sx={{ height: 400 }}>
      <Bubble data={data} options={options} />
    </Box>
  );
};

export default BubbleChart;