javascript - What would be a good approach for providing d3 capability in a dust-helper? -


right i've been considering writing dust-helper renders barcharts dust files server-side using custom dust-helper , d3 module node. wondering if there better way construct sort of context object pass dust renderer:

{   padding: {     top: integer,     right: integer,     bottom: integer,     left: integer   },   width: integer,   height: integer,   data: [datum, ...],   x: {     scale: {       type: string, // 'linear', 'time', 'ordinal'       range: 'extent', // optionally [lower, upper]       tick: { // if applicable         format: string, // d3 number format linear scale                         // d3 time format time scale         args: integer | [interval, integer]       }     },     value: string, // datum[value] used x-axis   },   y: {     ...   } } 

and on, have d3 use scheme render customized components , return svg markup string. seems verbose option me, lot of requirement add more , more attributes bloat context until becomes messy manage well, why wondering if there better approach perhaps splitting dust helpers individual components of d3.

i've been thinking , best way think go using d3 dust filter instead following:

dust.filters.d3 = function(value) {     var node = d3.select(value).node();      if (node) {         return node.outerhtml;     }      return 'd3 selection not found'; }; 

and running d3 code before starting dust rendering.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -