2021-05-20 13:38:50 +00:00
|
|
|
import React from "react"
|
2021-05-20 11:36:07 +00:00
|
|
|
import BoxFull from "./BoxFull"
|
|
|
|
import ChartComponent from "react-chartjs-2"
|
|
|
|
|
|
|
|
|
2021-05-21 17:52:56 +00:00
|
|
|
export default function BoxChart({ chartProps, ...props }) {
|
2021-05-20 11:36:07 +00:00
|
|
|
const getCssVar = (variable) => {
|
2021-05-20 13:34:05 +00:00
|
|
|
const computedStyle = window.getComputedStyle(document.querySelector("main"))
|
2021-05-20 11:36:07 +00:00
|
|
|
return computedStyle.getPropertyValue(variable).trim()
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-05-20 13:34:05 +00:00
|
|
|
<BoxFull {...props}>
|
|
|
|
<ChartComponent
|
|
|
|
options={{
|
|
|
|
responsive: true,
|
|
|
|
scales: {
|
|
|
|
x: {
|
|
|
|
beginAtZero: true,
|
|
|
|
grid: {
|
|
|
|
borderColor: getCssVar("--bg-light"),
|
|
|
|
color: getCssVar("--bg-light"),
|
2021-05-20 11:36:07 +00:00
|
|
|
},
|
2021-05-20 13:34:05 +00:00
|
|
|
ticks: {
|
2021-05-20 11:36:07 +00:00
|
|
|
color: getCssVar("--fg-primary"),
|
2021-05-21 17:52:56 +00:00
|
|
|
},
|
2021-05-20 13:34:05 +00:00
|
|
|
},
|
|
|
|
y: {
|
|
|
|
beginAtZero: true,
|
|
|
|
grid: {
|
|
|
|
borderColor: getCssVar("--bg-light"),
|
|
|
|
color: getCssVar("--bg-light"),
|
2021-05-20 11:36:07 +00:00
|
|
|
},
|
2021-05-20 13:34:05 +00:00
|
|
|
ticks: {
|
|
|
|
color: getCssVar("--fg-primary"),
|
2021-05-21 17:52:56 +00:00
|
|
|
},
|
2021-05-20 13:34:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
elements: {
|
|
|
|
bar: {
|
|
|
|
backgroundColor: getCssVar("--fg-primary"),
|
|
|
|
borderColor: "transparent",
|
|
|
|
color: getCssVar("--fg-primary"),
|
2021-05-20 11:36:07 +00:00
|
|
|
},
|
2021-05-20 13:34:05 +00:00
|
|
|
},
|
|
|
|
plugins: {
|
|
|
|
legend: {
|
|
|
|
display: false,
|
2021-05-21 17:52:56 +00:00
|
|
|
},
|
|
|
|
},
|
2021-05-20 13:34:05 +00:00
|
|
|
}}
|
|
|
|
{...chartProps}
|
|
|
|
/>
|
2021-05-20 11:36:07 +00:00
|
|
|
</BoxFull>
|
|
|
|
)
|
|
|
|
}
|