3D Pie

优质
小牛编辑
130浏览
2023-12-01

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

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

配置 (Configurations)

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

chart.options3d

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

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

例子 (Example)

highcharts_3d_pie.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,
                  beta: 0
               }
            };
            var title = {
               text: 'Browser market shares at a specific website, 2014'   
            };   
            var tooltip = {
               pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            };
            var plotOptions = {
               pie: {
                  allowPointSelect: true,
                  cursor: 'pointer',
                  depth: 35,
                  dataLabels: {
                     enabled: true,
                     format: '{point.name}'
                  }
               }
            };   
            var series = [{
               type: 'pie',
               name: 'Browser share',
               data: [
                  ['Firefox',   45.0],
                  ['IE',       26.8],
                  {
                     name: 'Chrome',
                     y: 12.8,
                     sliced: true,
                     selected: true
                  },
                  ['Safari',    8.5],
                  ['Opera',     6.2],
                  ['Others',   0.7]
               ]
            }];     
            var json = {};   
            json.chart = chart; 
            json.title = title;       
            json.tooltip = tooltip; 
            json.plotOptions = plotOptions; 
            json.series = series;   
            $('#container').highcharts(json);
         });
      </script>
   </body>
</html>