目录

带反转轴的样条曲线(Spline with inverted axes)

以下是具有反转轴的样条曲线图的示例。

我们已经看到用于在Highcharts Configuration Syntax章节中绘制图表的配置 。 现在,我们将讨论具有反转轴的样条图的示例。

配置 (Configurations)

将图表类型配置为基于样条线。 chart.type决定图表的系列类型。 这里,默认值是“line”。

配置要反转的轴。 当true x axis是垂直的而y axis是水平的时 - 如果图表中存在条形系列,则相反的方向将被反转。 这里,默认值为false。

图表

var chart = {
   type: 'spline',
   inverted: true
}; 

例子 (Example)

highcharts_spline_inverted.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>  
   </head>
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto"></div>
      <script language = "JavaScript">
         $(document).ready(function() {  
            var chart = {
               type: 'spline',
               inverted: true
            }; 
            var title = {
               text: 'Atmosphere Temperature by Altitude'   
            };
            var subtitle = {
               text: 'According to the Standard Atmosphere Model'
            };
            var xAxis = {
               reversed: false,
               title: {
                  enabled: true,
                  text: 'Altitude'
               },
               labels: {
                  formatter: function () {
                     return this.value + 'km';
                  }
               },
               maxPadding: 0.05,
               showLastLabel: true
            };
            var yAxis = {
               title: {
                  text: 'Temperature'
               },
               labels: {
                  formatter: function () {
                     return this.value + '\xB0';
                  }
               },
               lineWidth: 2
            };
            var legend = {
               enabled: false 
            };
            var tooltip = {
               headerFormat: '<b>{series.name}</b><br/>',
               pointFormat: '{point.x} km: {point.y}\xB0C'
            };
            var plotOptions = {
               spline: {
                  marker: {
                     enable: false
                  }
               }
            };
            var series = [{
               name: 'Temperature',
               data: [[0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1],
                  [50, -2.5], [60, -27.7], [70, -55.7], [80, -76.5]]
            }];      
            var json = {};
            json.chart = chart;
            json.title = title;
            json.subtitle = subtitle;
            json.legend = legend;
            json.tooltip = tooltip;
            json.xAxis = xAxis;
            json.yAxis = yAxis;  
            json.series = series;
            json.plotOptions = plotOptions;
            $('#container').highcharts(json);
         });
      </script>
   </body>
</html>

结果 (Result)

验证结果。

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