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