You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.5 KiB
98 lines
2.5 KiB
7 months ago
|
import React, { useEffect, useRef, useState } from "react"
|
||
|
import Highcharts from "highcharts"
|
||
|
import HighchartsReact from "highcharts-react-official"
|
||
|
import { Col, Row } from "reactstrap"
|
||
|
import { format_angka } from "../util"
|
||
|
const date = new Date()
|
||
|
const cBulan = date.getMonth() + 1
|
||
|
|
||
|
const Pembayaran = ({ dataSend }) => {
|
||
|
const base_url = "<?=base_url()?>"
|
||
|
|
||
|
const refChart = useRef(null)
|
||
|
const [dataC, setDataC] = useState(null)
|
||
|
const [dataMin1, setDataMin1] = useState(null)
|
||
|
const [dataMin2, setDataMin2] = useState(null)
|
||
|
|
||
|
useEffect(() => {
|
||
|
jQuery.get({
|
||
|
url: base_url + "kewilayahan/kytp/sebaranPembayaran",
|
||
|
dataType: "json",
|
||
|
type: "POST",
|
||
|
data: {
|
||
|
...dataSend,
|
||
|
tahun: date.getFullYear(),
|
||
|
bulan: cBulan
|
||
|
},
|
||
|
success: (data) => {
|
||
|
setDataC(data.dataC)
|
||
|
setDataMin1(data.dataMin1)
|
||
|
setDataMin2(data.dataMin2)
|
||
|
}
|
||
|
})
|
||
|
}, [dataSend])
|
||
|
|
||
|
const optionsChart = (data, title, type) => {
|
||
|
const total_wp = collect(data).sum("y")
|
||
|
return {
|
||
|
chart: {
|
||
|
plotBackgroundColor: null,
|
||
|
plotBorderWidth: null,
|
||
|
plotShadow: false,
|
||
|
type: "pie",
|
||
|
zoomType: "xy",
|
||
|
height: "300"
|
||
|
},
|
||
|
title: {
|
||
|
text: title,
|
||
|
style: { fontSize: "10px" }
|
||
|
},
|
||
|
tooltip: {
|
||
|
pointFormat: "<b>{point.percentage:.1f}%</b><br>Jml NPWP : {point.y} dari " + format_angka(total_wp)
|
||
|
},
|
||
|
accessibility: {
|
||
|
point: {
|
||
|
valueSuffix: "%"
|
||
|
}
|
||
|
},
|
||
|
plotOptions: {
|
||
|
pie: {
|
||
|
allowPointSelect: true,
|
||
|
cursor: "pointer",
|
||
|
//colors : warna_garis,
|
||
|
dataLabels: {
|
||
|
enabled: true,
|
||
|
style: { fontSize: "10px" },
|
||
|
format: "{point.name}: <br> {point.percentage:.1f} %"
|
||
|
}
|
||
|
// showInLegend: true
|
||
|
}
|
||
|
// series: pie_click
|
||
|
},
|
||
|
series: [
|
||
|
{
|
||
|
name: type,
|
||
|
data
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
return (
|
||
|
<>
|
||
|
<Row>
|
||
|
<Col>
|
||
|
<HighchartsReact ref={refChart} highcharts={Highcharts} options={optionsChart(dataC, "s.d. bulan ini", "C")} />
|
||
|
</Col>
|
||
|
<Col>
|
||
|
<HighchartsReact ref={refChart} highcharts={Highcharts} options={optionsChart(dataMin1, "s.d. bulan lalu", "Min1")} />
|
||
|
</Col>
|
||
|
<Col>
|
||
|
<HighchartsReact ref={refChart} highcharts={Highcharts} options={optionsChart(dataMin2, "s.d. 2 bulan yang lalu", "Min2")} />
|
||
|
</Col>
|
||
|
</Row>
|
||
|
</>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
export default Pembayaran
|