jasondavies / d3-cloud

Create word clouds in JavaScript.
https://www.jasondavies.com/wordcloud/
Other
3.85k stars 1.07k forks source link

Setting custom style on cloud throws an exception #186

Closed alexresolute closed 1 year ago

alexresolute commented 1 year ago

Hi, a previously supported feature, using .style("fill", (d,i) => { return fill(i) }) seems to have been removed. Is there no support for custom colors now? It seems as though fill style is hard coded to red now?

jasondavies commented 1 year ago

This library does not (and has never) handled rendering: it only deals with positioning and sizing of words so that they don't overlap. In fact, you can use SVG, canvas, or anything else to render the words once their positions and sizes have been computed.

I'm not sure what your issue is exactly, but it sounds like a problem with how you're using D3 and SVG for rendering.

(Aside: the use of the colour red internally is only for hidden extraction of glyphs, this doesn't affect whatever colours you use for rendering).

alexresolute commented 1 year ago

I guess I didn't really understand that based on the example. What is the point of providing a canvas if the library solely computes positioning of the given text? Not being snarky, I'm just trying to wrap my head around this.

jasondavies commented 1 year ago

You can provide an optional canvas generator for internal extraction of glyphs. This is mainly for Node.js, where there is no DOM.

alexresolute commented 1 year ago

understood, thank you for the clarification