计数任何图表标签的功能

时间:2016-11-02 16:19:27

标签: anychart

我有一张饼图,我使用anychart.js

制作

JSFiddle

我想要实现的目标是让图表上的标签“数字化”。页面加载时我有一个有效的javascript示例位于Here

以下是我用来实现此目的的代码

$(document).ready(function () {
    $('.count').each(function () {
    $(this).prop('Counter', 0).animate({
        Counter: $(this).text()
    }, {
        duration: 4000,
        easing: 'swing',
        step: function (now) {
            $(this).text(Math.ceil(now));
        }
    });
});
});

我只是不知道如何将其附加到饼图上的标签上。

2 个答案:

答案 0 :(得分:1)

如果你切换到7.12.0,你可以开箱即用动画:http://jsfiddle.net/jqqgf5r1/7/

    chart.animation(true);

答案 1 :(得分:0)

不确定我是否理解你想要实现的目标,但我希望这个样本能够得到帮助 http://jsfiddle.net/jqqgf5r1/10/

    // update progress values in data to random values every 500ms
    setInterval(function() {
        var pointsCount = data.getRowsCount();
                for (var i = 0; i < pointsCount; i++) {
        chart.data().set(i, 'progress', Math.ceil(Math.random() * 100));
      }
    }, 500);