【发布时间】:2017-07-21 09:36:08
【问题描述】:
我尝试从 CSV 数据加载数据以创建饼图。 总是有切片显示“切片:0.0%”。但是,在我的 CSV 数据中,没有所谓的切片数据。我想知道这是因为 highchart 的默认设置还是因为我使用错误的方式读取 CSV 数据文件。
下面是图表的照片。
var pie_bl = Papa.parse(document.getElementById('pie_bl').innerHTML);
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
data: {
rows: pie_bl.data
},
title: {
text: 'Pie Chart_csv'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
});
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/data.js"></script>
<script src="https://rawgit.com/mholt/PapaParse/master/papaparse.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
<pre id="pie_bl" style="display:none">Category,Allocation
a,0.45,
b,0.5,
c,1.25,
d,0.15,
e,0.1,
f,0.55,
</pre>
【问题讨论】:
标签: javascript csv highcharts