我在查找如何在使用_.findWhere函数时在underscore.js中动态设置属性时遇到问题.
这是该函数的文档:
Run Code Online (Sandbox Code Playgroud)findWhere_.findWhere(list, properties)查看列表并返回与属性中列出的所有键值对匹配的第一个值.
如果未找到匹配项,或者list为空,则返回undefined.
Run Code Online (Sandbox Code Playgroud)_.findWhere(publicServicePulitzers, {newsroom: "The New York Times"}); => {year: 1918, newsroom: "The New York Times", reason: "For its public service in publishing in full so many official reports, documents and speeches by European statesmen relating to the progress and conduct of the war."}
在文档中建模示例,我想设置属性以动态搜索:
var publicServicePulitzers = [
{"newsroom":"The New York Times", "year":2013 },
{"newsroom":"The Los Angeles Times", "year":2012 }
];
var myprop = 'newsroom';
_.findWhere(publicServicePulitzers, { myprop : "The New York Times"});
Run Code Online (Sandbox Code Playgroud)
结果未定义.
我也尝试过: …
我想覆盖Chart JS中的漂亮数字算法,并在y轴上只显示两个标签(或刻度):值的最大值和最小值.这些值都是浮点数.我看到回调函数(yAxis.ticks.callback)已经找到了勾号,所以我不认为这是做这件事的地方.任何帮助,将不胜感激.
我无法弄清楚当使用Chart JS将鼠标悬停在数据点上时,如何在折线图上绘制垂直线.我希望该线保持在图表矩形的范围内,以便它不会延伸到刻度区域.任何帮助,将不胜感激!