Skip to content
Snippets Groups Projects
LineGraph.tsx 839 B
import React, { ReactElement } from 'react';
import { Line } from 'react-chartjs-2';


import {
  Chart as ChartJS,
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Title,
  Tooltip,
  Legend,
} from 'chart.js';
import { BasicDataset } from "../../Schema";


ChartJS.register(
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Title,
  Tooltip,
  Legend
);

const options = {
  responsive: true,
  animation: {
    duration: 0
  },
  plugins: {
    legend: {
      position: 'top' as const,
      onClick: () => { /* intentionally empty */ },
    },
    title: {
      display: true,
      text: '',
    },
  },
};

interface inputProps {
  data: BasicDataset
}

function LineGraph({ data }: inputProps): ReactElement {
  return (
    <Line data={data} options={options} />
  );
}

export default LineGraph;