Skip to content Skip to sidebar Skip to footer

Time Parsing And Scaling For D3js Graphs

I have this code that draws a d3js multichart object, the value time:Years values are given in this format Year=2011... with this time format the code works fine but once I wanted

Solution 1:

The problem in your example is that you're converting all properties of the objects to numbers. This works if the date is just the year, but not if it is a string that needs to be parsed. In your case, you don't need to do this conversion anyway because you can give the numbers as numbers rather than strings directly. That is, you don't need

for(var prop in d) {
    if(d.hasOwnProperty(prop)) {
        d[prop] = parseFloat(d[prop]);
    }
}

Working jsfiddle with the conversion code removed here.

Post a Comment for "Time Parsing And Scaling For D3js Graphs"