我正在使用highcharts,需要列出列出的类别和子类别。
E.g:
我有一些运动员,我希望按地点和性别列出奖牌。
所以必须列出所有奖牌类型,并将这些类别分为男性和女性
| GOLD | SILVER | BRONZE |
|male|female||male|female||male|female|
---------------------------------------
| cl | cl | cl | cl | cl | cl |
* cl =某些列,其中包含每种性别类型的奖牌数据
是否可以在highcharts中使用,如果可以,怎么样?
答案 0 :(得分:8)
这是一个旧的请求,但由于我不得不做类似的事情,我会分享解决方案 - 构建在HighCharts的多个类别插件上 - 这里是来自jsfiddle的代码 - http://jsfiddle.net/fieldsure/Lr5sjh5x/2/
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: "container",
type: "column",
borderWidth: 5,
borderColor: '#e8eaeb',
borderRadius: 0,
backgroundColor: '#f7f7f7'
},
title: {
style: {
'fontSize': '1em'
},
useHTML: true,
x: -27,
y: 8,
text: '<span class="chart-title"> Grouped Categories with 2 Series<span class="chart-href"> <a href="http://www.blacklabel.pl/highcharts" target="_blank"> Black Label </a> </span> <span class="chart-subtitle">plugin by </span></span>'
},
yAxis: [{ // Primary yAxis
labels: {
format: '${value}',
style: {
color: Highcharts.getOptions().colors[0]
}
},
title: {
text: 'Daily Tickets',
style: {
color: Highcharts.getOptions().colors[0]
}
}
}, { // Secondary yAxis
title: {
text: 'Invoices',
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '${value}',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}]
,
series: [{
name: 'Daily',
type: 'column',
yAxis: 1,
data: [4, 14, 18, 5, 6, 5, 14, 15, 18],
tooltip: {
valueSuffix: ' mm'
}
}, {
name: 'Invoices',
type: 'column',
data: [4, 17, 18, 8, 9, 5, 13, 15, 18],
tooltip: {
valueSuffix: ' °C'
}
}],
xAxis: {
categories: [{
name: "1/1/2014",
categories: ["Vendor 1", "Vendor 2", "Vendor 3"]
}, {
name: "1/2/2014",
categories: ["Vendor 1", "Vendor 2", "Vendor 3"]
}, {
name: "1/3/2014",
categories: ["Vendor 1", "Vendor 2", "Vendor 3"]
}]
}
});
});
答案 1 :(得分:1)
我认为你需要一个堆积的条形图。根据您的数据跟踪示例。 http://jsfiddle.net/AtGRH/
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['Gold', 'Silver', 'Bronze']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
}
},
legend: {
backgroundColor: '#FFFFFF',
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: 'Male',
data: [5, 3, 4 ]
}, {
name: 'Female',
data: [2, 2, 3]
},]
});
});