我无法正确对齐%总轴。这是相关的代码。
var totalPercentageAxisScale = d3.scale.ordinal()
.domain(dataTop.percent_of_total)
.rangeBands([0, width]);
var totalPercentageAxis = d3.svg.axis()
.scale(totalPercentageAxisScale)
.tickValues(dataTop.percent_of_total)
.tickPadding([15]);
var botTotPercAxisScale = d3.scale.ordinal()
.domain(dataBottom.percent_of_total)
.rangeBands([0, width]);
var botTotPercAxis = d3.svg.axis()
.scale(botTotPercAxisScale)
.tickValues(dataBottom.percent_of_total);
chartWrapper.select(".chart-two").append("g").attr("transform", "translate(0, " + (heightBottom + 12) + ")").attr("class", "axis").call(botTotPercAxis);
chartWrapper.select(".chart-two").append("g").attr("transform", "translate(0, " + (heightBottom + 24) + ")").attr("class", "axis").call(botPercChangeAxis);
console.log(JSON.stringify(dataTop.percent_of_total),JSON.stringify(dataBottom.percent_of_total)); 返回... [“-0.04%”,“0.18%”,“0.41%”,“0.12%”,“0.1%”,“0.01%”,“0.01%”] [“ - 0.1%”,“0.16%”,“ 0.38%“,”0.16%“,”0.06%“,”0.05%“,”0.01%“]