ChartdataHome.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 Sparkline from "@/components/Common/Sparklines.js";
  5. import FlotChart from "@/components/Charts/Flot.js";
  6. import { connect } from "react-redux";
  7. import { getPengunjung } from "@/actions/pengunjung";
  8. class ChartdataHome extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. dataPengunjung: [],
  13. };
  14. }
  15. ChartSpline = {
  16. data: [
  17. {
  18. // label: "Uniques",
  19. color: "#3e3a8e",
  20. data: [
  21. ["1", 20],
  22. ["10", 90],
  23. ["20", 40],
  24. ["30", 60],
  25. ],
  26. },
  27. ],
  28. options: {
  29. series: {
  30. lines: {
  31. show: false,
  32. },
  33. points: {
  34. show: true,
  35. radius: 4,
  36. },
  37. splines: {
  38. show: true,
  39. tension: 0.4,
  40. lineWidth: 1,
  41. fill: 0.5,
  42. },
  43. },
  44. grid: {
  45. borderColor: "#eee",
  46. borderWidth: 1,
  47. hoverable: true,
  48. backgroundColor: "#fcfcfc",
  49. },
  50. tooltip: true,
  51. tooltipOpts: {
  52. content: (label, x, y) => x + " : " + y,
  53. },
  54. xaxis: {
  55. tickColor: "#fcfcfc",
  56. mode: "categories",
  57. },
  58. yaxis: {
  59. min: 0,
  60. max: 150, // optional: use it for a clear represetation
  61. tickColor: "#eee",
  62. //position: 'right' or 'left',
  63. tickFormatter: (v) => v /* + ' visitors'*/,
  64. },
  65. shadowSize: 0,
  66. },
  67. };
  68. render() {
  69. console.log(this.state.dataPengunjung);
  70. return (
  71. <Col lg={12}>
  72. <Card>
  73. <CardBody>
  74. <FlotChart
  75. options={this.ChartSpline.options}
  76. data={this.ChartSpline.data}
  77. className="flot-chart"
  78. height="150px"
  79. width="350px"
  80. />
  81. </CardBody>
  82. <div align="center">
  83. <h5 className="font-weight-bold">Data Statistik Pengunjung Bulan<span> Juli</span></h5>
  84. </div>
  85. </Card>
  86. </Col>
  87. );
  88. }
  89. }
  90. const mapStateToProps = (state) => ({ token: state.token });
  91. export default connect(mapStateToProps)(ChartdataHome);