2021-05-18 00:04:06 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-05-15 16:05:13 +00:00
|
|
|
import BoxFull from "../base/BoxFull"
|
2021-05-17 15:05:19 +00:00
|
|
|
import ReactWordcloud from "@steffo/nest-react-wordcloud"
|
2021-05-18 00:04:06 +00:00
|
|
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
2021-05-15 16:05:13 +00:00
|
|
|
|
|
|
|
|
2021-05-16 21:14:28 +00:00
|
|
|
/**
|
|
|
|
* A Box which displays a wordcloud.
|
|
|
|
*
|
|
|
|
* @param words - A list of word objects, made of a string "text" and a number "value"
|
|
|
|
* @param props - Additional props to pass to the box.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
export default function BoxWordcloud({ words, props }) {
|
2021-05-18 00:48:34 +00:00
|
|
|
const { strings } = useContext(ContextLanguage)
|
2021-05-18 00:04:06 +00:00
|
|
|
|
2021-05-15 16:05:13 +00:00
|
|
|
return (
|
2021-05-18 00:04:06 +00:00
|
|
|
<BoxFull header={strings.wordcloud} {...props}>
|
2021-05-18 00:48:34 +00:00
|
|
|
<div style={{ "width": "100%", "height": "100%" }}>
|
2021-05-15 16:05:13 +00:00
|
|
|
<ReactWordcloud
|
|
|
|
options={{
|
|
|
|
colors: [
|
|
|
|
"var(--fg-primary)",
|
|
|
|
],
|
|
|
|
fontFamily: "Bree Serif",
|
2021-05-18 17:37:32 +00:00
|
|
|
fontSizes: [16, 48],
|
2021-05-15 16:05:13 +00:00
|
|
|
size: undefined,
|
|
|
|
deterministic: true,
|
|
|
|
}}
|
2021-05-16 21:14:28 +00:00
|
|
|
words={words}
|
2021-05-15 16:05:13 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</BoxFull>
|
|
|
|
)
|
|
|
|
}
|