Skip to content

Commit

Permalink
fix(core): wordcloud should not render if value is not a number (ca…
Browse files Browse the repository at this point in the history
…rbon-design-system#1449)

* fix(core): wordcloud should not render if `value` is not a number

* requested changes
  • Loading branch information
theiliad committed Sep 26, 2022
1 parent fc879cd commit 822f813
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/core/src/components/graphs/wordcloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ export class WordCloud extends Component {
.size([width, height])
.words(
displayData.map(function (d) {
let value = d[fontSizeMapsTo];

if (typeof d[fontSizeMapsTo] !== 'number') {
throw Error(
'Badly formatted WordCloud data. `value` should only be an integer or float'
);
}

return {
[groupMapsTo]: d[groupMapsTo],
text: d[wordMapsTo],
size: d[fontSizeMapsTo],
value: d[fontSizeMapsTo],
size: value,
value,
};
})
)
Expand Down

0 comments on commit 822f813

Please sign in to comment.