小编use*_*804的帖子

使用d3.js将SVG添加到Canvas

有没有人在创建d3.js可视化时尝试使用svg来绘制库?我已经尝试使用canvg.js和d3.js将svg从android 2.3应用程序webview中转换为canvas,但是当我调用时:

svg.selectAll(".axis")
    .data(d3.range(angle.domain()[1]))
    .enter().append("g")
    .attr("class", "axis")
    .attr("transform", function(d) { return "rotate(" + angle(d) * 180 / Math.PI + ")"; })
    .call(d3.svg.axis()
        .scale(radius.copy().range([-5, -outerRadius]))
        .ticks(5)
        .orient("left"))
    .append("text")
    .attr("y", 
        function (d) {
            if (window.innerWidth < 455){
                console.log("innerWidth less than 455: ",window.innerWidth);
                return -(window.innerHeight * .33);
            }
            else {
                console.log("innerWidth greater than 455: ",window.innerWidth);
                return -(window.innerHeight * .33);
            }
        })
    .attr("dy", ".71em")
    .attr("text-anchor", "middle")
    .text(function(d, i) { return capitalMeta[i]; })
    .attr("style","font-size:12px;");
Run Code Online (Sandbox Code Playgroud)

我收到错误:Uncaught TypeError:无法调用setPropertynull的方法http://mbostock.github.com/d3/d3.js?2.5.0:1707

是某种无头浏览器应用程序,还是服务器端js解析器?有没有人遇到过这个?

javascript select svg node.js d3.js

14
推荐指数
3
解决办法
2万
查看次数

标签 统计

d3.js ×1

javascript ×1

node.js ×1

select ×1

svg ×1