d3中的数据绑定错误:无法读取未定义的属性“start”

时间:2015-11-25 15:32:29

标签: javascript d3.js

我的数据如下:

start,end
    2,3
    4,7
    10,14

我需要等于值的比例带。例如,对于第一个值(2和3),它必须显示在51°-77°带之间(最大值14等于(2 * Math.PI)= 360°。

但是我收到了错误

index.html:37 Uncaught TypeError: Cannot read property 'start' of undefined

如何解决此错误?

<script>



    d3.csv("StartEndPoints.csv", function (data) { 

    var max = d3.max(data, function (d) { return d.end; })  ;

    var PI = (2 * Math.PI)

        var wid = 960,hei = 500

        var plane = d3.select("body").append("svg")
            .attr("width", wid)
            .attr("height", hei)
          .append("g")
            .attr("transform", "translate(480,250)");   

        var arc = d3.svg.arc()
            .innerRadius(218)
            .outerRadius(220)
            .startAngle(0)
            .endAngle(2 * Math.PI);

        var arc2 = d3.svg.arc()
            .innerRadius(214)
            .outerRadius(216)
            .startAngle  (function(d) { return    (d.start/max)*PI  ; } ) // here i try to normalize the values
            .endAngle    (function(d) { return    (d.end/max)*PI    ; } ) ;

        var group = plane.append("g");

            group.append("path")
            .attr("d", arc)

            group.append("path")
            .attr("d", arc2) 


        plane.selectAll("path")
            .data([data])
            .enter()
                .append("path")
                .attr("d",arc2)


    })  

0 个答案:

没有答案
相关问题