Q: nvd3 chart only displaying after resize I am having a problem where my chart will only render after a resize event has been called by the browser.
After the resize event it looks exactly how I want it to.
I am using d3.csv to load the data I suspect this may have something to do with it but I have no idea really.
I am using d3 3.5.6 and nvd3 1.8.1
I am locally serving with python -m SimpleHTTPServer
Here is the javascript that I am using to create the chart:
nv.addGraph(function () {
    var chart = nv.models.lineChart()
        .useInteractiveGuideline(true);
    chart.duration(0)
        .margin({
        left: 100,
        bottom: 100
    })
        .x(function (d) {
        return d.financial_year
    })
        .y(function (d) {
        return d.real_expenditure_millions
    })
        .forceY([0]);
    chart.xAxis.axisLabel("Financial Year ");
    chart.yAxis.axisLabel('Expenditure (millions)');
    chart.showXAxis(true);

    myData = getData();
    d3.select(".chart")
        .datum(myData)
        .attr("id", function (d) { console.log(d); })
        .call(chart);
    nv.utils.windowResize(chart.update);
    return chart;
});

Here is my getData function which also serves to update a table on the page:
function getData() {
    var myData = [];
    d3.csv("data.csv", function (data) {
        var table = d3.select("table");
        var row = table.append("thead").append("tr")
        row.append("th").text("financial year");
        row.append("th").text("Real Expenditure (millions)");
        table = table.append("tbody");
        for (d in data) {
            var year = data[d].financial_year;
            var expenditure = data[d].real_expenditure_millions;
            row = table.append("tr");
            row.append("td").text(year);
            row.append("td").text(expenditure);

            myData.push({
                financial_year: +(year.substr(0, 4)),
                real_expenditure_millions: +expenditure
            });
        }
    });
    return [{
        values: myData,
        key: "Federal Government Dental Expenditure in NSW",
        color: "#ff7f0e"
    }];
}

data.csv looks like
financial_year,real_expenditure_millions
1997-98,60
1998-99,115
1999-00,144
2000-01,177
2001-02,182
2002-03,175
2003-04,169
2004-05,177
2005-06,183
2006-07,189
2007-08,280
2008-09,479
2009-10,578
2010-11,613
2011-12,660

The chart only displays after a window.dispatchEvent(new Event('resize')); in the browser console.

A: I ended up having to load the data by calling my get data function outside the nv.addGraph
