/* * QQQ - Low-code Application Framework for Engineers. * Copyright (C) 2021-2022. Kingsrook, LLC * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States * contact@kingsrook.com * https://github.com/Kingsrook/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ import Card from "@mui/material/Card"; import Divider from "@mui/material/Divider"; import Icon from "@mui/material/Icon"; import parse from "html-react-parser"; import {useMemo} from "react"; import {Bar} from "react-chartjs-2"; import MDBox from "qqq/components/Temporary/MDBox"; import MDTypography from "qqq/components/Temporary/MDTypography"; import {GenericChartDataSingleDataset} from "qqq/pages/dashboards/Widgets/Data/GenericChartDataSingleDataset"; /////////////////////////// // options for bar chart // /////////////////////////// const options = { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false, }, }, interaction: { intersect: false, mode: "index", }, scales: { y: { grid: { drawBorder: false, display: true, drawOnChartArea: true, drawTicks: false, borderDash: [5, 5], color: "rgba(255, 255, 255, .2)", }, ticks: { suggestedMin: 0, suggestedMax: 500, beginAtZero: true, padding: 10, font: { size: 14, weight: 300, family: "Roboto", style: "normal", lineHeight: 2, }, color: "#fff", }, }, x: { grid: { drawBorder: false, display: true, drawOnChartArea: true, drawTicks: false, borderDash: [5, 5], color: "rgba(255, 255, 255, .2)", }, ticks: { display: true, color: "#f8f9fa", padding: 10, font: { size: 14, weight: 300, family: "Roboto", style: "normal", lineHeight: 2, }, }, }, }, }; //////////////////////////////////// // define properties and defaults // //////////////////////////////////// interface Props { color?: "primary" | "secondary" | "info" | "success" | "warning" | "error" | "dark"; title: string; description?: string; date: string; data: GenericChartDataSingleDataset; } BarChart.defaultProps = { color: "dark", description: "", }; function getChartData(labels: any, dataset: any) { return { chartData: { labels, datasets: [ { label: dataset?.label, tension: 0.4, borderWidth: 0, borderRadius: 4, borderSkipped: false, backgroundColor: "rgba(255, 255, 255, 0.8)", data: dataset?.data, maxBarThickness: 6, }, ], } }; } function BarChart({color, title, description, date, data}: Props): JSX.Element { ///////////////////////////////////////////////////////// // enrich data with expected customizations and styles // ///////////////////////////////////////////////////////// const {chartData} = getChartData(data?.labels, data?.dataset); return ( {useMemo( () => ( ), [data, color] )} {title} {parse(description)} schedule {date} ); } export default BarChart;