Highcharts中点的动画

Animation from point in Highcharts

本文关键字:动画 Highcharts      更新时间:2023-09-26

如何在Highcharts中从某一点动画图形?

看这个JSfiddle。我可以说"从点[Date.UTC(1997,1,0),5.5]开始动画"吗?或者只制作某个系列的动画?

所以[Date.UTC(1997,1,0),5.5]之前的所有东西都不应该动画,只是在图形加载时"在那里"。

chart = new Highcharts.Chart({
    exporting: {
        enabled: false
    },
    chart: {
        renderTo: 'container',
        type: 'spline',
        marginRight: 20
    },
    title: {
        text: 'Kortetermijnraming CPB'
    },
    subtitle: {
        text: 'Werkloosheid stijgt tot 6%'
    },
    xAxis: {
        max: Date.UTC(2013, 1, 0),
        type: 'datetime',
        dateTimeLabelFormats: { // don't display the dummy year
            month: '%Y',
            year: '%Y'
        }
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Werkloosheid (%)'
        },
        plotLines: [{
            value: 0,
            width: 2,
            color: '#000000',
            zIndex: 5
        }, {
            label: {
                text: 'Werkloosheid',
                x: 0,
                align: 'right'
            },
            value: 5,
            width: 0.5,
            color: '#ffffff',
            zIndex: 1
        }]
    },
    tooltip: {
        formatter: function () {
            return '<b>' + this.series.name + '<br/>' + Highcharts.dateFormat('%Y', this.x) + ':</b> ' + this.y + '%';
        }
    },
    plotOptions: {
        series: {
            animation: {
                duration: 5000
            }
        },
        spline: {
            lineWidth: 3,
            states: {
                hover: {
                    lineWidth: 4
                }
            },
            marker: {
                enabled: false,
                states: {
                    hover: {
                        enabled: true,
                        symbol: 'circle',
                        radius: 4,
                        lineWidth: 1
                    }
                }
            }
        }
    },
    legend: {
        enabled: false
    },
});

为系列添加动画:

serie: [{
    animation: {
        duration: 5000
    },
    ...
}]