ChartRadarB.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React, { Component } from "react";
  2. import ContentWrapper from "@/components/Layout/ContentWrapper";
  3. import { Container, Row, Col, Card, CardHeader, CardBody } from "reactstrap";
  4. import { connect } from "react-redux";
  5. import { jumlahLaporan } from "@/actions/pelaporan";
  6. import dynamic from "next/dynamic";
  7. import { getjumlahStatusLaporan } from "../../actions/graph";
  8. const ReactApexChart = dynamic(() => import("react-apexcharts"), { ssr: false });
  9. class ChartRadarB extends React.Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. series: [
  14. {
  15. name: 'Keberatan',
  16. data: [8, 6, 8, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 3],
  17. },
  18. {
  19. name: 'Banding',
  20. data: [4, 6, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 4],
  21. }
  22. , {
  23. name: 'Pemantauan Perbaikan',
  24. data: [4, 6, 8, 4, 5, 6, 7, 8, 8, 9, 3, 4, 5, 6, 7, 3],
  25. }
  26. , {
  27. name: 'Pencabutan Sanksi',
  28. data: [4, 6, 6, 9, 8, 7, 6, 3, 2, 1, 8, 5, 4, 3, 6, 7],
  29. colors: "#B2B0D2",
  30. },],
  31. options: {
  32. chart: {
  33. height: 150,
  34. type: 'radar',
  35. },
  36. xaxis: {
  37. categories: ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI"]
  38. },
  39. chart: {
  40. toolbar: {
  41. show: true,
  42. tools: {
  43. download: false,
  44. },
  45. },
  46. },
  47. // legend: {
  48. // show: false,
  49. // }
  50. },
  51. };
  52. }
  53. async componentDidMount() {
  54. const { token } = this.props;
  55. const data = await getjumlahStatusLaporan(this.props.token);
  56. this.setState((prevState) => ({
  57. ...prevState,
  58. series: [{ data: data.data.map((e) => e.jumlah_keberatan), name: "Keberatan" }
  59. , { data: data.data.map((e) => e.jumlah_banding), name: "Banding" },
  60. { data: data.data.map((e) => e.jumlah_pemantauan_perbaikan), name: "Pemantauan perbaikan" },
  61. { data: data.data.map((e) => e.jumlah_pencabutan_sanksi), name: "Pencabutan sanksi" }],
  62. options: {
  63. ...prevState,
  64. xaxis: {
  65. categories: data.data.map((data) => data.pembina.name),
  66. },
  67. },
  68. }));
  69. }
  70. render() {
  71. return (
  72. <Card className="card-default">
  73. <CardBody>
  74. <div id="chart">
  75. <ReactApexChart options={this.state.options} series={this.state.series} type="radar" height={400} />
  76. </div>
  77. </CardBody>
  78. </Card>
  79. );
  80. }
  81. }
  82. const MapStateToProps = (state) => ({ token: state.token });
  83. export default connect(MapStateToProps)(ChartRadarB);