javascript - D3 漏斗图中的工具提示位置无法正常工作
问题描述
我正在尝试做一个 d3 水平漏斗图。
一切正常,但工具提示位置无法正常工作,它出现在不同的位置。
这是我的代码:
const data = [
["L0", 10],
["L1", 0],
["L2", 5],
["L3", 10],
["L4", 3],
["L5", 10]
];
newdata = data.map(function (d,i){
var new_d = d
if (new_d[1] == 0){
new_d[1] = 0.50
}
return new_d
})
const options = {
chart: {
width: 200,
height: 450,
bottomWidth: 1 / 2,
bottomPinch: 1,
},
block: {
dynamicSlope: true,
dynamicHeight: true,
minHeight:50
},
label: {
enabled: true,
fontSize: '18px',
fill: '#fff',
/* format: '{l}: {f}' */
format: function(label, value) {
console.log('value', value);
if(value ==0.50){
var a=0;
return label+ ":" + a;
}else{
return label+ ":" + value;
}
}
},
tooltip: {
enabled: true,
format: '{l}: {f}'
}
};
const chart = new D3Funnel('#funnel');
chart.draw(newdata, options);
<script src="https://d3js.org/d3.v4.js"></script>
<script src="https://rawgit.com/jakezatecky/d3-funnel/master/dist/d3-funnel.min.js"></script>
<div id="funnel" style="transform: rotate(270deg);height: 539px;width:1px;margin-left:267px;"></div>
解决方案
推荐阅读
- apache-spark - 如何估计 Spark DataFrame 中每列的字节大小?
- r - R 维恩图错误 - 三重维恩图
- java - 从java后端服务以角度下载文件
- c# - C# 从正在运行的进程中获取输出
- snakemake - 获取从蛇文件中的命令行给出的实际 --cores [N]、--jobs [N]、-j [N] 值
- linux - 在目标中构建库以在主机中进行交叉编译
- outlook - 移动到 Exchange 中的文件夹时将电子邮件标记为未读
- java - 使用 jmsTemplate (Spring JMS) 重复调度消息以传递 ActiveMQ
- mysql - SQL Check(汽车租赁)
- r - 使用 r 获取列名并在数据框中的未列出列中分配值