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
156
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
var contents = [];
38
39
// Table settings
40
41
// create table
42
var table = anychart.standalones.table();
43
44
table.top(title.getRemainingBounds().getTop());
45
46
for(var i= 0; i<7; i++){
47
contents.push([
48
newLine(i), // create line charts in the first column
49
AcceptedAvailability.row(i)[0], // get names for second column
50
newBullet(i), // create bullet charts for third column
51
AcceptedAvailability.row(i)[1] + "%" // get values for fourth column
52
]);
53
}
54
55
// set table content
56
table.contents(contents);
57
58
// disable borders and adjust width of second and fourth column
59
table.cellBorder("#B8B8B8");
60
table.getCol(1).width(130);
61
table.getCol(3).width(50);
62
63
// visual settings for text in table
64
table.vAlign("center").hAlign("center").fontWeight(600).fontSize(12);
65
66
// set table container and initiate draw
67
table.container(stage).draw();
68
69
70
// Settings for table content
71
72
// create new sparkline chart
73
function newLine(i){
74
var line = anychart.sparkline(Availability.mapAs({x: [0], value: [(i + 1)]}));
75
76
// adjust visualization
77
line
78
.stroke("2 #000")
79
.height("100%")
80
.xScale(
81
anychart.scales.dateTime()
82
.minimumGap(0)
83
.maximumGap(0)
84
.ticks([])
85
);
86
87
return line;
88
}
89
90
// create new bullet chart
91
function newBullet (i) {
92
var bulletData = 0;
93
for (var rowCounter = 0; rowCounter<(Availability.getRowsCount() - 1);rowCounter++){
94
bulletData += Availability.row(rowCounter)[i+1];
95
}
96
var bullet = anychart.bullet([{"value": bulletData/(Availability.getRowsCount() - 1), "type": "line", gap: 0.4}]);
97
bullet.range(0).from(AcceptedAvailability.row(i)[1]).to(100).fill("#ccc");
98
bullet.title().enabled(false);
99
bullet.axis().enabled(false);
100
bullet.background().enabled(true).stroke("#ccc").fill("#fff");
101
bullet.scale(anychart.scales.linear().minimum(85).maximum(100)).padding(0).margin(10);
102
return bullet;
103
}
104
105
106
// create legend
107
var legend = anychart.standalones.legend();
108
legend.itemsFormatter(function(){
109
var items = [
110
{
111
"index": 0,
112
"text": "Actual",
113
"iconType": function(path, size) {
114
path.clear();
115
var x = Math.round(size / 2);
116
var y = Math.round(size / 2);
117
var height = size * 0.6;
118
path.clear()
119
.moveTo(x, y - height / 2)
120
.lineTo(x, y + height / 2)
121
.lineTo(x + 2, y + height / 2)
122
.lineTo(x + 2, y - height / 2)
123
.close();
124
},
125
"iconStroke": "none",
126
"iconFill": "#000"
127
},
128
{
129
"index": 1,
130
"text": "Acceptable",
131
"iconType": function(path, size) {
132
path.clear();
133
var x = Math.round(size / 2);
134
var y = Math.round(size / 2);
135
var height = size * 0.8;
136
path.clear()
137
.moveTo(x - 2, y - height / 2)
138
.lineTo(x - 2, y + height / 2)
139
.lineTo(x + 3, y + height / 2)
140
.lineTo(x + 3, y - height / 2)
141
.close();
142
},
143
"iconStroke": "none",
144
"iconFill": "#ccc"
145
}
146
];
147
return items;
148
});
149
legend.title().enabled(false);
150
legend.titleSeparator().enabled(false);
151
legend.paginator().enabled(false);
152
legend.fontSize("10px").itemsLayout("horizontal").iconTextSpacing(0).align("right").position("bottom").padding(0).margin(0).itemsSpacing(0);
153
legend.parentBounds(anychart.math.rect(0, 15, stage.width(),15));
154
legend.background().enabled(false);
155
legend.container(stage).draw();
156
});