HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 90%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
var chart = anychart.polar();
4
5
// add the lines to the chart
6
var series0 = chart.polyline(getData()[0]);
7
series0.color("#4d9ece");
8
var series1 = chart.polyline(getData()[1]);
9
series1.color("#ff9941");
10
var series2 = chart.polyline(getData()[2]);
11
series2.color("#0db341");
12
var series3 = chart.polyline(getData()[3]);
13
series3.color("#f35556");
14
var series4 = chart.polyline(getData()[4]);
15
series4.color("#ad6ac7");
16
var series5 = chart.polyline(getData()[5]);
17
series5.color("#16ccda");
18
var series6 = chart.polyline(getData()[6]);
19
series6.color("#f873c7");
20
21
// set the maximum value of the x-scale
22
chart.xScale()
23
.maximum(360)
24
.ticks([0,45,52,60,75,90,110,120,135,150,165]);
25
chart.yScale()
26
.minimum(0)
27
.ticks([0,2,4,6,8,10]);
28
29
30
// set the interactivity mode
31
chart.interactivity("by-x");
32
33
// format labels
34
chart.yAxis().labels()
35
.anchor('left-center')
36
.offsetY(-2)
37
.format('{%value}kts')
38
chart.xAxis().labels().format('{%value}°')
39
chart.xAxis().ticks().length(0);
40
41
// customize grids
42
chart.xGrid().stroke({
43
dash: "1 5"
44
});
45
chart.yGrid().stroke({
46
dash: "1 5"
47
});
48
49
chart.tooltip().titleFormat('{%x}°');
50
51
// set the container id
52
chart.container("container");
53
relocateChart(chart);
54
chart.draw();
55
56
chart.listen('chartDraw', function(){
57
relocateChart(chart);
58
});
59
});
60
61
function relocateChart(chart) {
62
chart.left(-chart.container().getBounds().width+30);
63
}
64
65
function getData() {
66
return [[
67
{x: 52, value: 5.5},
68
{x: 60, value: 5.9},
69
{x: 75, value: 6.24},
70
{x: 90, value: 6.24},
71
{x: 110, value: 6.28},
72
{x: 120, value: 6.08},
73
{x: 135, value: 5.36},
74
{x: 150, value: 4.5},
75
{x: 160, value: null},
76
],
77
[
78
{x: 52, value: 6.6},
79
{x: 60, value: 6.85},
80
{x: 75, value: 7.02},
81
{x: 90, value: 7.06},
82
{x: 110, value: 7.21},
83
{x: 120, value: 7.1},
84
{x: 135, value: 6.65},
85
{x: 150, value: 5.66},
86
{x: 160, value: null},
87
],
88
[
89
{x: 52, value: 6.98},
90
{x: 60, value: 7.19},
91
{x: 75, value: 7.42},
92
{x: 90, value: 7.47},
93
{x: 110, value: 7.71},
94
{x: 120, value: 7.71},
95
{x: 135, value: 7.31},
96
{x: 150, value: 6.65},
97
{x: 160, value: null},
98
],
99
[
100
{x: 52, value: 7.12},
101
{x: 60, value: 7.34},
102
{x: 75, value: 7.74},
103
{x: 90, value: 7.95},
104
{x: 110, value: 8.08},
105
{x: 120, value: 8.36},
106
{x: 135, value: 7.91},
107
{x: 150, value: 7.25},
108
{x: 160, value: null},
109
],
110
[
111
{x: 52, value: 7.2},
112
{x: 60, value: 7.44},
113
{x: 75, value: 7.94},
114
{x: 90, value: 8.42},
115
{x: 110, value: 8.48},
116
{x: 120, value: 8.82},
117
{x: 135, value: 8.7},
118
{x: 170, value: 7},
119
{x: 175, value: null},
120
],
121
[
122
{x: 52, value: 7.3},
123
{x: 60, value: 7.53},
124
{x: 75, value: 8.07},
125
{x: 90, value: 8.72},
126
{x: 110, value: 8.87},
127
{x: 120, value: 9.27},
128
{x: 135, value: 9.71},
129
{x: 150, value: 8.34},
130
{x: 160, value: null},
131
],
132
[
133
{x: 52, value: 7.41},
134
{x: 60, value: 7.73},
135
{x: 75, value: 8.35},
136
{x: 90, value: 8.99},
137
{x: 110, value: 9.89},
138
{x: 120, value: 10.22},
139
{x: 135, value: 11.4},
140
{x: 150, value: 10.43},
141
{x: 160, value: null},
142
]];
143
}