Highcharts使饼图显示0数据

时间:2018-02-26 18:58:42

标签: highcharts pie-chart

当我将以下数据提供给饼图:{ "_id": { "$oid": "5a736236ee687920e2fb736f" }, "img": "hauntedhouse.jpg", "name": "Holloween Party", "date": "2017-10-31", "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Praesentium hic molestiae cum eaque? Officia, temporibus, nobis! In labore quod, esse alias, quos, ex quae eius enim quisquam autem fugit consectetur.", "address": "Lorenzo \u201cLore\u201d Garcia Park - 413 E. Clark Ave", "start": "6:00 PM", "end": "10:00 PM", "phone": "555-555-555", "email": "asdf@asdf.com", "url": "http://www.test.com", "__v": 0 } 时,图表为空。

但是,我想让饼图显示三个切片,每个百分比分布等于[[0],[0],[0]]

我知道在这种情况下最好使用条形图/柱形图,但是我有这个边缘情况,我需要在饼图中显示0数据

1 个答案:

答案 0 :(得分:0)

解决方法

设置一些非零值并为每个点添加{"1":"one"} 标志。然后在isZero

中使用此标记
tooltip.pointFormatter

这会导致您的积分可见,如果悬停点的tooltip: { pointFormatter: function() { return "<span style='color:" + this.color + "'>\u25CF</span>" + this.series.name + ": <b>" + (this.options.isZero ? 0 : this.y) + "</b><br/>"; } } 标记设置为0,则会在工具提示中打印isZero

现场演示: http://jsfiddle.net/BlackLabel/52a1xh99/