我正在尝试在图表下方获取自定义图例,我可以添加自己的文字。
在下面的示例中,我想为每个违规代码创建图例。它将是描述违规代码的静态文本。 可能吗 ?如果是这样,我该如何实现呢?
这是我的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Staten Island Violation Code Destribution</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<style type="text/css">
${demo.css}
</style>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Staten Island Violation Distribution'
},
subtitle: {
text: 'Source: NYC Open DataSet</a>'
},
xAxis: {
type: 'category',
labels: {
rotation: -45,
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
}
},
data: {
csv: document.getElementById('csv').innerHTML
},
yAxis: {
min: 0,
title: {
text: 'Count'
}
},
legend: {
enabled: false
},
tooltip: {
pointFormat: 'Count: <b>{point.y}</b>'
},
series: [{
name: 'Violation Count',
dataLabels: {
enabled: true,
rotation: -90,
color: '#FFFFFF',
align: 'right',
format: '{point.y}', // one decimal
y: 10, // 10 pixels down from the top
style: {
fontSize: '8px',
fontFamily: 'Verdana, sans-serif'
}
}
}]
});
});
</script>
</head>
<body>
<script src="../../js/highcharts.js"></script>
<script src="../../js/modules/exporting.js"></script>
<script src="../../js/modules/data.js"></script>
<div id="container" style="min-width: 300px; height: 400px; margin: 0 auto"></div>
<pre id="csv" style="display:none">
VIOLATIONCODE,COUNT
10F,843
06D,603
02G,602
10B,583
08A,517
06C,472
02B,415
04L,405
04H,322
06E,317
04N,293
04A,283
06F,267
10H,262
Others,3335
</pre>
</body>
</html>
答案 0 :(得分:1)
将每个违规代码对齐在自己的系列中,然后定义系列标题将实现我认为您正在寻找的内容。
<pre id="csv" style="display:none">
VIOLATIONCODE,Description1,Description2,Description3,Description4,Description5,Description6
10F,843
06D,,603
02G,,,602
10B,,,,583
08A,,,,,517
06C,,,,,,472
[...]
</pre>
同时将您的dataLabels
媒体资源移至plotOptions
并将grouping
设为false。