There are certainly redundant pieces when using Om & d3 together, like 
data-binding and DOM management. I experimented (briefly) with the idea of 
using Om/React as much as possible and only using d3 basically to create 
functions for generating paths. This avoids having to sync the redundant parts 
and is less awkward in Om-land.

You can checkout some of this experimentation here: 
https://github.com/loganlinn/powergrid/blob/34ac2303b1893399d044f5bd080d9ccadb812410/src/cljs/powergrid/ui/cities.cljs#L10-L41

Notice how I am creating the SVG elements in `render` with om.dom and setting 
`d` property from calling `path`, a D3 function (rather than calling out to 
some d3 code in `did-mount`)

>From what I could tell, this was pretty effective & easier to manage 


On Wednesday, May 28, 2014 8:27:03 AM UTC-7, Juan Manuel Gimeno Illa wrote:
> I'm trying to define chart components for Om in order to create dashboards. 
> For the state management and propagation Om feels right and for the charting 
> my idea is to use d3.js (via strokes, a clojurescript adapter).
> 
> I have started by translating the code for 
> http://10consulting.com/2014/02/19/d3-plus-reactjs-for-charting/ to use Om 
> instead of React.js and strokes instead of d3.
> 
> The translation is more or less straightforward but something in the approach 
> does not feel right. From d3 I only use scales and the data binding part is 
> realized by om. For simple bar charts (as those in the example) this approach 
> works, but to create the axis with labels I'll have to rewrite most of the 
> code in d3 but using om.dom instead accessing the read DOM apis.
> 
> Here is my question: is it possible to access and work on the real DOM node 
> from an Om component? 
> 
> My idea is to leave Om manage state propagation and re-rendering until the 
> SVG container (the node than contains the chart). If it has to be re-rendered 
> (because tha data or teh size has changed), leave the re-rendering of its 
> children (e.g. rectangles for the bars, text for the labels, etc.) to d3 data 
> binding. 
> 
> Is it possible to do that? Is it sensible? 
> 
> Thanks !!
> 
> Juan Manuel

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to