d3.js - Display CSV data - 1 row, several bars with d3/dimplejs -


as example i've got short csv file 1 row of data:

id,amountx,amounty,amountz 1,2,1,7 

now chart should display 3 bars - 1 2 units tall, 1 one unit tall , 1 7 units tall.
can't working @ .. that's code:

<head>   <script src="http://d3js.org/d3.v3.min.js"></script>   <script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script> </head> <body> <div id="chartcontainer">   <script type="text/javascript">     var svg = dimple.newsvg("#chartcontainer", 590, 400);     d3.csv("tester.csv", function (data) {       var mychart = new dimple.chart(svg, data);       mychart.setbounds(60, 30, 510, 305)       mychart.addcategoryaxis("x", ["amountx", "amounty", "amountz"]);       mychart.addmeasureaxis("y", "amountz");       mychart.addseries(null, dimple.plot.bar);       mychart.addlegend(65, 10, 510, 20, "right");       mychart.draw();     });   </script> </div> </body>  

what do wrong here?


changed json:

{     "h1amount": 2,     "h2amount": 4,     "h3amount": 14,     "h4amount": 0 } 

and html:

<head>   <script src="http://d3js.org/d3.v3.min.js"></script>   <script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script> </head> <body>  <div id="chartcontainer">   <script type="text/javascript">     var svg = dimple.newsvg("#chartcontainer", 590, 400);      var x = null,         y = null;      d3.json("test.json", function (data) {         var mychart = new dimple.chart(svg, data);         mychart.setbounds(60, 30, 510, 305)          x = mychart.addmeasureaxis("x", ["h1amount", "h2amount", "h3amount"]);         x.overridemin = 0;           x.overridemax = 40;             mychart.addmeasureaxis("y", "h1amount");         mychart.addseries(null, dimple.plot.bar);         mychart.addlegend(65, 10, 510, 20, "right");         mychart.draw();     });   </script> </div>  </body>  

but receive white page - idea comes from?
how can debug what's going on there?

i've got working , guess it's data model. coming mysql , relational db modeling think used wrong approach , automatically tried normalize within php (where generate json).
reading through massive article nosql data modeling: https://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/ get's me bit further in understanding how json data should like.
thank - got deeper d3/dimple through poking around full day issue.

<head>   <script src="http://d3js.org/d3.v3.min.js"></script>   <script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script> </head> <body>  <h1>titles</h1> <div id="chartcontainer">   <script type="text/javascript">     var svg = dimple.newsvg("#chartcontainer", 400, 300);     var x = null,     y = null;     d3.json("test.json", function (error, json) {         var mychart = new dimple.chart(svg, json);         mychart.setbounds(60, 30, 310, 205)         x = mychart.addcategoryaxis("x", ["label"]);         y = mychart.addmeasureaxis("y", ["value"]);         mychart.addseries("titles",  dimple.plot.bar);         mychart.addlegend(65, 10, 300, 20, "right");         mychart.draw();     });   </script> </div> </body>  

and json changed / "denormalised" now:

[     {         "label": "h1amount",         "value": 2     },     {         "label": "h2amount",         "value": 4     },     {         "label": "h3amount",         "value": 5     },     {         "label": "h4amount",         "value": 1     } ] 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -