SVG is a whole lot easier to manage in JavaScript. If for no other reason,
you've got access to the D3 libraries. In V4, Mike Bostock wen to a lot of
effort to break bits out into stand-alone libraries to make reuse easier
without the whole D3 environment, and to encourage contributions from other
people. One of the core features of D3 is the scale:

https://github.com/d3/d3/blob/master/API.md#scales-d3-scale

And a couple of examples from Mr. Bostock:

Quantile, Quantize, Threshold Scales
http://bl.ocks.org/syntagmatic/29bccce80df0f253c97e

Linear & Ordinal Scales
https://bl.ocks.org/pstuffa/c37d059efa1501d33913d63ffe3585db

It's super powerful. Like most things D3, you define an object that is
implemented using JavaScript's (very nice) closures.So, you end up with an
object that can perform scaling operations. The object can be passed around
as a parameter and it can be invoked as such. What's nice about the closure
in this case is that you can manufacture a whole bunch of different scales
- you set the values when you build your scaling object. Then you pass the
pre-defined scale object, as needed. The object caries the scaling function
internally. It's very tidy and very powerful. There's nothing remotely
similar in the 4D language, so there's no way to make a meaningful metaphor
for this sort of structure.

Scales in D3 can be of all sorts of different types, including ordinal,
continuous, and sequential. If you need animations, I think that the
interpolation features lock in here too. It takes a bit of time to get your
head around D3 scales, or at least it did for me when I was using D3
heavily, but after that, they're a snap. No more hassles.  Super powerful
and super easy, once you've got the hang of it.

Notes:
* Mike Bostock's JavaScript relies heavily on anonymous functions. I don't
really get it why JS people love them so much. But M. Bostock is way
smarter than likely anyone I've met, so I figure roll with it.

* He's also pretty into that freight-car-function style from jQuery which I
hated on sight. But it does make it easier to set a ton of properties
legibly in a compact space. Virtually everything in D3 is set to return in
a way that supports this syntax so, yeah, be aware of that.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to