From 7dd27b21b4f45cda98c786cc6f494c0fe25ea642 Mon Sep 17 00:00:00 2001 From: ardhi Date: Wed, 21 Sep 2022 14:59:07 +0700 Subject: [PATCH] add dashboard BoD --- src/views/Dashboard/index.js | 193 ++++++++++++++++++++++++++++++++++- 1 file changed, 190 insertions(+), 3 deletions(-) diff --git a/src/views/Dashboard/index.js b/src/views/Dashboard/index.js index dbaae25..4a4b4fc 100644 --- a/src/views/Dashboard/index.js +++ b/src/views/Dashboard/index.js @@ -1,5 +1,145 @@ import React, { useEffect, useState } from 'react'; import axios from 'axios' +import { Row, Col, Button } from 'antd'; +// import { +// Chart as ChartJS, +// CategoryScale, +// LinearScale, +// BarElement, +// Title, +// Tooltip, +// Legend, +// } from 'chart.js'; +import { Bar, HorizontalBar } from 'react-chartjs-2'; + +// ChartJS.register( +// CategoryScale, +// LinearScale, +// BarElement, +// Title, +// Tooltip, +// Legend +// ); + +const verticalBarChartOption = { + elements: { + bar: { + borderWidth: 2, + }, + }, + maintainAspectRatio: false, + responsive: true, + legend: { + display: true, + position: 'right' + }, +} + +const horizontalBarChartOption = { + elements: { + bar: { + borderWidth: 2, + }, + }, + responsive: false, + legend: { + display: false + } +} + +const optionsExpenditure = { + indexAxis: 'y', + elements: { + bar: { + borderWidth: 2, + }, + }, + responsive: false, + legend: { + display: false + }, + // plugins: { + // legend: { + // position: 'right', + // }, + // title: { + // display: true, + // text: 'Chart.js Horizontal Bar Chart', + // }, + // }, +}; +const labelsExpenditure = ['Total Budget', 'Expenditure', 'Invoice', 'Cash In']; +const dataExpenditure = { + labels: labelsExpenditure, + datasets: [ + { + label: '', + data: [302, 197, 197, 157], + borderColor: 'rgb(255, 99, 132)', + backgroundColor: 'rgba(255, 99, 132, 0.5)', + } + ], +}; +const CardExpenditure = ({title, subtitle}) => { + return ( +
+
+
+
{title}
+
{subtitle}
+
+
+ +
+
+ +
+ +
+ +
+ ) +} +const CardDashboard = ({title, subtitle, chartType, chartData, chartOption}) => { + let chart = null; + if (chartType === 'vertical-bar') { + chart = + } + else if (chartType === 'horizontal-bar') { + chart = + } + else if (chartType === 'pie') { + + } + else if (chartType === 'line') { + + } + else if (chartType === '') { + + } + + return ( +
+
+
+
{title}
+
{subtitle}
+
+
+ +
+ {chart} +
+ +
+ ) +} const DashboardPMO = () => { const token = localStorage.getItem("token") @@ -11,9 +151,56 @@ const DashboardPMO = () => { } return ( - <> -
- +
+ + + + + + + + + + + + + + + + + + +
); }