Highcharts 3D 圆环图
我们已经在Highcharts配置语法一章中看到了用于绘制图表的配置。
下面给出了一个 3D 圆环图的例子。
配置
现在让我们看看额外的配置/步骤。
chart.options3d
将图表类型配置为基于 3D。将类型设置为"饼"。在这里,图表可以以 3 个维度呈现。
var chart = {
type: 'pie',
options3d: {
enabled: true,
alpha: 15,
beta: 15,
depth: 50,
viewDistance: 25
}
};
plotOptions.pie.innerSize
饼的内径大小。大于 0 的大小呈现
圆环图。大小可以是百分比或像素值。百分比与饼图大小有关。像素值以整数形式给出。这里,默认值为 0。
plotOptions.pie.depth
3D 饼的厚度。
plotOptions: {
pie: {
innerSize: 100,
depth: 45
}
},
示例
highcharts_3d_donut.htm
<html>
<head>
<title>Highcharts Tutorial</title>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script src = "https://code.highcharts.com/highcharts.js"></script>
<script src = "https://code.highcharts.com/highcharts-3d.js"></script>
</head>
<body>
<div id = "container" style = "width: 550px; height: 400px; margin: 0 auto"></div>
<script language = "JavaScript">
$(document).ready(function() {
var chart = {
type: 'pie',
options3d: {
enabled: true,
alpha: 45
}
};
var title = {
text: 'Contents of Highsoft\'s weekly fruit delivery'
};
var subtitle = {
text: '3D donut in Highcharts'
};
var plotOptions = {
pie: {
innerSize: 100,
depth: 45
}
};
var series = [{
name: 'Delivered amount',
data: [
['Bananas', 8],
['Kiwi', 3],
['Mixed nuts', 1],
['Oranges', 6],
['Apples', 8],
['Pears', 4],
['Clementines', 4],
['Reddish (bag)', 1],
['Grapes (bunch)', 1]
]
}];
var json = {};
json.chart = chart;
json.title = title;
json.subtitle = subtitle;
json.plotOptions = plotOptions;
json.series = series;
$('#container').highcharts(json);
});
</script>
</body>
</html>