Thanks for the feedback, and glad to hear you're making progress. Your
approach to the candlestick chart sounds reasonable. I think the
answer to #2 is also "yes", but I'm not sure I understand the
question. Like Protovis, D3 uses accessor functions for nearly
everything, which means you can conform your visualization
specification to fit the shape of your data, rather than the other way
around.
Regarding performance of SVG & Canvas: Yep! SVG is fast, too; for
certain tasks such as incremental updates to a complex visualization,
SVG can be faster than Canvas because the browser can be smart about
what needs to redraw. Other tasks, such as caching bitmaps and
pixel-based manipulation, may give Canvas the edge. You can also use
CSS3 transforms with SVG to improve performance. For example, try
rotating this phylogenetic tree:
http://jasondavies.com/tree-of-life
Mike
Yes, for most things D3 allows you to specify an accessor function to
retrieve an arbitrary property (or perform some transformation) for each
datum.
> 2. I have unique requirements for the x axis labels. Currently the
> only solution with other charting packages has been to generate these
> labels on the server side and populate a property of my json object
> with them or to iterate through all the data on the client side and
> generate an array of labels before actually plotting the data. With
> d3 however it looks like i could instead assign a function call and
> pass it the the data point being plotted and that function can return
> the label to draw. Is this correct?
D3 is a completely generic data transformation library so you can decide
on your own way of generating axis labels. Usually each axis has an
associated scale e.g. d3.scale.linear(), and you can call .ticks() to
retrieve an array of tick values appropriate for using for axis labels.
If you have your own peculiar way of generating labels, it should be
easy enough to do: simply bind your data to a group of elements and then
use an accessor function to generate the label for each element.
In summary, you shouldn't need to do any server-side generation of
labels, and they can be generated on-the-fly in the browser.
> 3. One of the advantages of using html5 canvas is speed. The
> disadvantage of canvas is image quality esp when zooming. I've found
> that performance can be a problem for svg based chart libraries when
> plotting large sets of data (i.e. 20+ yrs of data). I have read that
> d3 can handle large sets of data efficiently. Is this correct and how
> is it different than other libs in this regard?
There are indeed differences between canvas and SVG performance-wise.
Typically SVG is better for interactive visualisations because it uses
the browser's built-in scene graph for event handling and animation.
See also Mike's message here which covers some advantages/disadvantages
of pixel-based vs. SVG:
<https://groups.google.com/d/msg/d3-js/KjGW94SyrAg/lc6rDxyisPAJ>
Note that with SVG you can scale your visualisation to arbitrary
resolutions, whereas this is harder to do with canvas.
> 4. Are there any examples of candlestick plot(i know protovis has an
> example but im guessing d3 is significantly diff?)
Not yet, but I'm working on a reusable candlestick chart so one should
appear at some point. You've probably already seen the box plot
example: <http://mbostock.github.com/d3/ex/box.html>.
> Thanks much...im really excited to try this based on what i have
> read. Will give it a shot tonight.
Good stuff, do let us know if you have any questions!
--
Jason Davies, http://www.jasondavies.com/