0

我正在尝试向 Google 图表添加最小和最大限制,该图表是使用 CSV 数据中的 Perl 脚本生成的 - 通过对这两个值使用间隔角色

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

仅显示主要数据:

在此处输入图像描述

谁能发现错误,我非常简单的测试用例有什么问题?

请将下面的代码保存为 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>

(我不想使用addColumnor之类的方法addRows。相反,我将数据准备为 Perl 脚本中的数据结构,然后进行 JSON 编码并将其传递给DataTablectr)。

4

1 回答 1

1

您必须在数据列之后指定间隔角色列。正如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"}
            ]}};    

..你最终得到:

在此处输入图像描述

于 2013-06-03T12:46:26.307 回答