我的应用程序中有一个Highcharts图表。我需要显示一年中每个月售出了多少辆汽车,此图表显示了在13个月内(例如:2017年6月至2018年6月)销售的汽车,因此两次显示了同一个月(两年)。 X类别应类似于(6月,7月,8月,9月,10月,11月,12月,1月,2月,3月,4月,5月,6月)
但是问题是图表在图表中仅显示一个“六月”月。我认为类别名称重复是错误。有解决方法吗?
这是我到目前为止尝试过的:
// Create the chart
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Car Sales'
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total percent car salee'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
"series": [
{
"name": "Browsers",
"colorByPoint": true,
"data": [
{
"name": "January",
"y": 62.74,
},
{
"name": "February",
"y": 10.57,
},
{
"name": "March",
"y": 7.23,
},
{
"name": "April",
"y": 5.58,
},
{
"name": "May",
"y": 4.02,
},
{
"name": "June",
"y": 1.92,
},
{
"name": "July",
"y": 7.62,
},
{
"name": "August",
"y": 7.62,
},
{
"name": "September",
"y": 7.62,
},
{
"name": "October",
"y": 7.62,
},
{
"name": "November",
"y": 7.62,
},
{
"name": "December",
"y": 7.62,
},
{
"name": "January",
"y": 7.62,
}
]
}
],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
JSfiddle链接:https://jsfiddle.net/yasirunilan/2ryfnv3q/
答案 0 :(得分:1)
在向下钻取中实现此目的的最简单方法是“欺骗”类别名称。如果您能够在下钻的第二个Jan
末尾添加空格(或其他任意随机字符),则可以解决此问题。
Click here展示了解决方案。
"drilldown": {
"series": [
{
"name": "Chrome",
"id": "Chrome",
"data": [
{
"name": "Jan",
"y": 0.1
},
{
"name": "Feb",
"y": 0.1
},
//snip
{
"name": "Jan ",
"y": 0.1
}
]
},