如何从分组条形图中的空白区域中逃脱?

时间:2018-06-12 18:17:52

标签: javascript d3.js

Here is the example image

g.append('g')
        .attr('class', 'bars')
        .selectAll("g")
        .data(final_data)
        .enter().append("g")
        .attr("class", "barGroup")
        .attr("transform", (d) => { return "translate(" + x0(d.month) + ",0)"; })
        .selectAll("rect")
        .data((d) => {
            return Object.keys(d).map((key) => {return { key: key, value: d[key] }; });
        })
        .enter()
        .filter(function (d) {if (d.value && d.key!='month') return d; })
        .append('rect')
        .attr("x", (d) => x1(d.key))
        .attr("y", (d) => y(d.value))
        .attr("width", x1.bandwidth())
        .attr("height", (d) => height - y(d.value))
        .attr("fill", (d) => default_colors(d.key));

请帮助::我如何从分组条形图中的空白处逃脱?

0 个答案:

没有答案