gpt4 book ai didi

javascript - 如何隐藏 nvd3 图表上的第一条 Y 轴线?

转载 作者:行者123 更新时间:2023-11-28 18:59:42 24 4
gpt4 key购买 nike

Plnkr 示例: http://plnkr.co/edit/19D5cnrVYdUrMlblQARy?p=preview

我的应用程序的屏幕截图: enter image description here

我尝试修改 CSS,但是我只能删除第二条(右 Y 轴线),但不能删除第一条左 Y 轴线。

我尝试过的:

.nv-y { 
display: none;
}

以及此答案中的所有行:Alter first vertical grid line in nvd3

d3.selectAll('.nv-y').attr('display','none')

d3.selectAll('.nv-y path').attr('opacity','0.1')

d3.selectAll('.nv-y path').attr('display','none')

我当前的drawChart函数:

function drawChart(res) {
console.log(' ');
console.log('drawChart res = ',res);
nv.addGraph(function() {
var chart = nv.models.linePlusBarChart()
.margin({top: 30, right: 40, bottom: 50, left: 40})
.x(function(d,i) { return i })
.y(function(d) { return d[1] })
.color(d3.scale.category10().range());

chart.xAxis.tickFormat(function(d) {
var dx = res[0].values[d] && res[0].values[d][0] || 0;
return d3.time.format('%x')(new Date(dx))
});

chart.y1Axis
.tickFormat(d3.format(',f'));

chart.y2Axis
.tickFormat(function(d) { return '$' + d3.format(',f')(d) });

chart.bars.forceY([0]);
// https://stackoverflow.com/questions/23754188/nvd3-js-how-to-disable-tooltips-for-one-serie-only
chart.lines.interactive(false);
// http://nvd3-community.github.io/nvd3/examples/documentation.html#line
chart.height(280);
// If not chart data is avaliable to display:
chart.noData("There is no Data to display at the moment.");

// Remove legend:
chart.showLegend(false);

d3.select('#chart svg')
.datum(res)
.transition().duration(500)
.call(chart);

d3.selectAll('.nv-y path').attr('display','none');

nv.utils.windowResize(chart.update);

return chart;
});
}

最佳答案

如果你想隐藏第一个 y 轴,请执行以下操作:

.nv-y1{
display:none;
}

如果你想隐藏第二个 y 轴,请执行以下操作:

.nv-y2{
display:none;
}

http://plnkr.co/edit/IgFh1rV4a6ubAMe0VqT2?p=preview

关于javascript - 如何隐藏 nvd3 图表上的第一条 Y 轴线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32852062/

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