aboutsummaryrefslogtreecommitdiffstats
path: root/uiframe-iui/src/main/resources/webroot/vendor/ict/dashboard-jq/demo/ict-barchart-c3.js
blob: ee1040cab5ac5f163e83731e2727965d3432ca7a (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var ICT_Bar_Chart_C3 = function (placeholdeC3, inputData, callbackList) {

    var language;
    //取得国际化信息
    $.ajax({
        dataType: "json",
        url: "/web/newict/framework/thirdparty/flotchart/i18n/ict-barchart-flot-" + getLanguage() + ".json",
        async: false,
        contentType: "application/json; charset=utf-8",
        "success": function (data) {
            language = data.language;
        },
        "error": function (xhr, info) {
            alert("Communication Error! Error reason:" + info);
        }
    });

    var config = {};
    config.bindto = '#' + placeholdeC3;
    config.data = {};
    config.data.json = {};
    config.data.json["告警"] = inputData;
    config.axis = {"y": {"label": {"text": "Number of Alarms", "position": "outer-middle"}}};
    config.axis.x = {
        type: 'category',
        categories: [language[0].value, language[1].value, language[2].value, language[3].value]
    };
    /* config.axis.y.tick = {
     format: function(data){
     return data + "%";
     }
     }; */
    config.data.types = {};
    config.data.types["告警"] = "bar";
    config.data.color = function (inColor, data) {
        if (data.index !== undefined) {
            return language[data.index].color;
        }
        return inColor;
    },
        config.data.onclick = function (data, element) {
            if (data.index !== undefined) {
                var severity = data.index + 1;
                window.open(
                    "/web/res/web-framework/default.html?showNav=false&severity="
                    + severity + "#uep-ict-fm-currentAlarm", "fm_portlet_page_title"
                    + severity, "");
            }
        },
        //config.data.colors = ['red', 'green', 'blue', 'yellow'];
        config.legend = {
            show: false
        };
    $.facebox.charts[placeholdeC3] = c3.generate(config);

    /* if($.facebox.isExpand(placeholdeC3)){
     barChartData = $.facebox.barChartData;
     }else{
     $.facebox.barChartData = barChartData;
     }		 */

    $.each(callbackList, function (index, callback) {
        callback();
    });

}