Visitor Statistics

This commit is contained in:
Roman Hergenreder 2020-07-01 21:10:25 +02:00
parent ce82eb0231
commit 23be9fb6d0
21 changed files with 2024 additions and 130 deletions

@ -4,7 +4,7 @@ namespace Api {
use Driver\SQL\Condition\Compare;
class ApiKeyAPI extends Request {
abstract class ApiKeyAPI extends Request {
protected function apiKeyExists($id) {
$sql = $this->user->getSQL();

@ -1,7 +1,7 @@
<?php
namespace Api {
class ContactAPI extends Request {
abstract class ContactAPI extends Request {
}
}

@ -4,7 +4,7 @@ namespace Api {
use Driver\SQL\Condition\Compare;
class GroupsAPI extends Request {
abstract class GroupsAPI extends Request {
protected function groupExists($name) {
$sql = $this->user->getSQL();

@ -2,7 +2,7 @@
namespace Api {
class LanguageAPI extends Request {
abstract class LanguageAPI extends Request {
}

@ -1,7 +1,7 @@
<?php
namespace Api {
class MailAPI extends Request {
abstract class MailAPI extends Request {
}
}

@ -1,7 +1,7 @@
<?php
namespace Api {
class NotificationsAPI extends Request {
abstract class NotificationsAPI extends Request {
}
}

@ -2,7 +2,7 @@
namespace Api {
class PermissionAPI extends Request {
abstract class PermissionAPI extends Request {
protected function checkStaticPermission() {
if (!$this->user->isLoggedIn() || !$this->user->hasGroup(USER_GROUP_ADMIN)) {
return $this->createError("Permission denied.");

@ -2,7 +2,7 @@
namespace Api {
class SettingsAPI extends Request {
abstract class SettingsAPI extends Request {
}

@ -34,39 +34,6 @@ class Stats extends Request {
return ($this->success ? $res[0]["count"] : 0);
}
private function getVisitorStatistics() {
$currentYear = getYear();
$firstMonth = $currentYear * 100 + 01;
$latsMonth = $currentYear * 100 + 12;
$sql = $this->user->getSQL();
$res = $sql->select($sql->count(), "month")
->from("Visitor")
->where(new Compare("month", $firstMonth, ">="))
->where(new Compare("month", $latsMonth, "<="))
->where(new Compare("count", 1, ">"))
->groupBy("month")
->orderBy("month")
->ascending()
->execute();
$this->success = $this->success && ($res !== FALSE);
$this->lastError = $sql->getLastError();
$visitors = array();
if ($this->success) {
foreach($res as $row) {
$month = $row["month"];
$count = $row["count"];
$visitors[$month] = $count;
}
}
return $visitors;
}
private function checkSettings() {
$req = new \Api\Settings\Get($this->user);
$this->success = $req->execute(array("key" => "^(mail_enabled|recaptcha_enabled)$"));
@ -88,11 +55,14 @@ class Stats extends Request {
$userCount = $this->getUserCount();
$pageCount = $this->getPageCount();
$visitorStatistics = $this->getVisitorStatistics();
$req = new \Api\Visitors\Stats($this->user);
$this->success = $req->execute(array("type"=>"monthly"));
$this->lastError = $req->getLastError();
if (!$this->success) {
return false;
}
$visitorStatistics = $req->getResult()["visitors"];
$loadAvg = "Unknown";
if (function_exists("sys_getloadavg")) {
$loadAvg = sys_getloadavg();

@ -0,0 +1,88 @@
<?php
namespace Api {
abstract class VisitorsAPI extends Request {
}
}
namespace Api\Visitors {
use Api\Parameter\Parameter;
use Api\Parameter\StringType;
use Api\VisitorsAPI;
use DateTime;
use Driver\SQL\Condition\Compare;
use Driver\SQL\Query\Select;
use Objects\User;
class Stats extends VisitorsAPI {
public function __construct(User $user, bool $externalCall = false) {
parent::__construct($user, $externalCall, array(
'type' => new StringType('type', 32),
'date' => new Parameter('date', Parameter::TYPE_DATE, true, new DateTime())
));
}
private function setConditions(string $type, DateTime $date, Select $query) {
if ($type === "yearly") {
$yearStart = $date->format("Y0000");
$yearEnd = $date->modify("+1 year")->format("Y0000");
$query->where(new Compare("day", $yearStart, ">="));
$query->where(new Compare("day", $yearEnd, "<"));
} else if($type === "monthly") {
$monthStart = $date->format("Ym00");
$monthEnd = $date->modify("+1 month")->format("Ym00");
$query->where(new Compare("day", $monthStart, ">="));
$query->where(new Compare("day", $monthEnd, "<"));
} else if($type === "weekly") {
$weekStart = ($date->modify("monday this week"))->format("Ymd");
$weekEnd = ($date->modify("sunday this week"))->format("Ymd");
$query->where(new Compare("day", $weekStart, ">="));
$query->where(new Compare("day", $weekEnd, "<="));
} else {
$this->createError("Invalid scope: $type");
}
}
public function execute($values = array()) {
if (!parent::execute($values)) {
return false;
}
$date = $this->getParam("date");
$type = $this->getParam("type");
$sql = $this->user->getSQL();
$query = $sql->select($sql->count(), "day")
->from("Visitor")
->where(new Compare("count", 1, ">"))
->groupBy("day")
->orderBy("day")
->ascending();
$this->setConditions($type, $date, $query);
if (!$this->success) {
return false;
}
$res = $query->execute();
$this->success = ($res !== FALSE);
$this->lastError = $sql->getLastError();
if ($this->success) {
$this->result["type"] = $type;
$this->result["visitors"] = array();
foreach($res as $row) {
$day = DateTime::createFromFormat("Ymd", $row["day"])->format("Y/m/d");
$count = $row["count"];
$this->result["visitors"][$day] = $count;
}
}
return $this->success;
}
}
}

@ -114,10 +114,10 @@ class CreateDatabase {
->foreignKey("user_id", "User", "uid");
$queries[] = $sql->createTable("Visitor")
->addInt("month")
->addInt("day")
->addInt("count", false, 1)
->addString("cookie", 26)
->unique("month", "cookie");
->unique("day", "cookie");
$queries[] = $sql->createTable("Route")
->addSerial("uid")
@ -191,7 +191,8 @@ class CreateDatabase {
->addRow("User/invite", array(USER_GROUP_ADMIN), "Allows users to create a new user and send them an invitation link")
->addRow("User/edit", array(USER_GROUP_ADMIN), "Allows users to edit details and group memberships of any user")
->addRow("User/delete", array(USER_GROUP_ADMIN), "Allows users to delete any other user")
->addRow("Permission/fetch", array(USER_GROUP_ADMIN), "Allows users to list all API permissions");
->addRow("Permission/fetch", array(USER_GROUP_ADMIN), "Allows users to list all API permissions")
->addRow("Visitors/stats", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT), "Allowes users to see visitor statistics");
return $queries;
}

@ -260,10 +260,10 @@ class User extends ApiObject {
}
$cookie = $_COOKIE["PHPSESSID"];
$month = (new DateTime())->format("Ym");
$day = (new DateTime())->format("Ymd");
$this->sql->insert("Visitor", array("cookie", "month"))
->addRow($cookie, $month)
$this->sql->insert("Visitor", array("cookie", "day"))
->addRow($cookie, $day)
->onDuplicateKeyStrategy(new UpdateStrategy(
array("month", "cookie"),
array("count" => new Add("Visitor.count", 1))))

1620
js/admin.min.js vendored

File diff suppressed because one or more lines are too long

@ -1,68 +0,0 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

68
src/package-lock.json generated

@ -3972,6 +3972,15 @@
"object-assign": "^4.1.1"
}
},
"create-react-context": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/create-react-context/-/create-react-context-0.3.0.tgz",
"integrity": "sha512-dNldIoSuNSvlTJ7slIKC/ZFGKexBMBrrcc+TTe1NdmROnaASuLPvqpwj9v4XS4uXZ8+YPu0sNmShX2rXI5LNsw==",
"requires": {
"gud": "^1.0.0",
"warning": "^4.0.3"
}
},
"cross-spawn": {
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
@ -4313,6 +4322,11 @@
}
}
},
"date-fns": {
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.14.0.tgz",
"integrity": "sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw=="
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
@ -6259,6 +6273,11 @@
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE="
},
"gud": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz",
"integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw=="
},
"gzip-size": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz",
@ -9389,6 +9408,11 @@
"ts-pnp": "^1.1.6"
}
},
"popper.js": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz",
"integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ=="
},
"portfinder": {
"version": "1.0.26",
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.26.tgz",
@ -10676,6 +10700,18 @@
"resolved": "https://registry.npmjs.org/react-collapse/-/react-collapse-5.0.1.tgz",
"integrity": "sha512-cN2tkxBWizhPQ2JHfe0aUSJtmMthKA17NZkTElpiQ2snQAAi1hssXZ2fv88rAPNNvG5ss4t0PbOZT0TIl9Lk3Q=="
},
"react-datepicker": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-3.0.0.tgz",
"integrity": "sha512-Yrxan1tERAiWS0EzitpiaiXOIz0APTUtV75uWbaS+jSaKoGCR6wUN2FDwr1ACGlnEoGhR9QQ2Vq3odnWtgJsOA==",
"requires": {
"classnames": "^2.2.6",
"date-fns": "^2.0.1",
"prop-types": "^15.7.2",
"react-onclickoutside": "^6.9.0",
"react-popper": "^1.3.4"
}
},
"react-dev-utils": {
"version": "10.2.1",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz",
@ -10963,6 +10999,25 @@
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"react-onclickoutside": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/react-onclickoutside/-/react-onclickoutside-6.9.0.tgz",
"integrity": "sha512-8ltIY3bC7oGhj2nPAvWOGi+xGFybPNhJM0V1H8hY/whNcXgmDeaeoCMPPd8VatrpTsUWjb/vGzrmu6SrXVty3A=="
},
"react-popper": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-1.3.7.tgz",
"integrity": "sha512-nmqYTx7QVjCm3WUZLeuOomna138R1luC4EqkW3hxJUrAe+3eNz3oFCLYdnPwILfn0mX1Ew2c3wctrjlUMYYUww==",
"requires": {
"@babel/runtime": "^7.1.2",
"create-react-context": "^0.3.0",
"deep-equal": "^1.1.1",
"popper.js": "^1.14.4",
"prop-types": "^15.6.1",
"typed-styles": "^0.0.7",
"warning": "^4.0.2"
}
},
"react-router": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
@ -13266,6 +13321,11 @@
"mime-types": "~2.1.24"
}
},
"typed-styles": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/typed-styles/-/typed-styles-0.0.7.tgz",
"integrity": "sha512-pzP0PWoZUhsECYjABgCGQlRGL1n7tOHsgwYv3oIiEpJwGhFTuty/YNeduxQYzXXa3Ge5BdT6sHYIQYpl4uJ+5Q=="
},
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
@ -13567,6 +13627,14 @@
"makeerror": "1.0.x"
}
},
"warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"requires": {
"loose-envify": "^1.0.0"
}
},
"watchpack": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.2.tgz",

@ -12,6 +12,7 @@
"react": "^16.13.1",
"react-chartjs-2": "^2.9.0",
"react-collapse": "^5.0.1",
"react-datepicker": "^3.0.0",
"react-dom": "^16.13.1",
"react-draft-wysiwyg": "^1.14.5",
"react-router-dom": "^5.2.0",

@ -114,4 +114,8 @@ export default class API {
async savePermissions(permissions) {
return this.apiCall("permission/save", { permissions: permissions });
}
async getVisitors(type, date) {
return this.apiCall("visitors/stats", { type: type, date: date });
}
};

@ -20,6 +20,7 @@ import EditUser from "./views/edituser";
import CreateGroup from "./views/addgroup";
import Settings from "./views/settings";
import PermissionSettings from "./views/permissions";
import Visitors from "./views/visitors";
class AdminDashboard extends React.Component {
@ -95,6 +96,7 @@ class AdminDashboard extends React.Component {
}}/>
<Route path={"/admin/user/permissions"}><PermissionSettings {...this.controlObj}/></Route>
<Route path={"/admin/group/add"}><CreateGroup {...this.controlObj} /></Route>
<Route path={"/admin/visitors"}><Visitors {...this.controlObj} /></Route>
<Route path={"/admin/logs"}><Logs {...this.controlObj} notifications={this.state.notifications} /></Route>
<Route path={"/admin/settings"}><Settings {...this.controlObj} /></Route>
<Route path={"/admin/pages"}><PageOverview {...this.controlObj} /></Route>

@ -25,6 +25,10 @@ export default function Sidebar(props) {
"name": "Dashboard",
"icon": "tachometer-alt"
},
"visitors": {
"name": "Visitor Statistics",
"icon": "chart-bar",
},
"users": {
"name": "Users & Groups",
"icon": "users"

@ -62,22 +62,26 @@ export default class Overview extends React.Component {
'#ff4444', '#ffbb33', '#00C851', '#33b5e5'
];
let data = new Array(12).fill(0);
const numDays = moment().daysInMonth();
let data = new Array(numDays).fill(0);
let visitorCount = 0;
for (let date in this.state.visitors) {
let month = parseInt(date) % 100 - 1;
if (month >= 0 && month < 12) {
if (this.state.visitors.hasOwnProperty(date)) {
let day = parseInt(date.split("/")[2]) - 1;
if (day >= 0 && day < numDays) {
let count = parseInt(this.state.visitors[date]);
data[month] = count;
data[day] = count;
visitorCount += count;
}
}
}
let labels = Array.from(Array(numDays), (_, i) => i + 1);
let chartOptions = {};
let chartData = {
labels: moment.monthsShort(),
labels: labels,
datasets: [{
label: 'Unique Visitors ' + moment().year(),
label: 'Unique Visitors ' + moment().format("MMMM"),
borderWidth: 1,
data: data,
backgroundColor: colors,
@ -159,7 +163,7 @@ export default class Overview extends React.Component {
<div className="icon">
<Icon icon={"chart-line"} />
</div>
<Link to={"/admin/statistics"} className="small-box-footer">More info <Icon icon={"arrow-circle-right"}/></Link>
<Link to={"/admin/visitors"} className="small-box-footer">More info <Icon icon={"arrow-circle-right"}/></Link>
</div>
</div>
</div>
@ -168,7 +172,7 @@ export default class Overview extends React.Component {
<div className="col-lg-6 col-12">
<div className="card card-info">
<div className="card-header">
<h3 className="card-title">Unique Visitors this year</h3>
<h3 className="card-title">Unique Visitors this month</h3>
<div className="card-tools">
<button type="button" className={"btn btn-tool"} onClick={(e) => {
e.preventDefault();

208
src/src/views/visitors.js Normal file

@ -0,0 +1,208 @@
import {Link} from "react-router-dom";
import * as React from "react";
import Alert from "../elements/alert";
import moment from 'moment'
import {Bar} from "react-chartjs-2";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
export default class Visitors extends React.Component {
constructor(props) {
super(props);
this.state = {
alerts: [],
date: new Date(),
type: 'monthly',
visitors: { }
};
this.parent = {
api: props.api,
}
}
componentDidMount() {
this.fetchData(this.state.type, this.state.date);
}
fetchData(type, date) {
this.setState({...this.state, type: type, date: date });
this.parent.api.getVisitors(type, moment(date).format("YYYY-MM-DD")).then((res) => {
if(!res.success) {
let alerts = this.state.alerts.slice();
alerts.push({ message: res.msg, title: "Error fetching Visitor Statistics" });
this.setState({ ...this.state, alerts: alerts });
} else {
this.setState({
...this.state,
visitors: res.visitors
});
}
});
}
removeError(i) {
if (i >= 0 && i < this.state.alerts.length) {
let alerts = this.state.alerts.slice();
alerts.splice(i, 1);
this.setState({...this.state, alerts: alerts});
}
}
showData(type) {
if (type === this.state.type) {
return;
}
this.fetchData(type, this.state.date);
}
createLabels() {
if (this.state.type === 'weekly') {
return moment.weekdays();
} else if(this.state.type === 'monthly') {
const numDays = moment().daysInMonth();
return Array.from(Array(numDays), (_, i) => i + 1);
} else if(this.state.type === 'yearly') {
return moment.monthsShort();
} else {
return [];
}
}
createTitle() {
if (this.state.type === 'weekly') {
return "Week " + moment(this.state.date).week();
} else if(this.state.type === 'monthly') {
return moment(this.state.date).format('MMMM');
} else if(this.state.type === 'yearly') {
return moment(this.state.date).format('YYYY');
} else {
return "";
}
}
fillData(data = []) {
for (let date in this.state.visitors) {
if (!this.state.visitors.hasOwnProperty(date)) {
continue;
}
let parts = date.split("/");
let count = parseInt(this.state.visitors[date]);
if (this.state.type === 'weekly') {
let day = moment(date).day();
if (day >= 0 && day < 7) {
data[day] = count;
}
} else if(this.state.type === 'monthly') {
let day = parseInt(parts[2]) - 1;
if (day >= 0 && day < data.length) {
data[day] = count;
}
} else if(this.state.type === 'yearly') {
let month = parseInt(parts[1]) - 1;
if (month >= 0 && month < 12) {
data[month] = count;
}
}
}
}
handleChange(date) {
this.fetchData(this.state.type, date);
}
render() {
let alerts = [];
for (let i = 0; i < this.state.alerts.length; i++) {
alerts.push(<Alert key={"error-" + i} onClose={() => this.removeError(i)} {...this.state.alerts[i]}/>)
}
const viewTypes = ["Weekly", "Monthly", "Yearly"];
let viewOptions = [];
for (let type of viewTypes) {
let isActive = this.state.type === type.toLowerCase();
viewOptions.push(
<label key={"option-" + type.toLowerCase()} className={"btn btn-secondary" + (isActive ? " active" : "")}>
<input type="radio" autoComplete="off" defaultChecked={isActive} onClick={() => this.showData(type.toLowerCase())} />
{type}
</label>
);
}
const labels = this.createLabels();
let data = new Array(labels.length).fill(0);
this.fillData(data);
let colors = [ '#ff4444', '#ffbb33', '#00C851', '#33b5e5' ];
const title = this.createTitle();
while (colors.length < labels.length) {
colors = colors.concat(colors);
}
let chartOptions = {};
let chartData = {
labels: labels,
datasets: [{
label: 'Unique Visitors ' + title,
borderWidth: 1,
data: data,
backgroundColor: colors
}],
maintainAspectRatio: false
};
return <>
<div className={"content-header"}>
<div className={"container-fluid"}>
<div className={"row mb-2"}>
<div className={"col-sm-6"}>
<h1 className={"m-0 text-dark"}>Visitor Statistics</h1>
</div>
<div className={"col-sm-6"}>
<ol className={"breadcrumb float-sm-right"}>
<li className={"breadcrumb-item"}><Link to={"/admin/dashboard"}>Home</Link></li>
<li className="breadcrumb-item active">Visitors</li>
</ol>
</div>
</div>
</div>
</div>
<section className={"content"}>
<div className={"container-fluid"}>
{alerts}
<div className={"row"}>
<div className={"col-4"}>
<p className={"mb-1 lead"}>Show data</p>
<div className="btn-group btn-group-toggle" data-toggle="buttons">
{viewOptions}
</div>
</div>
<div className={"col-4"}>
<p className={"mb-1 lead"}>Select date</p>
<DatePicker className={"text-center"} selected={this.state.date} onChange={(d) => this.handleChange(d)}
showMonthYearPicker={this.state.type === "monthly"}
showYearPicker={this.state.type === "yearly"} />
</div>
</div>
<div className={"row"}>
<div className={"col-12"}>
<div className="chart p-3">
<Bar data={chartData} options={chartOptions} height={100} />
</div>
</div>
</div>
</div>
</section>
</>
}
}