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