Highcharts失去平滑的缩放效果

时间:2017-01-16 12:46:32

标签: highcharts

当'series'选项中的'data'总共少于100个元素时,可以进行平滑缩放。如果不这样做,平滑缩放就会消失。

add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
    function add_custom_price( $cart_object ) {   
        foreach ( $cart_object->cart_contents as $key => $value ) {   
            $productId = $value['data']->id;
            if ( check delivered product) {
            {
                // product to be delivered              
                $value['data']->price = $value['data']->price + $your_custom_price;
            }
            else{
                //book table
                $value['data']->price = $value['data']->price;
            }
        }
    }
    }
$(function () {
    $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=usdeur.json&callback=?', function (data) {
				var length = 99;
        data = data.slice(0, length);
        Highcharts.chart('container', {
            chart: {
                zoomType: 'x'
            },
            title: {
                text: 'USD to EUR exchange rate over time'
            },
            subtitle: {
                text: document.ontouchstart === undefined ?
                        'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
            },
            xAxis: {
                type: 'datetime'
            },
            yAxis: {
                title: {
                    text: 'Exchange rate'
                }
            },
            legend: {
                enabled: false
            },
            plotOptions: {
                area: {
                    fillColor: {
                        linearGradient: {
                            x1: 0,
                            y1: 0,
                            x2: 0,
                            y2: 1
                        },
                        stops: [
                            [0, Highcharts.getOptions().colors[0]],
                            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                        ]
                    },
                    marker: {
                        radius: 2
                    },
                    lineWidth: 1,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    threshold: null
                }
            },

            series: [{
                type: 'area',
                name: 'USD to EUR',
                data: data
            }]
        });
    });
});

即使'数据'在'系列'中有100个以上的元素,有没有办法进行平滑缩放?

1 个答案:

答案 0 :(得分:0)

chart.animation设为true。

chart: {
        type: 'line',
        zoomType: 'x',
        animation: true
    },

示例:http://jsfiddle.net/ky38kkn8/