1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-10-17 04:17:26 +00:00
pds-2021-g2-nest/nest_frontend/components/base/BoxChart.js

57 lines
1.9 KiB
JavaScript
Raw Normal View History

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"
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-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-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-20 13:34:05 +00:00
}}
{...chartProps}
/>
2021-05-20 11:36:07 +00:00
</BoxFull>
)
}