-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow more than 2 accessors, for instance for Bubble charts #33
Comments
Hi Bondifrench, I am a little undecided on this. In general, I know that one needs access to the original item: this is why all charts return some collection of objects having the shape {
item: <datum>,
index: <index>,
<curve>: <shape object>
} In this way, one can refer to the item, as well as the curve. Moreover, all charts accept a parameter compute: {
r: function(item) { ... }
} would result in objects of the shape {
item: <datum>,
index: <index>,
<curve>: <shape object>,
r: <result of the above function>
} Now, why doesn't all this work for bubble charts? The reason is that Paths.js is not actually doing any work for scatterplots! You see, the simplest way to produce a scatterplot (or a bubble chart) starting from a collection of data is just to iterate over each datum and draw a circle. There is no path computation to be done, hence no value added by paths.js. The reason I added it in the demo is that some people started asking for scatterplot support, so I showed that it was trivially doable with - say - the existing Stock diagram. Now, the problem in your case is that the stock diagram has an item associated for each line, while you need something (the radius) to be computed for each point. I see two solutions:
An example of the first in React would look more or less like this: var bubbles = data.map(function(d) {
<circle cx={f(d)} cy={g(d)} r={h(d)} />
});
return <svg>{ bubbles }</svg> where Let me know what you think - in case it would be pretty simple to add a BubbleChart. |
Hi Andrea,
so I don't need to do a separate calculation.
|
Hi Andrea,
how about allowing to have a third accessor? like
zaccessor
, so when we doline.path.points()
, we have arrays of 3 coordinates (x,y and z) and z can be assigned to ther
parameter, so from a scatter plot charts we can also do bubble charts?or change accessors to be an object, so it can be extended to more than 2 accessors? but i can guess that would be a breaking change.
Cheers
The text was updated successfully, but these errors were encountered: