heavysixer / d4

A friendly reusable charts DSL for D3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'ordinal' of undefined

gerritboogaart opened this issue · comments

When I try to run the sample script on my machine. I get this error:
d4.js:95 Uncaught Error: [d4] The scale type: "ordinal" is unrecognized. D4 only supports these scale types: time, time.utc
When I log supportedScales in line 175 (function validateScale); d3.scale is undefined.

I load d3.js first, then d4.js.

Any idea why this happens?

Hi @keesgboog can you post a block builder where I can see your code? blockbuilder.org/

Sure, I basically copied your code in the 'getting started'.

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
</head>
<body>
<div id="test">
</div>
<script type="text/javascript">
$(document).ready(function(){
        var data = [
          { x : '2010', y : 5 },
          { x : '2011', y : 15 },
          { x : '2012', y : 20 }
        ];
        var columnChart = d4.charts.column();
        d3.select('test')
          .datum(data)
          .call(columnChart);
});
</script>
<script type="text/javascript" src="d3.js"></script>
<script type="text/javascript" src="d4.js"></script>
</body>

I am working with d3 quite a lot to make dashboards, and am excited about d4's ability to make it easier to draw column charts.

oh, and it needed to be:

d3.select('#test')

👍 so it works for you now?

nope :) sorry. I don't think it gets past
var columnChart = d4.charts.column();
that's where the error:
d4.js:95 Uncaught Error: [d4] The scale type: "ordinal" is unrecognized. D4 only supports these scale types: time, time.utc
comes in... which i can follow to be an error in l.174 function validateScale()
(from the createAxisScale() , where axis.accessors.scale is 'ordinal', which tries to go to:

scale = d3.scaleaxis.accessors.scale;

which dies if you take the validator away, because it will state:

d4.js:235 Uncaught TypeError: Cannot read property 'scale' of undefined

Does that make sense? :)

Oh it does not work with the most current version of D3 yet. What version of D3 are you using?

Yeah that is probably it. If you look at the bower.json file you'll see the version of d3 that d4 is currently bound to https://github.com/heavysixer/d4/blob/master/bower.json 3.5.16

Ah That worked! Thanks!
Will there be a 4+ work around at one point?

yeah i would like to bring it current with the existing version of d3. However, I am not sure what a timeframe for that will look like. I am going to close this issue for now.

Cool! Thanks for your help!

You can use scaleOrdinal( ) in the newest versions.