More pr comment
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Shahan Nedadahandeh 2022-08-02 20:24:14 -07:00
parent d2f9946fcc
commit 8f2c390dbd
Signed by: snedadah
GPG Key ID: 8638C7F917385B01
3 changed files with 15 additions and 6 deletions

View File

@ -150,11 +150,11 @@ const WordCloudWords: React.FC<WordCloudWordsProps> = ({
random={fixedValueGenerator} random={fixedValueGenerator}
> >
{(cloudWords) => {(cloudWords) =>
cloudWords.map((word, i) => { cloudWords.map((word, index) => {
return ( return (
<Text <Text
key={`wordcloud-word-${word.text ?? ""}`} key={`wordcloud-word-${word.text ?? ""}-${index}`}
fill={wordColors[i % wordColors.length]} fill={wordColors[index % wordColors.length]}
transform={`translate(${word.x ?? 0}, ${word.y ?? 0})`} transform={`translate(${word.x ?? 0}, ${word.y ?? 0})`}
fontSize={word.size} fontSize={word.size}
fontFamily={word.font} fontFamily={word.font}
@ -173,13 +173,12 @@ const WordCloudWords: React.FC<WordCloudWordsProps> = ({
if (word.text) { if (word.text) {
showTooltip( showTooltip(
{ text: word.text, value: data[i].value }, { text: word.text, value: data[index].value },
eventSvgCoords.x - eventSvgCoords.x -
word.text.length * TOOLTIP_HORIZONTAL_SHIFT_SCALER, word.text.length * TOOLTIP_HORIZONTAL_SHIFT_SCALER,
eventSvgCoords.y eventSvgCoords.y
); );
} }
console.log(e, eventSvgCoords);
}) as React.MouseEventHandler<SVGTextElement> }) as React.MouseEventHandler<SVGTextElement>
} }
onMouseLeave={(_) => hideTooltip()} onMouseLeave={(_) => hideTooltip()}

View File

@ -4,7 +4,7 @@
"private": true, "private": true,
"engines": { "engines": {
"node": "^16", "node": "^16",
"npm": ">=7" "npm": "^8.0.0"
}, },
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@ -49,6 +49,16 @@ export default function Home() {
right: 20, right: 20,
}} }}
/> />
<h2>
<code>{"<WordCloud />"}</code>
</h2>
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
/>
</div> </div>
); );
} }