目录

3D Donut

我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置

下面给出了3D甜甜圈图的示例。

配置 (Configurations)

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

chart.options3d

将图表类型配置为基于3D。 将类型设置为“饼图”。 这里,图表可以三维呈现。

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

plotOptions.pie.innerSize

馅饼内径的大小。 大于0的大小会显示donut chart 。 大小可以是百分比或像素值。 百分比与饼图大小有关。 像素值以整数给出。 这里,默认值为0。

plotOptions.pie.depth

3D馅饼的厚度。

plotOptions: {
   pie: {
      innerSize: 100,
      depth: 45
   }
},

例子 (Example)

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>

结果 (Result)

验证结果。

新页面打开
↑回到顶部↑
WIKI教程 @2018