在nvd3中更改y轴比例 [英] Changing the y-axis scale in nvd3
本文介绍了在nvd3中更改y轴比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对nvd3非常陌生. 我绘制了一个折线图,其中大多数点在Y轴范围内(99到101).只有很少的值不在此范围内.检查此图像:
I am very new to nvd3. I plot a line chart, where most of the points are in the the Y-axis range 99 to 101. Only a few value will be outside this range. Check this image:
我希望一直扩大此范围.我希望最终用户将注意力集中在99到101的范围内,而不考虑异常值的大小.基本上,焦点应在99到101的范围内,但其他数据点也应显示.
这是我当前的代码:
$scope.setChartType = function(type) {
console.log(type);
$scope.options.chart.type = type;
};
$scope.options = {
chart: {
type: 'lineChart',
height: ClickHandlerService.chartOptions.height,
margin: ClickHandlerService.chartOptions.margin,
x: function (d) {
return parseInt(d.timestamp);
},
y: function (d) {
return d.latency;
},
useInteractiveGuideline: true,
staggerLabels: true,
stacked: false,
transitionDuration: ClickHandlerService.chartOptions.transitionDuration,
transitionEase: ClickHandlerService.chartOptions.transitionEase,
dispatch: {
stateChange: function (e) { /*Placeholder for graph events*/
},
changeState: function (e) { /*Placeholder for graph events*/
},
tooltipShow: function (e) { /*Placeholder for graph events*/
},
tooltipHide: function (e) { /*Placeholder for graph events*/
}
},
xAxis: {
tickFormat: function (d) {
return moment(d * 1000).utcOffset(-8).add(1, 'hours').format('DD-MM-YYYY/HH');
},
showMaxMin: false
},
yAxis: {
axisLabel: 'Data Latency (In minutes)',
tickFormat: function (d) {
return d3.format('.02f')(d);
},
axisLabelDistance: 30,
showMaxMin: false
},
callback: function (chart) {
}
},
title: {
enable: true,
text: graphDetails.name
},
caption: {
enable: true,
html: ClickHandlerService.chartOptions.dataLatencyCaption,
css: ClickHandlerService.chartOptions.captionCss
}
};
推荐答案
您可以将chart.yDomain
设置为[99-101]
(或您想要的任何范围).
You can set chart.yDomain
to [99-101]
(or whatever range you want).
这篇关于在nvd3中更改y轴比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文