如何显示条件标签和无标签?

How to show conditionals label and no-label?

显示标签正常,问题是显示无标签。我正在使用

labels: {
        format: function (v, id) {
            return (String(id).substring(0,5)=='avg')? d3.format(".3")(v): null;
        }
},

但 null(或 ""undefined)不起作用,生成 0 作为标签。在 bar 聊天中查看非请求的零:


https://output.jsbin.com/seriyih/edit

d3.format 正在将任何未定义和空值转换为“0”,因此您只需要对此进行进一步的条件测试,如果是,则避开格式化步骤。

    format: (v, id)=> (  (String(id).substring(0,3)=='avg')? (v != undefined ? d3.format(".3")(v) : null): null)