C3.js分组问题

时间:2015-10-04 19:06:46

标签: stack grouping c3.js

我正在构建一个监控网络流量的C3.js应用程序。不幸的是,我的数据点遍布时间线,不同组的数据可能在不同的时间出现。为了使问题复杂化,某些数据集包含的数据点多于其他数据点。为了更好地使用示例,请考虑以下数据:

c3.data.columns = [
    [
        "10.31.144.30->192.168.100.17:443 (1374.61 KB)",
        6600,
        34900
    ],
    [
        "10.31.144.35->192.168.100.1:443 (1333.4 KB)",
        8500,
        1900,
        6500,
        12700
    ],
    [
        "10.31.144.32->192.168.100.19:80 (710.45 KB)",
        18500
    ],
    [
        "10.31.144.30->192.168.100.14:80 (774.56 KB)",
        10836,
        10272
    ],
    [
        "10.31.144.33->192.168.100.2:443 (642.87 KB)",
        13900
    ]
]

上面的数据很好,直到我开始使用以下参数对其进行分组:

c3.data.groups = [[
    "10.31.144.30->192.168.100.17:443 (1374.61 KB)",
    "10.31.144.35->192.168.100.1:443 (1333.4 KB)",
    "10.31.144.32->192.168.100.19:80 (710.45 KB)",
    "10.31.144.30->192.168.100.14:80 (774.56 KB)",
    "10.31.144.33->192.168.100.2:443 (642.87 KB)"
]]

有人知道为什么我的案件中的分组不起作用吗?它在下面的函数中抛出JS错误:

c3_chart_internal_fn.getShapeOffset = function (typeFilter, indices, isSub) {
        var $$ = this,
            targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))),
            targetIds = targets.map(function (t) { return t.id; });
        return function (d, i) {
            var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id),
                y0 = scale(0), offset = y0;
            targets.forEach(function (t) {
                var values = $$.isStepType(d) ? $$.convertValuesToStep(t.values) : t.values;
                if (t.id === d.id || indices[t.id] !== indices[d.id]) { return; }
                if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) {
                    if (values[i].value * d.value >= 0) {
                        offset += scale(values[i].value) - y0;
                    }
                }
            });
            return offset;
        };
    };

0 个答案:

没有答案