diff --git a/nest_frontend/components/base/BoxChart.js b/nest_frontend/components/base/BoxChart.js
index ebb7c93..b461342 100644
--- a/nest_frontend/components/base/BoxChart.js
+++ b/nest_frontend/components/base/BoxChart.js
@@ -1,60 +1,57 @@
import React, { useRef } from "react"
import BoxFull from "./BoxFull"
import ChartComponent from "react-chartjs-2"
+import Loading from "./Loading"
export default function BoxChart({chartProps, ...props}) {
- const boxContentsRef = useRef(null)
const getCssVar = (variable) => {
- const computedStyle = window.getComputedStyle(boxContentsRef.current)
- console.debug(variable, computedStyle.getPropertyValue(variable))
+ const computedStyle = window.getComputedStyle(document.querySelector("main"))
return computedStyle.getPropertyValue(variable).trim()
}
return (
-
- {boxContentsRef.current ?
-
+
- : null}
+ y: {
+ beginAtZero: true,
+ grid: {
+ borderColor: getCssVar("--bg-light"),
+ color: getCssVar("--bg-light"),
+ },
+ ticks: {
+ color: getCssVar("--fg-primary"),
+ }
+ },
+ },
+ elements: {
+ bar: {
+ backgroundColor: getCssVar("--fg-primary"),
+ borderColor: "transparent",
+ color: getCssVar("--fg-primary"),
+ },
+ },
+ plugins: {
+ legend: {
+ display: false,
+ }
+ }
+ }}
+ {...chartProps}
+ />
)
}
diff --git a/nest_frontend/components/interactive/BoxVisualizationChart.js b/nest_frontend/components/interactive/BoxVisualizationChart.js
index efda701..147dadd 100644
--- a/nest_frontend/components/interactive/BoxVisualizationChart.js
+++ b/nest_frontend/components/interactive/BoxVisualizationChart.js
@@ -1,19 +1,27 @@
import React from "react"
import BoxFull from "../base/BoxFull"
import BoxChart from "../base/BoxChart"
+import Empty from "./Empty"
export default function BoxVisualizationChart({ tweets, ...props }) {
// TODO: translate this
+
const hours = [...Array(24).keys()].map(hour => hour.toString())
const hourlyTweetCount = Array(24).fill(0)
for(const tweet of tweets) {
const insertDate = new Date(tweet["insert_time"])
const insertHour = insertDate.getHours()
- console.log(insertHour)
hourlyTweetCount[insertHour] += 1
}
+ if(tweets.length === 0) {
+ return (
+
+
+
+ )
+ }
return (
tweets.length,
[tweets],
@@ -42,12 +41,16 @@ export default function BoxVisualizationStats({ tweets, words, totalTweetCount,
)
const wordCount = useMemo(
- () => words.map(word => word.value).reduce((a, b) => a + b),
- [words],
+ () => {
+ if(words.length === 0) return 0
+ return words.map(word => word.value).reduce((a, b) => a + b)
+ },
+ [words]
)
const mostPopularWord = useMemo(
() => {
+ if(words.length === 0) return "❌"
return words.sort((wa, wb) => {
if(wa.value > wb.value) {
return -1
@@ -142,7 +145,7 @@ export default function BoxVisualizationStats({ tweets, words, totalTweetCount,
{uniqueUsersCount}
- {mostActiveUser.user} ({mostActiveUser.count} tweets)
+ {mostActiveUser ? `${mostActiveUser.user} (${mostActiveUser.count} tweet${mostActiveUser.count === 1 ? "" : "s"})` : "❌"}
diff --git a/nest_frontend/components/interactive/BoxVisualizationWordcloud.js b/nest_frontend/components/interactive/BoxVisualizationWordcloud.js
index 780e1a3..c61fccd 100644
--- a/nest_frontend/components/interactive/BoxVisualizationWordcloud.js
+++ b/nest_frontend/components/interactive/BoxVisualizationWordcloud.js
@@ -1,11 +1,21 @@
import React, { useContext } from "react"
import BoxWordcloud from "../base/BoxWordcloud"
import ContextLanguage from "../../contexts/ContextLanguage"
+import BoxFull from "../base/BoxFull"
+import Empty from "./Empty"
export default function BoxVisualizationWordcloud({ words, ...props }) {
const { strings } = useContext(ContextLanguage)
+ if(words.length === 0) {
+ return (
+
+
+
+ )
+ }
+
return (
)