heavysixer / d4

A friendly reusable charts DSL for D3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing bar in simple collumn graph

dnbard opened this issue · comments

Hello. I'm using d4 and my graph missing one bar:
example

Still it's present in data model:
data model

Code:

for(var i = window.data.length - 1; i >= 0; i --){
    graphData.push({
        x: i + 1,
        y: window.data[i].count
    });
}

var columnChart = d4.charts.column().outerWidth(900);
d3.select('#graph').datum(graphData).call(columnChart);

Any help is appreciated ;)

Would it be possible to see this as a Fiddle so that I can see the issue in action?

Thanks!

@heavysixer Please take a look http://jsfiddle.net/nbww6/ (I've used d3 and d4 libraries from my server, feel free to change them to some CDN or else if you need)

Also it's working fine with different declaration of x in graphData array. You can look at final graph @ http://brackets-rating.herokuapp.com/

Hey @dnbard I've started a fiddle example for you, can you flesh it out for me?

http://jsfiddle.net/558hQ/

I've added data to your fiddle http://jsfiddle.net/558hQ/1/ It still miss one bar.
Also, you can remove any number of objects in window.data array to watch that graph to see different missing bars.

Yes, you are right, very strange behavior indeed. I am porting this over to a test case so that I can inspect it closer and figure out what is going on.

I think it might be the way your for loop is being constructed. Check out the updated example:

http://jsfiddle.net/Qggv5/

I am still trying to understand what the difference is between the two, because the for loop you are using looks completely valid. The odd thing is that the x dimension in this case is an ordinal value, which means that its a categorical scale, not based on a linear progression. I am thinking this must have something to do with it.

It works this way. Still I don't understand what is wrong with loop in my example?

Yes, I have tracked the bug down and am working on a patch now. It is a coercion bug in how the key accessor is created by default. Will let you know when I've patched it, after I've tested everything again.

@dnbard Please update your copy of d4 and everything should work nicely for you. Thanks for finding and submitting this bug to me! Your fiddle example should work now too, because its bound to the latest version of d4.

Can i use the CDNs for d3.js and d4.js from that Fiddle in my projects ?

@dnbard I would not use the d4.js file because it is always bound to the latest master, and that should be considered unstable. I do believe that you can use the d3.js from the CDN but again I am not totally sure.

@heavysixer ok, I'll stick with stable version of libraries.