gpt4 book ai didi

d3.js - nvd3 : remove y-axis tick labels from discrete bar chart

转载 作者:行者123 更新时间:2023-12-02 09:47:18 24 4
gpt4 key购买 nike

我正在尝试从 nvd3 中的离散条形图中删除 y 轴刻度标签。

我已经研究了 nvd3 源代码,但找不到可以更改的明显功能。谁能给我指出解决方案吗?

更新:代码

function Transform(value1, value2, chart_name,value3) {
value3 = typeof value3 !== 'undefined' ? value3 : 'no_header';
var chart = nv.models.discreteBarChart()
.x(function (d) {
return d.label;
})

.y(function (d) {
return d.value;
})

.staggerLabels(true)
.tooltips(false)
.showValues(true);

var a = [];
var f = [{
values: []
}];
d3.csv("../../csv/master.csv").get(function (error, rows) {

if (error){
console.log(error);
loadError("Uh Oh. This data set is missing... Try going <a href='/'>back to the start</a>");
return;
}

for (var i = 0; i < rows.length; i++) {
a.push(rows[i]);
}
console.log(a[0].agency);
for (var key = 0; key < a.length; key++) {
var b = a[key];
for (var c in b) {
if (c != "agency" && c != "division" && c != "pod") {
var d = b[c];
a[key][c] = +d;
}
}
console.log(a[0].changes);
}
try {
var e = $.grep(a, function (v) {
return v.division == {{division|safe}};
});
var k = $.grep(e, function(v) {
return v.agency == {{agency|safe}};
})[0];
console.log(k.division);
}
catch (TypeError) { loadError("Uh Oh. We could not find this combination\
of Agency & Division. Try going back to the <a href='/pitchview'>selection menu</a>");
return;
}
if (k.agency){
for (var g in k) {
if (g == value1 || g == value2 || g == value3) {
var h = {
"label": g,
"value": k[g]
};
f[0].values.push(h);
}
}


d3.select('#' + chart_name + ' svg')
.datum(f)
.transition().duration(500)
.call(chart)
nv.utils.windowResize(chart.update);
return chart;
} else {
loadError("Uh Oh. We could not find this combination of Agency &\
Division. Try going back to the <a href='/pitchview'>selection menu</a>");}});
}

最佳答案

nvd3 离散条函数中有一个变量可以删除 y 轴(包括标签)。在您的代码中使用它来删除它们:

.showYAxis(false)

x 轴也存在类似的变量。

关于d3.js - nvd3 : remove y-axis tick labels from discrete bar chart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17233444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com