HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
166
1
anychart.onDocumentReady(function () {
2
3
// set stage
4
var stage = anychart.graphics.create("container");
5
6
// Title settings
7
var title = anychart.standalones.title();
8
title.fontFamily("verdana, helvetica, arial, sans-serif").fontWeight("normal");
9
title.text("<span style='color:#86cf38; font-size: 16px;'>System Availability</span> <span style='color: #666666; font-size: 10px; font-weight: normal;'>(last 30 days)</span>");
10
title.orientation("top").align("left").vAlign("bottom").margin(10).padding(0).height(20).useHtml(true);
11
title.container(stage).draw();
12
13
// Data for charts in table
14
var Availability = anychart.data.set([
15
[Date.UTC(2013, 10), 98.6, 98.6, 95.3, 97.9, 99.0, 97.0, 96.1],
16
[Date.UTC(2013, 11), 98.5, 98.9, 95.9, 98.4, 98.4, 97.9, 96.1],
17
[Date.UTC(2014, 0), 98.5, 98.8, 96.7, 98.5, 99.1, 98.2, 96.0],
18
[Date.UTC(2014, 1), 99.0, 98.3, 95.6, 98.8, 98.2, 98.9, 95.9],
19
[Date.UTC(2014, 2), 99.2, 98.6, 96.8, 99.0, 98.2, 98.2, 95.7],
20
[Date.UTC(2014, 3), 99.0, 98.7, 95.8, 99.3, 97.9, 98.7, 95.5],
21
[Date.UTC(2014, 4), 99.3, 98.9, 96.3, 99.2, 98.6, 98.4, 95.0],
22
[Date.UTC(2014, 5), 99.1, 98.3, 95.6, 99.4, 99.1, 98.5, 94.9],
23
[Date.UTC(2014, 6), 99.0, 98.1, 95.4, 99.4, 98.4, 98.6, 94.8],
24
[Date.UTC(2014, 7), 99.3, 99.0, 95.5, 99.5, 99.2, 98.5, 95.0],
25
[Date.UTC(2014, 8), 99.5, 98.9, 96.7, 99.6, 99.2, 98.7, 94.8],
26
[Date.UTC(2014, 9), 99.7, 99.3, 96.9, 99.7, 99.3, 98.8, 94.4]
27
]);
28
var AcceptedAvailability = anychart.data.set([
29
["Network", 99],
30
["ERP", 98],
31
["Data Warehouse", 98],
32
["Web Site", 98],
33
["Email", 98],
34
["HR", 96],
35
["Problem Tracking", 93]
36
]);
37
38
// content for first row
39
var contents = [["Last 12 Month", "System", "Availability %", null]];
40
41
42
// Table settings
43
44
// create table
45
var table = anychart.standalones.table();
46
47
table.top(title.getRemainingBounds().getTop());
48
49
for(var i= 0; i<7; i++){
50
contents.push([
51
newLine(i), // create line charts in the first column
52
AcceptedAvailability.row(i)[0], // get names for second column
53
newBullet(i), // create bullet charts for third column
54
AcceptedAvailability.row(i)[1] + "%" // get values for fourth column
55
]);
56
}
57
58
// set table content
59
table.contents(contents);
60
61
// disable borders and adjust width of second and fourth column
62
table.cellBorder("#B8B8B8");
63
table.getCol(1).width(130);
64
table.getCol(3).width(50);
65
table.getCell(0,2).colSpan(2).fontColor("#FFF").hAlign("right");
66
table.getRow(0)
67
.height(20)
68
.cellFill("#444444")
69
.fontColor("#FFF")
70
.cellBorder("#444444")
71
.border()
72
.bottom("2 #B8B8B8");
73
74
// visual settings for text in table
75
table.vAlign("middle").hAlign("center").fontWeight(600).fontSize(12);
76
77
// set table container and initiate draw
78
table.container(stage).draw();
79
80
81
// Settings for table content
82
83
// create new sparkline chart
84
function newLine(i){
85
var line = anychart.sparkline(Availability.mapAs({x: 0, value: [(i + 1)]}));
86
87
// adjust visualization
88
line
89
.stroke("2 #000")
90
.height("100%")
91
.xScale(
92
anychart.scales.dateTime()
93
.minimumGap(0)
94
.maximumGap(0)
95
.ticks([])
96
);
97
98
return line;
99
}
100
101
// create new bullet chart
102
function newBullet (i) {
103
var bulletData = 0;
104
for (var rowCounter = 0; rowCounter<(Availability.getRowsCount() - 1);rowCounter++){
105
bulletData += Availability.row(rowCounter)[i+1];
106
}
107
var bullet = anychart.bullet([{"value": bulletData/(Availability.getRowsCount() - 1), "type": "line", gap: 0.4}]);
108
bullet.range(0).from(AcceptedAvailability.row(i)[1]).to(100).fill("#ccc");
109
bullet.title().enabled(false);
110
bullet.axis().enabled(false);
111
bullet.background().enabled(true).stroke("#ccc").fill("#fff");
112
bullet.scale(anychart.scales.linear().minimum(85).maximum(100)).padding(0).margin(10);
113
return bullet;
114
}
115
116
// create legend
117
var legend = anychart.standalones.legend();
118
legend.itemsFormatter(function() {
119
var items = [
120
{
121
"index": 0,
122
"text": "Actual",
123
"iconType": function(path, size) {
124
path.clear();
125
var x = Math.round(size / 2);
126
var y = Math.round(size / 2);
127
var height = size * 0.6;
128
path.clear()
129
.moveTo(x, y - height / 2)
130
.lineTo(x, y + height / 2)
131
.lineTo(x + 2, y + height / 2)
132
.lineTo(x + 2, y - height / 2)
133
.close();
134
},
135
"iconStroke": "none",
136
"iconFill": "#000"
137
},
138
{
139
"index": 1,
140
"text": "Acceptable",
141
"iconType": function(path, size) {
142
path.clear();
143
var x = Math.round(size / 2);
144
var y = Math.round(size / 2);
145
var height = size * 0.8;
146
path.clear()
147
.moveTo(x - 2, y - height / 2)
148
.lineTo(x - 2, y + height / 2)
149
.lineTo(x + 3, y + height / 2)
150
.lineTo(x + 3, y - height / 2)
151
.close();
152
},
153
"iconStroke": "none",
154
"iconFill": "#ccc"
155
}
156
];
157
return items;
158
});
159
legend.title().enabled(false);
160
legend.titleSeparator().enabled(false);
161
legend.paginator().enabled(false);
162
legend.fontSize("10px").itemsLayout("horizontal").iconTextSpacing(0).align("right").position("center-bottom").padding(0).margin(0).itemsSpacing(0);
163
legend.parentBounds(anychart.math.rect(0, 15, stage.width(),15));
164
legend.background().enabled(false);
165
legend.container(stage).draw();
166
});