nvd3.js - 默认情况下取消选择nvd3图表上的线条时如何删除复选标记
问题描述
我想将 nvd3 图表上的所有行设置为默认取消选择。我从 nvd3 网站修改了实时图表上的代码。这里(对不起,我不知道如何保存代码)。
我legend: { vers: 'furious' }
在图表块中添加,并添加disabled: true
到系列对象中。代码片段:
chart: {
type: 'lineChart',
height: 450,
margin : {
top: 20,
right: 20,
bottom: 40,
left: 55
},
legend: {
vers: 'furious'
},
x: function(d){ return d.x; },
y: function(d){ return d.y; },
useInteractiveGuideline: true,
dispatch: {
stateChange: function(e){ console.log("stateChange"); },
changeState: function(e){ console.log("changeState"); },
tooltipShow: function(e){ console.log("tooltipShow"); },
tooltipHide: function(e){ console.log("tooltipHide"); }
},
xAxis: {
axisLabel: 'Time (ms)'
},
yAxis: {
axisLabel: 'Voltage (v)',
tickFormat: function(d){
return d3.format('.02f')(d);
},
axisLabelDistance: -10
},
callback: function(chart){
console.log("!!! lineChart callback !!!");
}
}
和
function sinAndCos() {
var sin = [],sin2 = [],
cos = [];
//Data is represented as an array of {x,y} pairs.
for (var i = 0; i < 100; i++) {
sin.push({x: i, y: Math.sin(i/10)});
sin2.push({x: i, y: i % 10 == 5 ? null : Math.sin(i/10) *0.25 + 0.5}); cos.push({x: i, y: .5 * Math.cos(i/10+ 2) + Math.random() / 10});
}
//Line chart data should be sent as an array of series objects.
return [
{
values: sin, //values - represents the array of {x,y} data points
key: 'Sine Wave', //key - the name of the series.
color: '#ff7f0e', //color - optional: choose your own line color.
strokeWidth: 2,
classed: 'dashed',
disabled: true
},
{
values: cos,
key: 'Cosine Wave',
color: '#2ca02c',
disabled: true
},
{
values: sin2,
key: 'Another sine wave',
color: '#7777ff',
area: true //area - set to true if you want this line to turn into a filled area chart.
}
];
};
一切正常,但检查了复选标记。结果显示在这里:结果图像 我的问题是如何默认删除复选标记?非常感谢。
============================= 解决方法===================== =======
我找到了解决方案,只需添加以下语句。
userDisabled: true
解决方案
推荐阅读
- python - 如何使用pyhdb执行sql文件?
- elasticsearch - 在 kubernetes 上运行 elasticsearch 集群时的堆大小
- splunk - Splunk - 多选 - 显示唯一主机
- c# - 如何取消 MediatR 发送的查询?
- java - 在 fatJar 中打包 node.js 文件
- javascript - 设置表单控制错误 - 错误名称是一个变量
- java - 在休眠的上下文中将@NotNull 属性添加到现有域模型的便捷模式更新策略是什么?
- python - 使用 Joblib 并获取“无法解压不可迭代的函数对象”
- google-sheets - 您如何在 Google 表格中找到一列中的一个单元格与同一列中最后一个非空单元格之间的区别?
- php - PHP下载会随机报网络错误