javascript - 如何在 angular-flot 条上添加 onclick 功能
问题描述
我使用 angular-flot 创建一些数据的字符表示,这是我的 .html :
<div flot id="dataChar" [dataset]="barData" [options]="barOptions" height="300"></div>
然后在我的 .ts 中,我通过添加选项来配置 flot:
barData: any;
barOptions = {
series: {
bars: {
align: 'center',
lineWidth: 0,
show: true,
barWidth: 0.6,
fill: 0.9
}
},
grid: {
borderColor: '#eee',
borderWidth: 1,
hoverable: true,
backgroundColor: '#fcfcfc',
clickable:true
},
tooltip: true,
tooltipOpts: {
content: function (label, x, y) { return x + ' : ' + y; }
},
xaxis: {
tickColor: '#fcfcfc',
mode: 'categories'
},
yaxis: {
tickColor: '#eee'
},
shadowSize: 0
};
我已经看到在 ChartJs 中你可以使用onClick
,我尝试在这里使用它但它不起作用,那么我该如何在这里添加事件呢?我一直在搜索的所有内容似乎都在 jquery 中,我不知道我是否可以在我的项目中使用它,所以任何帮助都将不胜感激
解决方案
你能检查一下“actions”数组吗?我认为您需要为元素定义操作。'handler(chart)' 是一种添加处理程序的方法。检查这篇文章。
推荐阅读
- ibm-watson - 如何在 MessageResponse Watson Assistant Java 客户端中获取“操作”数据
- c# - 使用 Null 传播时出现 NullReferenceException
- qt - Qt示例程序可以执行命令行程序
- spring - 阔叶商务演示网站问题
- c# - 如何使用外键链接 3 个表?
- java - 如果父类中的方法“抛出异常”,我们可以在覆盖的方法中删除它吗
- android - 滚动时 Leanback 崩溃 ListRowPresenter
- javascript - 模型中的变量未更新
- c++ - 死锁使用 std::mutex 保护多线程中的 cout
- java - 为什么完整的 Arraylist 没有通过第二个 for 循环打印?