Add Wordcloud Component #27
|
@ -150,11 +150,11 @@ const WordCloudWords: React.FC<WordCloudWordsProps> = ({
|
|||
random={fixedValueGenerator}
|
||||
|
||||
>
|
||||
{(cloudWords) =>
|
||||
a258wang marked this conversation as resolved
a258wang
commented
Any particular reason why a rectagular spiral, and not an archimedean spiral? (Maybe it'd be nice to be able to control this as a prop?) Any particular reason why a rectagular spiral, and not an archimedean spiral? (Maybe it'd be nice to be able to control this as a prop?)
snedadah
commented
Added it as a prop, our figma design matches the rectangular which is why I set that one. Added it as a prop, our figma design matches the rectangular which is why I set that one.
|
||||
cloudWords.map((word, i) => {
|
||||
cloudWords.map((word, index) => {
|
||||
return (
|
||||
<Text
|
||||
key={`wordcloud-word-${word.text ?? ""}`}
|
||||
fill={wordColors[i % wordColors.length]}
|
||||
key={`wordcloud-word-${word.text ?? ""}-${index}`}
|
||||
fill={wordColors[index % wordColors.length]}
|
||||
transform={`translate(${word.x ?? 0}, ${word.y ?? 0})`}
|
||||
fontSize={word.size}
|
||||
fontFamily={word.font}
|
||||
|
@ -173,13 +173,12 @@ const WordCloudWords: React.FC<WordCloudWordsProps> = ({
|
|||
|
||||
if (word.text) {
|
||||
showTooltip(
|
||||
{ text: word.text, value: data[i].value },
|
||||
{ text: word.text, value: data[index].value },
|
||||
eventSvgCoords.x -
|
||||
word.text.length * TOOLTIP_HORIZONTAL_SHIFT_SCALER,
|
||||
eventSvgCoords.y
|
||||
);
|
||||
}
|
||||
console.log(e, eventSvgCoords);
|
||||
}) as React.MouseEventHandler<SVGTextElement>
|
||||
}
|
||||
onMouseLeave={(_) => hideTooltip()}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"private": true,
|
||||
"engines": {
|
||||
"node": "^16",
|
||||
"npm": ">=7"
|
||||
"npm": "^8.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
|
@ -49,6 +49,16 @@ export default function Home() {
|
|||
right: 20,
|
||||
}}
|
||||
/>
|
||||
|
||||
<h2>
|
||||
<code>{"<WordCloud />"}</code>
|
||||
</h2>
|
||||
<WordCloud
|
||||
data={moreMockCategoricalData.map((word) => ({
|
||||
text: word.key,
|
||||
value: word.value,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
I'm not sure if we should add quotes around
Inconsolata
🤔we need the quotes here, this is in TSX, that issue is only for CSS.
Ahh, my concern is that this string eventually becomes an inline style:
Looking at staging the font seems to be okay, but I'm not sure if that's because it's inline or if it's because
Inconsolata
doesn't have any spaces or if it's because of something else. But also I just tried adding quotation marks to the HTMl and it didn't seem to do anything, so yeah we're probably fine. 😄