区间角色i-line不会显示在Google折线图中

时间:2013-05-31 13:01:34

标签: charts google-visualization

我正在尝试为Google图表添加最小和最大限制,我使用CSV数据中的Perl脚本生成这些限制 - 使用the interval role获取这两个值。

不幸的是,虽然为了测试我将最小和最大限制设置为-100和100,但我的折线图上没有显示I线。

仅显示主要数据:

enter image description here

有人可以发现错误,我的非常简单的测试用例有什么问题吗?

请将以下代码保存为HTML文件并在浏览器中打开:

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script>
<script type="text/javascript">

        var data = {"L_B8_ACLR_50_0_QPSK_1_H":{"rows":[
            {"c":[{"v":"UTRA_1_DOWN"},{"v":-100},{"v":100},{"v":"-42.46912"}]},
            {"c":[{"v":"E-UTRA_1_DOWN"},{"v":-100},{"v":100},{"v":"-39.9545"}]},
            {"c":[{"v":"E-UTRA_1_UP"},{"v":-100},{"v":100},{"v":"-48.68408"}]},
            {"c":[{"v":"UTRA_1_UP"},{"v":-100},{"v":100},{"v":"-49.45148"}]},
            {"c":[{"v":"UTRA_2_UP"},{"v":-100},{"v":100},{"v":"-58.96674"}]}],

            "cols":[
            {"p":{"role":"domain"},"label":"MEASUREMENT","type":"string"},
            {"p":{"role":"interval"},"label":"LSL","type":"number"},
            {"p":{"role":"interval"},"label":"USL","type":"number"},
            {"p":{"role":"data"},"label":"1142926087","type":"number"}]}};

        function drawCharts() {
                for (var csv in data) {
                        var x = new google.visualization.DataTable(data[csv]);

                        var options = {
                                title: csv,
                                width: 800,
                                height: 600
                        };

                        var chart = new google.visualization.LineChart(document.getElementById(csv));
                        chart.draw(x, options);
                }
        }

        $(function() {
                google.setOnLoadCallback(drawCharts);
        });

</script>
</head>
<body>
<div id="L_B8_ACLR_50_0_QPSK_1_H"></div>
</body>
</html>

(我不想使用addColumnaddRows之类的方法。而是将我的数据作为数据结构在我的Perl脚本中准备,然后进行JSON编码并将其传递给{{1} } ctr)。

1 个答案:

答案 0 :(得分:1)

您必须在数据列之后指定interval-role列。正如API中所述:

除域名列以外的所有列都适用于可以应用的最近的左邻居

所以,如果你改变顺序(这里有一些较小的间隔)

var data = {"L_B8_ACLR_50_0_QPSK_1_H":{"rows":[
            {"c":[{"v":"UTRA_1_DOWN"},{"v":"-42.46912"},{"v":-50},{"v":-45}]},
            {"c":[{"v":"E-UTRA_1_DOWN"},{"v":"-39.9545"},{"v":-50},{"v":-45}]},
            {"c":[{"v":"E-UTRA_1_UP"},{"v":"-48.68408"},{"v":-50},{"v":-45}]},
            {"c":[{"v":"UTRA_1_UP"},{"v":"-49.45148"},{"v":-50},{"v":-45}]},
            {"c":[{"v":"UTRA_2_UP"},{"v":"-58.96674"},{"v":-50},{"v":-45}]}],

            "cols":[
            {"p":{"role":"domain"},"label":"MEASUREMENT","type":"string"},
            {"p":{"role":"data"},"label":"1142926087","type":"number"},
            {"p":{"role":"interval"},"label":"LSL","type":"number"},
            {"p":{"role":"interval"},"label":"USL","type":"number"}
            ]}};    

..你最终得到:

enter image description here