旋转高图

时间:2016-11-10 13:15:22

标签: javascript highcharts

我有以下代码

<!DOCTYPE html>
<head>
  <title>Shipment tracker</title>
  <script type="text/javascript" src="file:///android_asset/jquery.min.js"></script>
  <script type="text/javascript" src="file:///android_asset/highcharts.js"></script>
  <script type="text/javascript" src="file:///android_asset/highcharts-3d.js"></script>

  <script>

    function loadShipment(){
         $(function () {
              $('#container').highcharts({
                  colors:['#F58835','#F32D2B',],
                    chart: {
                        type: 'column'
                    },options3d: {
                    enabled: true,
                    alpha: 15,
                    beta: 15,
                    depth: 50,
                    viewDistance: 25
                },title: {
                        text: 'Shipment '
                    },
                    subtitle: {
                        text: ''
                    },
                    xAxis: {
                        categories: [
                            '2000',
                            '2001',
                            '2002',
                            '2003',
                            '2004',
                        ],
                        crosshair: true,
                        labels: {
                              useHTML: true,
                          },

                    },
                    yAxis: {
                        min: 0,
                        title: {
                            text: 'Shipment data'
                        },
                        allowDecimals: false
                    },
                    tooltip: {
                        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                        pointFormat: '<tr><td style="padding:0">{series.name}: </td>' +
                            '<td style="padding:0"><b>{point.y:.0f}</b></td></tr>',
                        footerFormat: '</table>',
                        shared: true,
                        useHTML: true
                    },
                    plotOptions: {
                        column: {
                            pointPadding: 0,
                            groupPadding: 0.3,
                            borderWidth: 0,
                            dataLabels: {
                            enabled: true,
                            textShadow:null,
                            // format:'{point.percentage:.0f}%'
                            format:'{point.y}'
                            },animation: {
                    duration: 15000
                }, column: {
         depth: 25
      },
                          point: {
                            events: {
                                click: function() {
                                    var drilldown = this.drilldown;
                                    if (drilldown) { 
                                            loadDrillDownData(drilldown);
                                    }
                                }
                              }
                            }
                        }
                    },
                    series: [{
                        name: 'Delayed Shipment',
                        data: [9, 5, 9, 8, 4,],
                    }, {
                        name: 'Shipped',
                        data: [0, 1, 2, 3, 1, ],
                    }]
                });

          });


    }
  </script>
</head>
<body>
    <div id="container" ></div>
    <div id="sliders">
        <table>
            <tr><td>Alpha Angle</td><td><input id="R0" type="range" min="0" max="45" value="15"/> <span id="R0-value" class="value"></span></td></tr>
            <tr><td>Beta Angle</td><td><input id="R1" type="range" min="0" max="45" value="15"/> <span id="R1-value" class="value"></span></td></tr>
        </table>
    </div>
</body>
</html>

我想在用户滑动边框时旋转图表。我怎么能这样做?这可行吗?我尝试添加代码,如下所示

 $('#R0').on('change', function () {
      highchart.options.chart.options3d.alpha = this.value;
      highchart.redraw(false);
   });
   $('#R1').on('change', function () {
      highchart.options.chart.options3d.beta = this.value;
      highchart.redraw(false);
   });

但它不起作用

1 个答案:

答案 0 :(得分:1)

在更改图表设置时,需要使用更新方法而不是使用重绘方法。 http://api.highcharts.com/highstock/Chart.update

这样就变成了:

{{1}}