$a = array("pear","apple","apple","ball","cat");
$u = array_unique($a);
echo json_encode($u);
Run Code Online (Sandbox Code Playgroud)
输出显示为:{"0":"pear","1":"apple","3":"ball","4":"cat"}
我需要一个非关联数组作为输出:["apple","ball","cat","pear"].
我正在使用mbostock的条形图.代码几乎相同.我没有字母和频率,而是分别有名字和价值.我想在条形图上显示每个数据的值.我试着在最后添加它.
svg.selectAll(".bar").append("text")
.attr("x", height/2)
.attr("y", function(d) { return y(d.value) - 3; })
.text(function(d) { return d.value; });
Run Code Online (Sandbox Code Playgroud)
但这似乎根本不起作用.那我搞砸了什么?