0

如何从 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
    },
});
4

1 回答 1

1

为系列添加动画:

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

演示

于 2012-12-28T11:05:14.340 回答