HTMLcopy
1
<div id="container"></div>
CSScopy
x
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
background: #1f2429;
7
}
8
9
#container {
10
width: 100%;
11
height: 100%;
12
margin: 0;
13
padding: 0;
14
}
JavaScriptcopy
125
1
anychart.onDocumentReady(function() {
2
3
// create a stage
4
var stage = anychart.graphics.create("container");
5
// create data
6
var data = [
7
{x: 0, value: 0, signal: 0, name: "WiFi hotspot", deviceType: "wifi", mac: 'BF-AD-3A-36-A4-BE'},
8
{index: 1, x: 0, value: 2, signal: -8, name: "iPhone X", deviceType: "phone", mac: 'D6-18-CD-D4-DE-D2'},
9
{index: 2, x: 90, value: 4, signal: -35, name: "Samsung s8", deviceType: "phone", mac: '03-ED-5C-E2-76-F4'},
10
{index: 3, x: 50, value: 4, signal: -47, name: "Oneplus3T", deviceType: "phone", mac: '49-5C-D8-54-5A-5B'},
11
{index: 4, x: 120, value: 8, signal: -72, name: "Nokia 6", deviceType: "phone", mac: 'C5-F4-29-05-67-0D'},
12
{index: 5, x: 170, value: 2, signal: -12, name: "Samsung Note9", deviceType: "phone", mac: '91-72-36-E5-C1-0C'},
13
{index: 6, x: 200, value: 4, signal: -37, name: "iPhone XS", deviceType: "phone", mac: 'F5-C3-0F-2B-C8-AE'},
14
{index: 7, x: 210, value: 2, signal: -20, name: "Dell XPS", deviceType: "laptop", mac: '44-99-CF-1E-61-CD'},
15
{index: 8, x: 300, value: 4, signal: -42, name: "Apple MBP", deviceType: "laptop", mac: '2A-76-AC-F0-52-89'},
16
{index: 9, x: 100, value: 2, signal: -25, name: "Lenovo Tab3", deviceType: "tablet", mac: '6B-CC-F8-E8-21-6C'}
17
];
18
19
//create chart
20
var polar = anychart.polar();
21
var dataSet = anychart.data.set(data);
22
//create series
23
var series = polar.marker(dataSet);
24
//adjust series appearance
25
series.type('circle');
26
series.normal().fill(placeImages);
27
series.normal().size(15).stroke(null);
28
series.hovered().size(17);
29
series.selected().size(17);
30
series.selected().fill(placeImages).stroke('#0f4b86', 3);
31
series.labels(true);
32
series.labels()
33
.anchor('center')
34
.offsetY(-2)
35
.fontSize(12)
36
.fontColor('white')
37
.format(function() {
38
return this.getData('index');
39
});
40
41
var gridPalette = [["#70e952 0.8", "#61da44 0.8"], ["#6cd053 0.8", "#39d811 0.8"], ["#46978d 0.8", "#05bda5 0.8"], ["#274553 0.8", "#01638f 0.8"], ["#28323c 0.8", "#596985 0.8"]];
42
43
//adjust scales and axes
44
polar.yGrid().palette(gridPalette);
45
polar.yGrid().stroke("black", 6);
46
polar.xGrid(false);
47
polar.xScale().maximum(360);
48
polar.yScale()
49
.maximum(9)
50
.minimum(0)
51
.ticks([0, 1, 3, 5, 7, 9]);
52
polar.xAxis(false);
53
polar.yAxis(false);
54
polar.yAxis().stroke(null);
55
polar.background("#1f2429");
56
57
//adjsut tooltip
58
polar.tooltip().format("Singnal strenthg: {%signal} dB\nMAC address: {%mac}");
59
polar.tooltip().titleFormat('{%name}');
60
61
polar.container(stage).draw();
62
63
//create and adjust standalone legend
64
var legend = anychart.standalones.legend();
65
var legendItems = [
66
{
67
text: 'Excellent',
68
iconType: "square",
69
iconFill: '#6cd053',
70
iconStroke: {color: 'black', thickness: 2}
71
},
72
{
73
text: 'Good',
74
iconType: "square",
75
iconFill: '#46978d',
76
iconStroke: {color: 'black', thickness: 2}
77
},
78
{
79
text: 'Average',
80
iconType: "square",
81
iconFill: '#274553',
82
iconStroke: {color: 'black', thickness: 2}
83
},
84
{
85
text: 'Poor',
86
iconType: "square",
87
iconFill: '#28323c',
88
iconStroke: {color: 'black', thickness: 2}
89
}
90
];
91
92
legend
93
.items(legendItems)
94
.itemsLayout('vertical')
95
.align('left')
96
.padding(5)
97
.container(stage).draw();
98
99
legend.listen("legendItemMouseOver", function(e){
100
// highlight area
101
polar.yGrid().palette().itemAt(e.itemIndex + 1, "White 0.7");
102
});
103
legend.listen("legendItemMouseOut", function(e){
104
// reset grid to default
105
polar.yGrid().palette(gridPalette);
106
});
107
108
function placeImages() {
109
var src;
110
if (this.getData("deviceType") === "phone")
111
src = "https://image.flaticon.com/icons/svg/65/65680.svg";
112
if (this.getData("deviceType") === "laptop")
113
src = "https://image.flaticon.com/icons/png/128/59/59505.png";
114
if (this.getData("deviceType") === "tablet")
115
src = "https://cdn2.iconfinder.com/data/icons/font-awesome/1792/tablet-128.png";
116
if (this.getData("deviceType") === "wifi")
117
src = "https://image.flaticon.com/icons/png/128/34/34143.png";
118
return {
119
src: src,
120
mode: 'fit',
121
opacity: 1
122
}
123
}
124
});
125