有一些条形图不是高图表上的 url 链接
Have some bars not a url link on highcharts
我有一个这样的高图表:小提琴演示图表它是在 PHP 的服务器上用数据生成的,但如果数据计数为零,我不希望它有一个 URL(因为没有什么可看的(。
如何告诉图表仅禁用这些柱上的链接?
if($value['category'] > 0){
$chartActive .= $comma."{y:".$value['category'].", url: '/section/of/site/index.php'}";
}else{
$chartActive .= $comma."{y:0, url: javascript:void(0)}";
}
然后,这将像这样添加到图表中:
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || '#333'
}
},
series: {
cursor: 'pointer',
point: {
events: {
click: function() {
location.href = this.options.url;
}
}
}
}
},
series: [{
name: 'Active',
data: [<?php echo $chartActive; ?>]
},
如您所见,url 是在 plotOptions 的系列部分中定义的,因此它始终存在,如果我按照我现在的方式进行操作,链接可以工作但转到 mysite.com/undefined
任何建议将不胜感激。
马克
您可以在设置 url 之前测试该点是否在点击事件中具有值。但是,任何空点仍将具有指针光标,我还没有找到绕过它的方法。
series: {
cursor: 'pointer',
point: {
events: {
click: function() {
// if you've more than one series then you'll have to sum up the value for the stack
if (this.y != 0) {
location.href = this.options.url;
}
}
}
}
}
相关文章:
- 将重定向URL链接添加到JS函数
- 我如何重新加载URL链接,在我点击提交按钮后它保持不变
- 如何摆脱AngularJS中的当前域URL链接
- Javascript:我如何自动打开链接中的url链接
- 如何在Javascript中用URL链接不同的幻灯片图像
- 获取javascript中的URL链接名称
- 用于浏览器检测和url链接的脚本
- 翻译一篇文章'上.单击'PHP中的事件,来自'window.open'到基本URL链接
- javascript替换url链接循环
- 带有JS点击相对路径的网页URL链接
- 使用javascript基于登录用户重定向URL链接
- 带有URL链接且无重复项的旋转横幅
- 有一些条形图不是高图表上的 url 链接
- 如何使用 css 元素从 java 添加 url 链接
- 如何通过 css 元素从 jquery 添加 url 链接
- 使用 JavaScript 动态显示 URL 链接
- 使用JS逻辑从自定义选项构建URL链接
- 使用URL链接加载弹出窗口
- 为文件夹[javascript]中的文件生成URL链接列表
- 将数据存储到URL链接中