【问题标题】:highchart threshold color with live updating series具有实时更新系列的高图阈值颜色
【发布时间】:2013-07-15 14:45:52
【问题描述】:

我正在尝试将 Highcharts v3.0.2 的新阈值/negativeColor 功能基本上应用于“spline updating each second”示例。

在图表更新的动画过程中,我在系列行中看到了奇怪的伪影 - 看起来它正在对一组不同的控制点进行动画处理......然后当动画(的新数据点进来)完成。

注释掉阈值/negativeColor 特征会使这种视觉伪影消失。

我看到错误了吗?

更新:我发布以下代码作为示例,这是股票 highcharts 演示(我的本地 jquery 是 v1.10.2),我添加了阈值/颜色/negativeColor 行(系列下的第一行)。这段代码似乎行为不端。

<html>
<head>
<script src="js/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<script>
$(function () {
    $(document).ready(function() {
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });

        var chart;
        $('#container').highcharts({
            chart: {
                type: 'spline',
                animation: Highcharts.svg, // don't animate in old IE
                marginRight: 10,
                events: {
                    load: function() {

                        // set up the updating of the chart each second
                        var series = this.series[0];
                        setInterval(function() {
                            var x = (new Date()).getTime(), // current time
                                y = Math.random();
                            series.addPoint([x, y], true, true);
                        }, 1000);
                    }
                }
            },
            title: {
                text: 'Live random data'
            },
            xAxis: {
                type: 'datetime',
                tickPixelInterval: 150
            },
            yAxis: {
                title: {
                    text: 'Value'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                formatter: function() {
                        return '<b>'+ this.series.name +'</b><br/>'+
                        Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
                        Highcharts.numberFormat(this.y, 2);
                }
            },
            legend: {
                enabled: false
            },
            exporting: {
                enabled: false
            },
            series: [{
                threshold: 0.5,
                color: '#FF0000',
                negativeColor: '#00FF00',
                name: 'Random data',
                data: (function() {
                    // generate an array of random data
                    var data = [],
                        time = (new Date()).getTime(),
                        i;

                    for (i = -19; i <= 0; i++) {
                        data.push({
                            x: time + i * 1000,
                            y: Math.random()
                        });
                    }
                    return data;
                })()
            }]
        });
    });

});
</script>
</head>

<body>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>

【问题讨论】:

  • 没有看到你是如何设置阈值和negativeColor的,真的很难回答。你能发布一些显示这种行为的示例代码吗?
  • 感谢您的快速响应 - 添加的示例代码似乎与描述的行为不符。
  • 这看起来真的很酷。似乎较低的值(绿色)在添加新点时会出现古怪的波动,而“红色”值只是向左滑动。
  • 我会将其归类为错误。这是 jsFiddle 展示了这一点:jsfiddle.net/kkzkq

标签: highcharts


【解决方案1】:

确实它看起来像一个错误,报告here。目前您只能禁用动画。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-19
    • 2016-09-27
    • 1970-01-01
    • 2021-10-17
    • 1970-01-01
    • 2016-07-15
    相关资源
    最近更新 更多