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
x
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, 95.5],
16
[Date.UTC(2013, 11), 98.5, 98.9, 95.9, 98.4, 98.4, 97.9],
17
[Date.UTC(2014, 0), 98.5, 98.8, 96.7, 98.5, 99.1, 98.2],
18
[Date.UTC(2014, 1), 99.0, 98.3, 95.6, 98.8, 98.2, 98.9],
19
[Date.UTC(2014, 2), 99.2, 98.6, 96.8, 99.0, 98.2, 98.2],
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
console.log(anychart.scales.dateTime());
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("middle").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
console.log("AnyChart SPARK: " + JSON.stringify(line.toJson()));
76
// adjust visualization
77
line
78
.stroke("2 #000")
79
.height("100%")
80
//.xScale(anychart.scales.dateTime()
81
//.minimumGap(0)
82
//.maximumGap(0)
83
//.ticks([])
84
//)
85
;
86
console.log(JSON.stringify(line.toJson()));
87
88
return line;
89
}
90
91
// create new bullet chart
92
function newBullet (i) {
93
var bulletData = 0;
94
for (var rowCounter = 0; rowCounter<(Availability.getRowsCount() - 1);rowCounter++){
95
bulletData += Availability.row(rowCounter)[i+1];
96
}
97
var bullet = anychart.bullet([{"value": bulletData/(Availability.getRowsCount() - 1), "type": "line", gap: 0.4}]);
98
bullet.range(0).from(AcceptedAvailability.row(i)[1]).to(100).fill("#ccc");
99
bullet.title().enabled(false);
100
bullet.axis().enabled(false);
101
bullet.background().enabled(true).stroke("#ccc").fill("#fff");
102
bullet.scale(anychart.scales.linear().minimum(85).maximum(100)).padding(0).margin(10);
103
return bullet;
104
}
105
106
107
// create legend
108
var legend = anychart.standalones.legend();
109
legend.itemsFormatter(function() {
110
var items = [
111
{
112
"index": 0,
113
"text": "Actual",
114
"iconType": function(path, size) {
115
path.clear();
116
var x = Math.round(size / 2);
117
var y = Math.round(size / 2);
118
var height = size * 0.6;
119
path.clear()
120
.moveTo(x, y - height / 2)
121
.lineTo(x, y + height / 2)
122
.lineTo(x + 2, y + height / 2)
123
.lineTo(x + 2, y - height / 2)
124
.close();
125
},
126
"iconStroke": "none",
127
"iconFill": "#000"
128
},
129
{
130
"index": 1,
131
"text": "Acceptable",
132
"iconType": function(path, size) {
133
path.clear();
134
var x = Math.round(size / 2);
135
var y = Math.round(size / 2);
136
var height = size * 0.8;
137
path.clear()
138
.moveTo(x - 2, y - height / 2)
139
.lineTo(x - 2, y + height / 2)
140
.lineTo(x + 3, y + height / 2)
141
.lineTo(x + 3, y - height / 2)
142
.close();
143
},
144
"iconStroke": "none",
145
"iconFill": "#ccc"
146
}
147
];
148
return items;
149
});
150
legend.title().enabled(false);
151
legend.titleSeparator().enabled(false);
152
legend.paginator().enabled(false);
153
legend.fontSize("10px").itemsLayout("horizontal").iconTextSpacing(0).align("right").position("center-bottom").padding(0).margin(0).itemsSpacing(0);
154
legend.parentBounds(anychart.math.rect(0, 15, stage.width(),15));
155
legend.background().enabled(false);
156
legend.container(stage).draw();
157
});