aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/speedometer/c3-master/spec/c3-helper.js
blob: 970cd1b7cdd02383a97977965bc5d638f3f9cdb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function initDom() {
    'use strict';

    var div = document.createElement('div');
    div.id = 'chart';
    div.style.width = '640px';
    div.style.height = '480px';
    document.body.appendChild(div);
    document.body.style.margin = '0px';
}
typeof initDom !== 'undefined';

function setMouseEvent(chart, name, x, y, element) {
    'use strict';

    var paddingLeft = chart.internal.main.node().transform.baseVal.getItem(0).matrix.e,
        event = document.createEvent("MouseEvents");
    event.initMouseEvent(name, true, true, window,
                       0, 0, 0, x + paddingLeft, y + 5,
                       false, false, false, false, 0, null);
    chart.internal.d3.event = event;
    if (element) { element.dispatchEvent(event); }
}
typeof setMouseEvent !== 'undefined';

function initChart(chart, args, done) {
    'use strict';

    if (typeof chart === 'undefined') {
        window.initDom();
    }
    if (args) {
        chart = window.c3.generate(args);
        window.d3 = chart.internal.d3;
        window.d3.select('.jasmine_html-reporter')
            .style('position', 'absolute')
            .style('width', '640px')
            .style('right', 0);
    }

    window.setTimeout(function () {
        done();
    }, 10);

    return chart;
}
typeof initChart !== 'undefined';