javascript - Why does my .data function work in pieChart but not in lineChart in dc.js? -


i want plot data dimension that's not in crossfilter i'm forced use .data.

all fine piechart, when switch linechar error p undefined (firefox) or cannot read property y of undefined (chrome). tried following code, got little lost in it. can tell me it's going wrong?

<div id="test"></div> <script>         dc.barchart("#test")         .width(100).height(100)         .dimension({})         .group({})         .x(d3.scale.linear().domain([0,5]))         .data(function(){             return [                  {key : 0, value : 4},                 {key : 2, value : 14},                 {key : 3, value : 20},             ];         });      dc.renderall(); </script> 

the code works if piechart, , comment out .x.

here's jsfiddle, note scripts loaded rawgit.com: http://fiddle.jshell.net/fyy5m26r/1/

sorry, aren't going able use .data() bar or line charts reasonable amount of effort, because dc.js uses .data() internally , in case have call d3.stack in order create data expecting.

instead, suggest create "fake group". can inline using

.group({all: function() { ... }}) 

instead of

.data(function() {...}) 

or, example code:

dc.barchart("#test")     .width(200).height(200)     .dimension({})     .x(d3.scale.linear().domain([0,5]))     .group({all: function(){         return [              {key : 0, value : 4},             {key : 2, value : 14},             {key : 3, value : 20},         ];     }}); 

fork of fiddle here: http://fiddle.jshell.net/gordonwoodhull/4lf8n7pn/8/


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -