【发布时间】:2017-12-29 16:13:52
【问题描述】:
我想使用如下所示的任何 jquery 库生成一个顶级快照图表。但到目前为止,我只成功地生成了图表的顶部(示例图像中的“Salary”)。 Here is my first attempt using Hicharts(代码如下),
我不知道如何包含下面的部分,它以平铺图样式显示各种数字评级(示例图像中的“老板评级”、“原因”等)。
可以使用heatmap 包含下半部分,但我不知道如何将它与上图结合起来。
如何在堆叠图表下方包含带有标签的图块?如果无法使用 Hicharts,我也可以使用另一个 jQuery 库。
以下是我目前所拥有的示例代码:
HTML:
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
JavaScript:
Highcharts.chart('container', {
chart: {
type: 'area',
spacingBottom: 20
},
title: {
text: 'Fruit consumption *'
},
subtitle: {
text: '* Jane\'s banana consumption is unknown',
floating: true,
align: 'right',
verticalAlign: 'bottom',
y: 15
},
legend: {
layout: 'horizontal',
align: 'bottom',
verticalAlign: 'bottom',
x: 150,
y: 100,
floating: false,
borderWidth: 1,
backgroundColor: (Highcharts.theme &&
Highcharts.theme.legendBackgroundColor) ||
'#FFFFFF'
},
xAxis: {
categories: ['Apples', 'Pears', 'Oranges', 'Bananas',
'Grapes', 'Plums', 'Strawberries', 'Raspberries']
},
yAxis: {
title: {
text: 'Y-Axis'
},
labels: {
formatter: function () {
return this.value;
}
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
this.x + ': ' + this.y;
}
},
plotOptions: {
area: {
fillOpacity: 0.5
}
},
credits: {
enabled: false
},
series: [{
name: 'John',
data: [4,5]
}, {
name: 'Jane',
data: [2,2],
}, {
name: 'Jane',
data: [1,1],
}, {
name: 'Jane',
data: [null,null,4,6],
}, {
name: 'Jane',
data: [null,null,2,2],
}, {
name: 'Jane',
data: [null,null,1,1],
}]
});
【问题讨论】:
-
jsfiddle.net/aLnc2nbv 我试过了,但我无法在右侧等所有标签...
-
@akraf : 我的期望不是开发完整的解决方案,我只期望允许将面积和柱形图结合在一起,对我来说就足够了。
-
我编辑了您的问题以包含您发布的代码和您的问题。如有必要,请查看并更正。我还包括您在问题的 cmets 中发布的问题。如果我理解正确,请查看
标签: highcharts stacked-area-chart