- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个漏斗图可视化,以可视化客人数量以及 3 类消费者的先前访问百分比:1 次访问、2 次访问、3 次以上访问。
现在每个类别都有 2 个标签(在右侧突出),但我想为每个类别在右侧突出 1 个标签,说明客人数量和先前访问的百分比。我还想为漏斗的每个 block 添加一个盒形标签,这样当您将鼠标悬停在它上面时,它看起来像:
[CATEGORY]
Percent of Prior Visit: [VALUE]
Guests: [VALUE]
现在,当我将鼠标悬停在 block 上时,框形标签只显示先前访问的百分比。所以我希望盒子固定好,右边的标签每 block 只有 1 个。我希望这是有道理的。我会怎么做这样的事情?提前致谢。
最佳答案
使用您之前尝试过的样式可以使这更容易。也就是说,在同一系列中设置值和百分比,如下所示:
series: [{
name: 'Guests',
data: [{
y: 352000,
yPercentage: 100,
name: '1 Visit',
color: "#ff0000",
},
...
]
}]
然后您可以像这样格式化数据标签:
dataLabels: {
enabled: true,
format: '<b>{point.name}</b> <br/>{point.y:,.0f} ({point.yPercentage} %)',
...
}
你的工具提示是这样的:
tooltip: {
headerFormat: '<span style="font-size: 10px"><b>{point.key}</b></span><br/>',
pointFormat: 'Percent of Prior Visit: {point.yPercentage} % <br/>Guests: {point.y:,.0f} '
}
这给了你这个:
Highcharts.chart('container', {
chart: {
type: 'funnel',
//Only for Pie Charts
options3d: {
enabled: false, // change to true to activate 3D
alpha: 40,
beta: 40,
depth: 100,
},
},
title: {
text: 'Guest Return Funnel'
},
plotOptions: {
funnel: {
depth: 100
},
series: {
events: {
legendItemClick: function() {
$.each(this.chart.series, function(i, serie) {
if (serie.visible)
serie.hide();
else
serie.show();
});
return false;
}
},
shadow: true,
allowPointSelect: true,
borderWidth: 18,
animation: {
duration: 400
},
dataLabels: {
enabled: true,
format: '<b>{point.name}</b> <br/>{point.y:,.0f} ({point.yPercentage} %)',
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black',
softConnector: true,
crop: false
},
center: ['50%', '50%'],
neckWidth: '40%',
neckHeight: '0%',
width: '65%',
height: '100%',
tooltip: {
headerFormat: '<span style="font-size: 10px"><b>{point.key}</b></span><br/>',
pointFormat: 'Percent of Prior Visit: {point.yPercentage} % <br/>Guests: {point.y:,.0f} '
}
}
},
legend: {
enabled: true
},
series: [{
name: 'Guests',
data: [{
y: 352000,
yPercentage: 100,
name: '1 Visit',
color: "#ff0000",
},
{
y: 88000,
yPercentage: 25,
name: '2 Visits',
color: "#FFA500",
},
{
y: 42000,
yPercentage: 48,
name: '3+ Visits',
color: "#32CD32"
}
]
}
]
});
/*
series: [{
name: 'Guests',
name2: 'Percent of Prior Visit',
data: [{
y:352000,
name: '1 Visit',
color: "#ff0000",
y2: 100,
name2: 'Percent of Prior Visit'
},
{
y: 88000,
name: '2 Visits',
color: "#FFA500",
y2: 25,
name2: 'Percent of Prior Visit',
},
{
y: 42000,
name: '3+ Visits',
color:"#32CD32",
y2: 48,
name2: 'Percent of Prior Visit'
}
]
}]
});
*/
<script src="https://code.highcharts.com/highcharts.js">
</script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/funnel.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container" style="min-width: 410px; max-width: 600px; height: 400px; margin: 0 auto"></div>
JSFiddle 工作示例: https://jsfiddle.net/ewolden/org6quk9/
关于javascript - Highchart 漏斗可视化的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51831422/
我遇到了这个 d3 Funnel Library 的问题 我目前正在使用此设置来使图表响应加载: var data = [ [ "Clicked", "5,000" ], [ "Joi
我的任务是创建一个如下所示的漏斗... 我看过一些例子here和 here并且还发现了以下 link但我无法让漏斗侧放。我什至不确定我是否在寻找正确的东西。 以前有没有人创造过类似的东西。 已更新这是
有人用过 Highchart Funnel for Angular 吗? 我使用 highchart-ng ( https://github.com/pablojim/highcharts-ng ),
我正在考虑实现 User Id用于谷歌分析。这基本上是一种告诉 Google Analytics 登录用户是否相同的方法,即使他们来自不同的设备。 谷歌表示,如果我以匿名用户身份登录,然后提供用户 I
我是一名优秀的程序员,十分优秀!