diff --git a/package.json b/package.json index 6fbea17..483378e 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,8 @@ "antd": "^4.16.13", "axios": "^0.21.1", "bootstrap": "^4.3.1", - "chart.js": "^2.8.0", - "chartjs-plugin-datalabels": "^1.0.0", + "chart.js": "^3.9.1", + "chartjs-plugin-datalabels": "^2.1.0", "chartjs-plugin-zoom": "^0.7.7", "classnames": "^2.2.6", "core-js": "^3.1.4", @@ -64,7 +64,7 @@ "react-bootstrap-table2-paginator": "^2.1.0", "react-bootstrap-table2-toolkit": "^2.1.1", "react-calendar-timeline": "^0.27.0", - "react-chartjs-2": "^2.7.6", + "react-chartjs-2": "^4.3.1", "react-color": "^2.17.3", "react-content-loader": "^6.0.3", "react-dom": "^16.14.0", diff --git a/src/routes.js b/src/routes.js index 87b08be..bdca249 100644 --- a/src/routes.js +++ b/src/routes.js @@ -43,11 +43,13 @@ const TestGantt = React.lazy(() => import('./views/testgantt')); const UserAdmin = React.lazy(() => import('./views/Master/UserAdmin')); const UserShift = React.lazy(() => import('./views/SimproV2/UserShift')); const DashboardProject = React.lazy(() => import('./views/DashboardProject')); +const DashboardBOD = React.lazy(() => import('./views/Dashboard/DashboardBOD')); + const routes = [ { path: '/', exact: true, name: 'Home' }, { path: '/dashboard', name: 'Dashboard', component: Dashboard}, - + { path: '/dashboard-bod', name: 'DashboardBOD', component: DashboardBOD}, { path: '/projects', exact: true, name: 'Projects', component: CreatedProyek }, { path: '/projects/:id/:project/gantt', exact: true, name: 'Gantt', component: Gantt }, { path: '/human-resource', exact: true, name: 'Human Resource', component: ResourceWorker }, diff --git a/src/views/Dashboard/DashboardBOD.js b/src/views/Dashboard/DashboardBOD.js new file mode 100644 index 0000000..3705ab1 --- /dev/null +++ b/src/views/Dashboard/DashboardBOD.js @@ -0,0 +1,483 @@ +import React, { useEffect, useState } from 'react'; +import axios from 'axios' +import { Row, Col, Button } from 'antd'; +import { + Chart as ChartJS, + CategoryScale, + LineController, + LineElement, + LinearScale, + BarController, + BarElement, + PieController, + Title, + Tooltip, + Legend, + ArcElement +} from 'chart.js'; +// import Chart from 'chart.js/auto'; +import {Chart, Bar, Line, Pie } from 'react-chartjs-2'; +import ChartDataLabels from 'chartjs-plugin-datalabels'; + +ChartJS.register( + CategoryScale, + LineController, + LineElement, + LinearScale, + BarController, + BarElement, + PieController, + Title, + Tooltip, + Legend, + ArcElement, + ChartDataLabels +); + +const styles = { + cardContainer: {backgroundColor: '#F8F8F8', margin: 2, paddingLeft: 20, paddingRight: 20, paddingTop: 10}, + cardHeaderContainer: {display: 'flex', flexDirection: 'row', marginBottom: 10}, + cardChartContainer: {position: 'relative', height: '21vh', margin: 'auto', paddingBottom: 10, justifyContent: 'center'}, + cardTitle: {color: '#444444', fontSize: 16, fontWeight: 'bold'}, + cardSubtitle: {color: '#888888', fontSize: 12} +} + +const verticalBarChartOption = { + elements: { + bar: { + borderWidth: 2, + }, + }, + indexAxis: 'x', + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { + display: true, + position: 'right', + labels: { + boxWidth: 10 + } + }, + datalabels: { + color: '#FFFFFF' + } + } +} + +const horizontalBarChartOption = { + indexAxis: 'y', + elements: { + bar: { + borderWidth: 2, + }, + }, + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { + display: false, + }, + datalabels: { + color: '#FFFFFF' + } + } +} + +const pieChartOption = { + elements: { + pie: { + borderWidth: 2, + }, + }, + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { + display: true, + position: 'right', + labels: { + boxWidth: 10 + } + }, + datalabels: { + color: '#FFFFFF' + } + } +} + +const lineChartOption = { + elements: { + line: { + borderWidth: 2, + }, + }, + responsive: false, + plugins: { + datalabels: { + color: '#FFFFFF' + } + } +} + +const optionsExpenditure = { + indexAxis: 'y', + elements: { + bar: { + borderWidth: 2, + }, + }, + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { + display: false, + position: 'right', + labels: { + boxWidth: 10 + } + }, + datalabels: { + color: '#FFFFFF' + } + // title: { + // display: true, + // text: 'Chart.js Horizontal Bar Chart', + // }, + }, +}; + +const optionsScheduleHealthPerDivision = { + elements: { + bar: { + borderWidth: 2, + }, + }, + responsive: false, + plugins: { + legend: { + display: true, + position: 'top', + labels: { + boxWidth: 10 + } + }, + datalabels: { + color: '#FFFFFF' + } + } +} + +const dataExpenditure = { + labels: ['Total Budget', 'Expenditure', 'Invoice', 'Cash In'], + datasets: [ + { + label: '', + data: [302, 197, 197, 157], + borderColor: ['#480CA8', '#B5179E', '#A26A16', '#4C4747'], + backgroundColor: ['#480CA8', '#B5179E', '#A26A16', '#4C4747'], + borderRadius: 5, + borderSkipped: false + } + ], +}; + +const dataScheduleHealthPerDivision = { + labels: ['Telecommunication Solution Service', 'Telecommunication Solution Product', 'Energy Solution', 'Constructions'], + datasets: [ + { + label: "Behind Schedule", + data: [1, 0, 0, 0], + borderColor: '#E80053', + backgroundColor: '#E80053', + borderWidth: 2, + borderRadius: 20, + borderSkipped: false + }, + { + label: "Early Warning", + data: [2, 0, 1, 1], + borderColor: '#FFD600', + backgroundColor: '#FFD600', + borderWidth: 2, + borderRadius: 20, + borderSkipped: false + }, + { + label: "On Schedule", + data: [4, 2, 3, 1], + borderColor: '#52AC0B', + backgroundColor: '#52AC0B', + borderWidth: 2, + borderRadius: 20, + borderSkipped: false + } + ], +} + +const CardExpenditure = ({title, subtitle}) => { + return ( +
+
+
+
{title}
+
{subtitle}
+
+
+
Detailed View
+
+
+ +
+ +
+ +
+ ) +} +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') { + chart = + } + else if (chartType === 'line') { + chart = + } + + return ( +
+
+
+
{title}
+
{subtitle}
+
+
+ +
+ {chart} +
+ +
+ ) +} + +const CardScheduleHealthPerDivision = ({title, subtitle, chartData, chartOption}) => { + return ( +
+
+
+
{title}
+
{subtitle}
+
+
+
Budget
+
Schedule
+
+
+ +
+ +
+ +
+ ) +} + +const DashboardBOD = () => { + const token = localStorage.getItem("token") + const HEADER = { + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + } + } + + return ( +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ); +} + +export default DashboardBOD; diff --git a/src/views/Dashboard/graphProjectExpenditure.js b/src/views/Dashboard/graphProjectExpenditure.js deleted file mode 100644 index 32e95d8..0000000 --- a/src/views/Dashboard/graphProjectExpenditure.js +++ /dev/null @@ -1,65 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import axios from 'axios' -import { Bar } from 'react-chartjs-2'; - -const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; - -const data = { - labels, - datasets: [ - { - label: 'Dataset 1', - borderColor: 'rgb(255, 99, 132)', - backgroundColor: 'rgba(255, 99, 132, 0.5)', - data: [] - }, - { - label: 'Dataset 2', - borderColor: 'rgb(53, 162, 235)', - backgroundColor: 'rgba(53, 162, 235, 0.5)', - }, - ], -}; - - -const options = { - indexAxis: 'y', - elements: { - bar: { - borderWidth: 2, - }, - }, - responsive: true, - plugins: { - legend: { - position: 'right', - }, - title: { - display: true, - text: 'Chart.js Horizontal Bar Chart', - }, - }, -}; - -const DashboardPMO = () => { - const token = localStorage.getItem("token") - const HEADER = { - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - } - } - - return ( - <> -
- -
- - ); -} - -export default DashboardPMO; diff --git a/src/views/Dashboard/index.js b/src/views/Dashboard/index.js index 4a4b4fc..5c23e6c 100644 --- a/src/views/Dashboard/index.js +++ b/src/views/Dashboard/index.js @@ -1,147 +1,6 @@ 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 Dashboard = () => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -152,56 +11,9 @@ const DashboardPMO = () => { return (
- - - - - - - - - - - - - - - - - - + Dashboard
); } -export default DashboardPMO; +export default Dashboard; diff --git a/src/views/Map/Map.js b/src/views/Map/Map.js index 40049f1..a363508 100644 --- a/src/views/Map/Map.js +++ b/src/views/Map/Map.js @@ -87,9 +87,66 @@ import Loader from 'react-loader-spinner' import "react-loader-spinner/dist/loader/css/react-spinner-loader.css" import * as alasql from 'alasql'; import * as lodash from 'lodash'; -import { Pie, Line } from 'react-chartjs-2'; +// import { +// Chart, +// ArcElement, +// LineElement, +// BarElement, +// PointElement, +// BarController, +// BubbleController, +// DoughnutController, +// LineController, +// PieController, +// PolarAreaController, +// RadarController, +// ScatterController, +// CategoryScale, +// LinearScale, +// LogarithmicScale, +// RadialLinearScale, +// TimeScale, +// TimeSeriesScale, +// Decimation, +// Filler, +// Legend, +// Title, +// Tooltip, +// SubTitle +// } from 'chart.js'; + +// Chart.register( +// ArcElement, +// LineElement, +// BarElement, +// PointElement, +// BarController, +// BubbleController, +// DoughnutController, +// LineController, +// PieController, +// PolarAreaController, +// RadarController, +// ScatterController, +// CategoryScale, +// LinearScale, +// LogarithmicScale, +// RadialLinearScale, +// TimeScale, +// TimeSeriesScale, +// Decimation, +// Filler, +// Legend, +// Title, +// Tooltip, +// SubTitle +// ); +import { Chart, LineController, LineElement, PointElement, LinearScale, Title } from 'chart.js' +// import { Pie, Line } from 'react-chartjs-3'; import numeral from 'numeral'; +Chart.register(LineController, LineElement, PointElement, LinearScale, Title); + const MappifiedNominatimSearch = mappify(NominatimSearch); const MappifiedMeasureButton = mappify(MeasureButton); const Map = mappify(onDropAware(MapComponent)); @@ -1994,7 +2051,7 @@ class SiopasMap extends Component { Persentase Progress Proyek x - console.log('click persentase linechart')} - /> + /> */} @@ -2035,7 +2092,7 @@ class SiopasMap extends Component { Progress Cost Perencanaan dan Realisasi x - + /> */} @@ -2079,7 +2136,7 @@ class SiopasMap extends Component { {/* */} - + /> */} @@ -2100,7 +2157,7 @@ class SiopasMap extends Component { Status Pengawas Lapangan x - + /> */}