import React from "react"; import {Doughnut, ChartData, ChartComponentProps, Line} from "react-chartjs-2"; import * as chartjs from "chart.js"; import {LANG} from "../../hooks/hook"; import {isEmpty} from "../../utils/utils"; import JDtable, {ReactTableDefault} from "../table/Table"; import {CellInfo} from "react-table"; export interface IGraphProps extends ChartComponentProps { JDtype: chartjs.ChartType | "list"; originalData?: any[]; } const JDgraph: React.FC = ({JDtype, data, originalData, ...prop}) => { const defaultDataSets = { labels: [LANG("none_data")], datasets: [ { data: [1], backgroundColor: "#CFCFCF", hoverBackgroundColor: "#b8b8b8" } ] }; const dataset = isEmpty(originalData) ? defaultDataSets : data; const columns = [ { Header: LANG("division"), accessor: "data", Cell: ({value, original, index}: CellInfo) => { // @ts-ignore return
{dataset.labels[index]}
; } }, { Header: LANG("sales"), accessor: "data", Cell: ({value, original}: CellInfo) => { return
{original}
; } } ]; switch (JDtype) { case "doughnut": return ; case "line": return ; case "list": return ( ); default: return
; } }; export default JDgraph;