When I click a button, I pass an array of data from a viewmodel. On the d3.json
function, I use json_encode
against the viewmodel to tranform it to a JSON object. When I inspect it on the page, it does convert it but I am getting an
"Uncaught SyntaxError: missing ) after argument list".
Can someone tell me what I am doing wrong?
d3.json("<?php echo json_encode($viewmodel) ?>", function(error,data){
data.forEach(function(d) {
d.projectdate = parseDate(d.projectdate);
d.Cost = +d.Cost;
});
var svg = d3.select("body")
.append("svg")
.attr("id", "chart")
.attr("width", w)
.attr("height", h);
svg.selectAll("bar")
.data(data)
.enter()
.append("rect")
.classed("bar", true)
.attr("x", 0)
.attr("y", function(d, i){
return i * 20
})
.attr("width", function(d,i){
return d;
})
.attr("height", 20);
});