morris.js - Hide ykeys but show label on morris js
问题描述
could you help me with this problem? I have this graphic in morris js where I show 2 variables, what I need is to generate a label of the sum without it being graphed.
Morris.Bar({
element: 'bar-example2',
data: [
{ y: '2018-05-21', a: 0, b: 8472, c: 8472 },
{ y: '2018-05-20', a: 0, b: 8391, c: 20 },
{ y: '2018-05-19', a: 0, b: 9031, c: 9031 },
{ y: '2018-05-18', a: 0, b: 8974, c: 8974 },
{ y: '2018-05-17', a: 360, b: 9095, c: 9455 },
{ y: '2018-05-16', a: 0, b: 10017, c: 10017 },
{ y: '2018-05-15', a: 0, b: 9576, c: 9576 }
],
xkey: 'y',
ykeys: ['a','b','c'],
labels: ['Mot1', 'Mot2', 'Total'],
stacked: true
});
I have this
I want this
解决方案
您可以尝试使用hoverCallback
选项中的功能来自定义其内容。以下代码应该可以完成这项工作:
hoverCallback: function (index, options, content, row) {
console.log(row);
return 'Your value is: '+parseFloat(row.a+row.b);
},
你可以在这里查看帮助:http: //morrisjs.github.io/morris.js/bars.html
推荐阅读
- javascript - 如何使这个 owlcarousel 正确显示项目?
- c# - READER IS CLOSED 时调用 read 的尝试无效 .. 错误在每一行重复
- node.js - 将另一个集合中的文档保存在新文档的数组中
- r - 根据 R 中表的列数过滤列表
- python-3.x - 在 termux 中安装 pynput 时出现错误
- c - 方案和C之间的混合编程
- async-await - 可以/如何调用描述符从条件和/或异步暂停方法/元类模板中受益
- http - http/net 请求不遵循 3xx 状态码
- c++ - 调用有时间限制的函数
- android - 电容器类星体“地理定位”插件未在 android 上实现