I am trying to remove y-axis tick labels from a discrete bar chart in nvd3.
I already looked into the nvd3 source, but can't find an obvious function I could change. Can anyone point me to the solution?
Update: Code
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>");}});
}
There's a variable in the nvd3 discrete bar-function that removes the y axis (including labels). Use this in your code to remove them:
.showYAxis(false)
A similar variable exists for the x-axis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With