d3.scaleOrdinal没有返回正确的范围值

时间:2018-05-09 14:46:10

标签: javascript d3.js

我在调用d3.scaleOrdinal()时遇到错误值的问题:

这是我的域名和范围:

this.domain = ["attributed_visits", "average_cost_per_spot", "cost_per_response", "responses_per_spot", "total_cost", "total_spots"]

this.range = ["rgba(255, 56, 56, 1)", "rgba(169, 64, 152, 1)", "rgba(0, 143, 219, 1)", "rgba(93, 206, 6, 1)", "rgba(244, 212, 0, 1)", "rgba(242, 96, 0, 1)"]

        var z = d3.scaleOrdinal()
        .domain(this.domain)
        .range(this.range);

当我打电话

z('total_cost')

它返回" rgba(255,56,56,1)和#34; - 范围中的第一个值,而不是第五个," rgba(244,212,0,1)"正如我所料。

0 个答案:

没有答案