-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQSenseBalance.js
108 lines (96 loc) · 3.16 KB
/
QSenseBalance.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
define(["./balance", "./d3.min", "css!./QSenseBalance.css"],
function(template) {
"use strict";
//définition de l'objet
return {
initialProperties: {
qHyperCubeDef: {
qDimensions: [],
qMeasures: [],
qInitialDataFetch: [{
qWidth: 2,
qHeight: 50
}]
}
},
definition: {
type: "items",
component: "accordion",
items: {
measures: {
uses: "measures",
min: 1,
max: 2
},
Setting: {
uses: "settings",
items: {
Colors: {
}
}
}
}
},
snapshot: {
canTakeSnapshot: true
},
//affichage de l'objet
paint: function($element, layout) {
//Taille de l'objet
var width = $element.width();
var height = $element.height();
var id = "container_" + layout.qInfo.qId;
//construction de la div
if (document.getElementById(id)) {
$("#" + id).empty();
} else {
$element.append($('<div />').attr("id", id).attr("class", "viz").width(width).height(height));
}
//recup des données
var hc = layout.qHyperCube;
//recup de la zone d'affichage
var div = document.getElementById(id);
var tooLong = ' ';
console.log(hc.qMeasureInfo[0].qFallbackTitle.length);
if (hc.qMeasureInfo[0].qFallbackTitle.length > 13) {
tooLong = '... ';
}
//recup de la valeur de la mesure
var measureName = hc.qMeasureInfo[0].qFallbackTitle.substr(0, 13) + tooLong + hc.qDataPages[0].qMatrix[0][0].qText;
var value = hc.qDataPages[0].qMatrix[0][0].qNum;
if (hc.qDataPages[0].qMatrix[0].length > 1) {
tooLong = ' ';
if (hc.qMeasureInfo[1].qFallbackTitle.length > 13){
tooLong = '... ';
}
var value2 = hc.qDataPages[0].qMatrix[0][1].qNum;
var measureName2 = hc.qMeasureInfo[1].qFallbackTitle.substr(0, 13) + tooLong + hc.qDataPages[0].qMatrix[0][1].qText;
}
var iconGauge = layout.iconGauge;
var bal = balance(div, width, height,
[0, 0, 1, 1, 0, 1, 0],
["Advice", "Waiting Time", "Service", "Explanation", "Atmosphere", "Welcome", "Farewell"],
4.2
)
.setBg("cyan")
.setPivotColor("green")
.setPivotLineColor("blue")
.setInclination("5")
.setLevelColor("yellow")
.setFontColor("grey")
.setFontSize(22)
.setWordColor(
[
{"label": "Advice", "color": "orange"},
{"label": "Waiting Time", "color": "green"},
{"label": "Service", "color": "yellow"},
{"label": "Explanation", "color": "brown"},
{"label": "Atmosphere", "color": "purple"},
{"label": "Welcome", "color": "pink"},
{"label": "Farewell", "color": "pink"}
]
)
.render();
}
};
});