Highcharts - 三维甜甜圈图



我们在 Highcharts 配置语法 章节中已经看到了用于绘制图表的配置。

以下给出了三维甜甜圈图的示例。

配置

现在让我们看看采取的其他配置/步骤。

chart.options3d

将图表类型配置为基于三维。将类型设置为“饼图”。此处,图表可以呈现三维。

var chart = {
   type: 'pie',
   options3d: {
      enabled: true,
      alpha: 15,
      beta: 15,
      depth: 50,
      viewDistance: 25
   }
};

plotOptions.pie.innerSize

饼图的内径大小。大于 0 的大小会呈现一个圆环图。大小可以为百分比或像素值。百分比相对于饼图大小。像素值给定为整数。此处,默认值为 0。

plotOptions.pie.depth

三维饼图的厚度。

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>

结果

验证结果。

highcharts_3d_charts.htm
广告