HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/bullet-chart/vertical-bullet-chart/data.js
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/bullet-chart/vertical-bullet-chart/data.json',
6
function (data) {
7
var dataSet = data;
8
9
var table = anychart.standalones.table();
10
table.hAlign('center');
11
12
table.contents([
13
[null],
14
[null],
15
[
16
null,
17
createBulletChart('A'),
18
createBulletChart('B1'),
19
createBulletChart('B2'),
20
createBulletChart('B3'),
21
createBulletChart('B5'),
22
createBulletChart('B6'),
23
createBulletChart('B7'),
24
createBulletChart('B9'),
25
createBulletChart('B12'),
26
createBulletChart('C'),
27
createBulletChart('D'),
28
createBulletChart('E'),
29
createBulletChart('K'),
30
null
31
],
32
[
33
null,
34
'A',
35
'B1',
36
'B2',
37
'B3',
38
'B5',
39
'B6',
40
'B7',
41
'B9',
42
'B12',
43
'C',
44
'D',
45
'E',
46
'K',
47
null
48
],
49
[null]
50
]);
51
table.getRow(0).height(20);
52
table.getRow(1).height(80).cellPadding(10, 0, 20, 0);
53
table.getRow(3).height(30);
54
table.getRow(2).cellPadding(10, 10, 10, 10);
55
table.getRow(4).height(20);
56
table
57
.getCell(1, 1)
58
.colSpan(13)
59
.useHtml(true)
60
.content(
61
'The Content of Vitamins of Corporate Dinners. ACME corp. <br/>' +
62
'<span style="color:#929292; font-size: 13px;">(Actual to Norm)</span>'
63
)
64
.fontSize(15)
65
.vAlign('bottom');
66
table.cellBorder(null);
67
68
table.container('container');
69
table.vAlign('middle');
70
table.draw();
71
72
function createBulletChart(name) {
73
var data = dataSet[name];
74
var target = data.norm;
75
var actual = data.actual;
76
var bullet = anychart.bullet([
77
{
78
value: actual,
79
type: 'bar',
80
gap: 0.7,
81
stroke: null
82
},
83
{
84
value: target,
85
type: 'line',
86
gap: 0.2,
87
stroke: { thickness: 2, color: '#545f69' }
88
}
89
]);
90
bullet
91
.background()
92
.enabled(true)
93
.fill('white')
94
.stroke('1 #e5e4e4');
95
bullet.padding(20, 0, 10, 0);
96
bullet.layout('vertical');
97
bullet.axis(null);
98
bullet.title(false);
99
100
return bullet;
101
}
102
}
103
);
104
});