无法将d3 svg元素追加到骨干元素

时间:2014-02-17 04:54:49

标签: javascript jquery backbone.js svg d3.js

所以我在我的视图中的init函数中执行此操作 -

    var svg = d3.select(".timechart-container").append("svg")
        .attr("width", width + margin.left + margin.right)
        .attr("height", height + margin.top + margin.bottom)
        .append("g")
        .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

我对timechart-container这么做的原因是因为我依靠视图来创建自己的el。

app.TimeChartView = Backbone.View.extend({

    tagName: 'div',
    className: 'timechart-container',

这是父视图的渲染功能 -

render: function(){
    this.$el.append(this.rightView.render().$el);
    this.$el.append(this.centerView.$el);
    this.centerView.render();
    return this;
}

当我做d3.select(“body”)...

svg元素追加。

使用我当前的代码,没有任何内容附加到该类的div。

为什么?

0 个答案:

没有答案