HTMLcopy
x
1
<table class="table-container" width="100%">
2
<tr>
3
<td>
4
<div class="toolbar">
5
<div class="btn-group">
6
<button type="button" class="btn btn-default color-picker" data-color="fill" data-toggle="tooltip"
7
title="Сhoose drawing fill color"><span
8
class="color-fill-icon dropdown-color-fill-icon"></span> <b
9
class="caret"></b>
10
</button>
11
12
<button type="button" class="btn btn-default color-picker" data-color="stroke" data-toggle="tooltip"
13
title="Сhoose drawing stroke color"><span
14
class="color-fill-icon dropdown-color-fill-icon"></span> <b
15
class="caret"></b>
16
</button>
17
18
<select class="selectpicker" id="select-stroke-settings"
19
title="Stroke settings"
20
data-style="btn-lg" data-width="121" multiple>
21
<optgroup label="Stroke width" data-max-options="1">
22
<option data-settings="width" value="0">0 px</option>
23
<option data-settings="width" value="1" selected>1 px</option>
24
<option data-settings="width" value="2">2 px</option>
25
<option data-settings="width" value="3">3 px</option>
26
<option data-settings="width" value="4">4 px</option>
27
<option data-settings="width" value="5">5 px</option>
28
</optgroup>
29
<optgroup label="Stroke dash" data-max-options="1">
30
<option value="6" data-settings="type" selected>solid</option>
31
<option value="7" data-settings="type">dotted</option>
32
<option value="8" data-settings="type">dashed</option>
33
</optgroup>
34
</select>
35
</div>
36
<div class="btn-group">
37
<button type="button" data-action-type="unSelectedAnnotation" class="btn btn-default"
38
aria-label="Center Align" data-toggle="tooltip" title="Cursor">
39
<i class="ac ac-mouse-pointer" aria-hidden="true"></i>
40
</button>
41
</div>
42
43
<div class="select-container">
44
<select class="selectpicker choose-drawing-tools"
45
title="Drawing tools"
46
data-style="btn-lg" data-width="133" data-max-options="1">
47
<optgroup label="Lines, Trend lines and Rays:">
48
<option data-icon="ac-line" data-annotation-type="line">Line Segment</option>
49
<option data-icon="ac-horizontal-line" data-annotation-type="horizontal-line">Horizontal
50
Line
51
</option>
52
<option data-icon="ac-vertical-line" data-annotation-type="vertical-line">Vertical Line
53
</option>
54
<option data-icon="ac-infinite-line" data-annotation-type="infinite-line">Infinite Line
55
</option>
56
<option data-icon="ac-ray" data-annotation-type="ray">Ray</option>
57
</optgroup>
58
<optgroup label="Geometric shapes:">
59
<option data-icon="ac-triangle" data-annotation-type="triangle">Triangle</option>
60
<option data-icon="ac-rectangle" data-annotation-type="rectangle">Rectangle</option>
61
<option data-icon="ac-ellipse" data-annotation-type="ellipse">Ellipse</option>
62
</optgroup>
63
<optgroup label="Other tools:">
64
<option data-icon="ac-trend-channel" data-annotation-type="trend-channel">Trend Channel
65
</option>
66
<option data-icon="ac-andrews-pitchfork" data-annotation-type="andrews-pitchfork">
67
Andrew's
68
Pitchfork
69
</option>
70
</optgroup>
71
<optgroup label="Fibonacci tools:">
72
<option data-icon="ac-fibonacci-fan" data-annotation-type="fibonacci-fan">Fibonacci Fan
73
</option>
74
<option data-icon="ac-fibonacci-arc" data-annotation-type="fibonacci-arc">Fibonacci Arc
75
</option>
76
<option data-icon="ac-fibonacci-retracement"
77
data-annotation-type="fibonacci-retracement">Fibonacci
78
Retracement
79
</option>
80
<option data-icon="ac-fibonacci-timezones" data-annotation-type="fibonacci-timezones">
81
Fibonacci Time
82
Zones
83
</option>
84
</optgroup>
85
</select>
86
</div>
87
88
<div class="btn-group hidden-xs">
89
<button data-annotation-type="line" type="button" class="btn btn-default" aria-label="Center Align"
90
data-toggle="tooltip" title="Line Segment">
91
<i class="ac ac-line" aria-hidden="true"></i>
92
</button>
93
<button data-annotation-type="horizontal-line" type="button" class="btn btn-default"
94
aria-label="Center Align" data-toggle="tooltip" title="Horizontal Line">
95
<i class="ac ac-horizontal-line" aria-hidden="true"></i>
96
</button>
97
<button data-annotation-type="vertical-line" type="button" class="btn btn-default"
98
aria-label="Center Align" data-toggle="tooltip" title="Vertical Line">
99
<i class="ac ac-vertical-line" aria-hidden="true"></i>
100
</button>
101
<button data-annotation-type="infinite-line" type="button" class="btn btn-default"
102
aria-label="Center Align" data-toggle="tooltip" title="Infinite Line">
103
<i class="ac ac-infinite-line" aria-hidden="true"></i>
104
</button>
105
<button data-annotation-type="ray" type="button" class="btn btn-default"
106
aria-label="Center Align" data-toggle="tooltip" title="Ray">
107
<i class="ac ac-ray" aria-hidden="true"></i>
108
</button>
109
</div>
110
111
<div class="btn-group hidden-xs">
112
<button data-annotation-type="triangle" type="button" class="btn btn-default"
113
aria-label="Center Align" data-toggle="tooltip" title="Triangle">
114
<i class="ac ac-triangle" aria-hidden="true"></i>
115
</button>
116
<button data-annotation-type="rectangle" type="button" class="btn btn-default"
117
aria-label="Center Align" data-toggle="tooltip" title="Rectangle">
118
<i class="ac ac-rectangle" aria-hidden="true"></i>
119
</button>
120
<button data-annotation-type="ellipse" type="button" class="btn btn-default"
121
aria-label="Center Align" data-toggle="tooltip" title="Ellipse">
122
<i class="ac ac-ellipse" aria-hidden="true"></i>
123
</button>
124
</div>
125
126
<div class="btn-group hidden-xs">
127
<button data-annotation-type="trend-channel" type="button" class="btn btn-default"
128
aria-label="Center Align" data-toggle="tooltip" title="Trend Channel">
129
<i class="ac ac-trend-channel" aria-hidden="true"></i>
130
</button>
131
<button data-annotation-type="andrews-pitchfork" type="button" class="btn btn-default"
132
aria-label="Center Align" data-toggle="tooltip" title="Andrew's Pitchfork">
133
<i class="ac ac-andrews-pitchfork" aria-hidden="true"></i>
134
</button>
135
</div>
136
137
<div class="btn-group hidden-xs">
138
<button data-annotation-type="fibonacci-fan" type="button" class="btn btn-default"
139
aria-label="Center Align" data-toggle="tooltip" title="Fibonacci Fan">
140
<i class="ac ac-fibonacci-fan" aria-hidden="true"></i>
141
</button>
142
<button data-annotation-type="fibonacci-arc" type="button" class="btn btn-default"
143
aria-label="Center Align" data-toggle="tooltip" title="Fibonacci Arc">
144
<i class="ac ac-fibonacci-arc" aria-hidden="true"></i>
145
</button>
146
<button data-annotation-type="fibonacci-retracement" type="button" class="btn btn-default"
147
aria-label="Center Align" data-toggle="tooltip" title="Fibonacci Retracement">
148
<i class="ac ac-fibonacci-retracement" aria-hidden="true"></i>
149
</button>
150
<button data-annotation-type="fibonacci-timezones" type="button" class="btn btn-default"
151
aria-label="Center Align" data-toggle="tooltip" title="Fibonacci Time Zones">
152
<i class="ac ac-fibonacci-timezones" aria-hidden="true"></i>
153
</button>
154
155
</div>
156
157
<div class="btn-group-container">
158
<div class="btn-group">
159
160
<select class="selectpicker select choose-marker" id="select-marker-type"
161
title="Marker"
162
data-style="btn-lg" data-width="90" data-max-options="1">
163
<option data-icon="ac-arrow-up-square" data-annotation-type="marker"
164
data-marker-type="arrowUp"
165
data-marker-anchor="center-top">Up Arrow
166
</option>
167
<option data-icon="ac-arrow-down-square" data-annotation-type="marker"
168
data-marker-type="arrow-down" data-marker-anchor="center-bottom">Down Arrow
169
</option>
170
<option data-icon="ac-arrow-left-square" data-annotation-type="marker"
171
data-marker-type="arrow-left" data-marker-anchor="left-center">Left Arrow
172
</option>
173
<option data-icon="ac-arrow-right-square" data-annotation-type="marker"
174
data-marker-type="arrow-right" data-marker-anchor="right-center">Right Arrow
175
</option>
176
<option data-icon="ac-head-arrow" data-annotation-type="marker"
177
data-marker-type="arrowHead"
178
data-marker-anchor="right-center">Head Arrow
179
</option>
180
<option data-icon="ac-cross" data-annotation-type="marker" data-marker-type="cross"
181
data-marker-anchor="center">Cross
182
</option>
183
<option data-icon="ac-diagonal-cros" data-annotation-type="marker"
184
data-marker-type="diagonal-cross"
185
data-marker-anchor="center">Diagonal cross
186
</option>
187
<option data-icon="ac-diamond" data-annotation-type="marker" data-marker-type="diamond"
188
data-marker-anchor="center">Diamond
189
</option>
190
<option data-icon="ac-pentagon" data-annotation-type="marker" data-marker-type="pentagon"
191
data-marker-anchor="center">Pentagon
192
</option>
193
<option data-icon="ac-square" data-annotation-type="marker" data-marker-type="square"
194
data-marker-anchor="center">Square
195
</option>
196
<option data-icon="ac-star-1" data-annotation-type="marker" data-marker-type="star10"
197
data-marker-anchor="center">Star 1
198
</option>
199
<option data-icon="ac-star-2" data-annotation-type="marker" data-marker-type="star4"
200
data-marker-anchor="center">Star 2
201
</option>
202
<option data-icon="ac-star-3" data-annotation-type="marker" data-marker-type="star5"
203
data-marker-anchor="center">Star 3
204
</option>
205
<option data-icon="ac-star-4" data-annotation-type="marker" data-marker-type="star6"
206
data-marker-anchor="center">Star 4
207
</option>
208
<option data-icon="ac-star-5" data-annotation-type="marker" data-marker-type="star7"
209
data-marker-anchor="center">Star 5
210
</option>
211
<option data-icon="ac-trapezium" data-annotation-type="marker"
212
data-marker-type="trapezium"
213
data-marker-anchor="center">Trapezium
214
</option>
215
<option data-icon="ac-triangle-up" data-annotation-type="marker"
216
data-marker-type="triangle-up"
217
data-marker-anchor="center-top">Triangle Up
218
</option>
219
<option data-icon="ac-triangle-down" data-annotation-type="marker"
220
data-marker-type="triangle-down"
221
data-marker-anchor="center-bottom">Triangle Down
222
</option>
223
<option data-icon="ac-triangle-left" data-annotation-type="marker"
224
data-marker-type="triangle-left"
225
data-marker-anchor="left-center">Triangle Left
226
</option>
227
<option data-icon="ac-triangle-right" data-annotation-type="marker"
228
data-marker-type="triangle-right"
229
data-marker-anchor="right-center">Triangle Right
230
</option>
231
</select>
232
233
<button type="button" class="btn btn-default volume-btn" data-el-size="marker" data-volume="20"
234
data-toggle="popover">Marker size
235
</button>
236
237
</div>
238
</div>
239
<div class="btn-group-container">
240
<div class="btn-group">
241
<button data-annotation-type="label" type="button" class="btn btn-default"
242
aria-label="Center Align"
243
data-toggle="tooltip" title="Label">
244
<i class="ac ac-font"></i>
245
</button>
246
247
<button type="button" class="btn btn-default" id="annotation-label-autosize"
248
aria-label="Auto-resize" data-toggle="tooltip" title="Auto-resize">
249
<i class="ac ac-enlarge" aria-hidden="true"></i>
250
</button>
251
252
<button type="button" class="btn btn-default color-picker" data-color="fontColor"
253
data-toggle="tooltip"
254
title="Сhoose font color"><span
255
class="color-fill-icon dropdown-color-fill-icon" data-color="black"></span> <b
256
class="caret"></b>
257
</button>
258
259
<button type="button" class="btn btn-default volume-btn" data-el-size="label" data-volume="15"
260
data-toggle="popover">Font size
261
</button>
262
263
<select class="selectpicker" id="select-font-style"
264
title="Font settings"
265
data-style="btn-lg" data-width="121" multiple>
266
<optgroup label="Font style" data-max-options="2">
267
<option data-icon="ac-italic" data-label-method="fontStyle" value="italic">Italic
268
</option>
269
<option data-icon="ac-bold" data-label-method="fontWeight" value="bold">Bold</option>
270
</optgroup>
271
<optgroup label="Font decoration" data-max-options="1" data-label-method="fontDecoration">
272
<option data-icon="ac-strikethrough" value="line-through">Line-through</option>
273
<option data-icon="ac-overline" value="overline">Overline</option>
274
<option data-icon="ac-underline" value="underline">Underline</option>
275
</optgroup>
276
<optgroup label="Horizontal align" data-max-options="1" data-label-method="hAlign">
277
<option data-icon="ac-align-center" value="center">Center</option>
278
<option data-icon="ac-align-left" value="left">Left</option>
279
<option data-icon="ac-align-right" value="right">Right</option>
280
<option data-icon="ac-position-left" value="start">Start</option>
281
<option data-icon="ac-position-right" value="end">End</option>
282
</optgroup>
283
<optgroup label="Anchor" data-max-options="1" data-label-method="anchor">
284
<option data-icon="ac-anc-cb" value="center-bottom">Center bottom</option>
285
<option data-icon="ac-anc-ct" value="center-top">Center top</option>
286
<option data-icon="ac-anc-lb" value="left-bottom">Left bottom</option>
287
<option data-icon="ac-anc-lc" value="left-center">Left center</option>
288
<option data-icon="ac-anc-lt" value="left-top">Left top</option>
289
<option data-icon="ac-anc-rb" value="right-bottom">Right bottom</option>
290
<option data-icon="ac-anc-rc" value="right-center">Right center</option>
291
<option data-icon="ac-anc-rt" value="right-top">Right top</option>
292
<option data-icon="ac-anc-c" value="center">Center</option>
293
</optgroup>
294
<optgroup label="Vertical align" data-max-options="1" data-label-method="vAlign">
295
<option data-icon="ac-position-top" value="top">Top</option>
296
<option data-icon="ac-position-center2" value="middle">Middle</option>
297
<option data-icon="ac-position-bottom" value="bottom">Bottom</option>
298
</optgroup>
299
</select>
300
301
</div>
302
</div>
303
<div class="btn-group-container">
304
<div class="btn-group">
305
<button data-action-type="removeSelectedAnnotation" type="button" class="btn btn-default"
306
aria-label="Center Align" data-toggle="tooltip" title="Delete selected drawing">
307
<i class="ac ac-remove-thin" aria-hidden="true"></i>
308
</button>
309
<button data-action-type="removeAllAnnotations" type="button" class="btn btn-default"
310
aria-label="Center Align" data-toggle="tooltip" title="Delete all drawings">Remove All
311
</button>
312
313
<select name="" id="seriesTypeSelect" class="select show-tick">
314
<!--series constructors-->
315
<option value="area">Area Chart</option>
316
<option value="candlestick">Candlestick Chart</option>
317
<option value="column">Column Chart</option>
318
<option value="jumpLine">Jump Line Chart</option>
319
<option value="line" selected>Line Chart</option>
320
<option value="marker">Marker Chart</option>
321
<option value="ohlc">OHLC Chart</option>
322
<option value="rangeArea">Range Area Chart</option>
323
<option value="rangeColumn">Range Column Chart</option>
324
<option value="rangeSplineArea">Range Spline Area Chart</option>
325
<option value="rangeStepArea">Range Step Area Chart</option>
326
<option value="spline">Spline Chart</option>
327
<option value="splineArea">Spline Area Chart</option>
328
<option value="stepArea">Step Area Chart</option>
329
<option value="stepLine">Step Line Chart</option>
330
<option value="stick">Stick Chart</option>
331
<!---->
332
</select>
333
334
</div>
335
</div>
336
</div>
337
</td>
338
</tr>
339
<tr>
340
<td class="chart-column">
341
<div id="chart-container" style="height: 350px;"></div>
342
</td>
343
</tr>
344
</table>
CSScopy
331
1
body {
2
padding: 10px 15px;
3
}
4
5
html, body {
6
height: 100%;
7
}
8
9
.color-fill-icon {
10
display: inline-block;
11
width: 16px;
12
height: 16px;
13
border: 1px solid #000;
14
background-color: #fff;
15
margin: 2px;
16
}
17
18
.colorpickerplus-custom-colors,
19
.colorpickerplus .input-group {
20
display: none;
21
}
22
23
.dropdown-color-fill-icon {
24
position: relative;
25
float: left;
26
margin-left: 0;
27
margin-right: 0
28
}
29
30
.title-drawing-tools {
31
display: none;
32
}
33
34
.text-drawing-tools {
35
display: none;
36
max-width: 1080px;
37
margin-bottom: 20px;
38
}
39
40
#chart-container {
41
height: 100%;
42
}
43
44
#annotation-label {
45
border: 0;
46
clip: rect(0 0 0 0);
47
height: 1px;
48
margin: -1px;
49
overflow: hidden;
50
padding: 0;
51
position: absolute;
52
width: 1px;
53
}
54
55
.table-container {
56
padding: 0;
57
width: 100%;
58
height: 100%;
59
}
60
61
.table-container td {
62
vertical-align: top;
63
}
64
65
.chart-column {
66
height: 100%;
67
}
68
69
.no-iframe #chart-container {
70
width: 99%;
71
}
72
73
.container-drawing-tools #chart-container {
74
margin-top: 0;
75
}
76
77
.drawing-tools-solo.container {
78
margin-top: 25px;
79
}
80
81
.container-drawing-tools .drawing-tools-solo {
82
margin: 0;
83
}
84
85
* {
86
outline: none !important;
87
}
88
89
.select > .btn {
90
font-weight: 400;
91
border-color: #c5c8d1;
92
background: #fff;
93
}
94
95
.bootstrap-select > .btn {
96
width: 100%;
97
padding-right: 25px;
98
}
99
100
.error .bootstrap-select .btn {
101
border: 1px solid #b94a48;
102
}
103
104
.control-group.error .bootstrap-select .dropdown-toggle {
105
border-color: #b94a48;
106
}
107
108
.bootstrap-select.fit-width {
109
width: auto !important;
110
}
111
112
.bootstrap-select.form-control {
113
margin-bottom: 0;
114
padding: 0;
115
}
116
117
.bootstrap-select .dropdown-toggle {
118
height: 34px;
119
padding: 8px 16px;
120
font-weight: 400;
121
border-color: #c5c8d1;
122
background: #fff;
123
}
124
125
.filter-option {
126
font-size: 14px;
127
float: left;
128
}
129
130
.btn-group-container {
131
display: inline-block;
132
}
133
134
.toolbar > .select-container {
135
display: inline-block;
136
}
137
138
.select .ac {
139
margin-right: 5px;
140
top: -1px;
141
}
142
143
.bootstrap-select .dropdown-toggle:focus {
144
outline: none !important;
145
outline-offset: 0 !important;
146
}
147
148
.btn-group-vertical > .btn,
149
.btn-group > .btn {
150
margin-left: -1px;
151
}
152
153
.bootstrap-select.btn-group:not(.input-group-btn),
154
.bootstrap-select.btn-group[class*=col-] {
155
margin-left: -1px;
156
}
157
158
.btn-group .select.select-marker-size {
159
margin-left: -5px !important;
160
}
161
162
.btn-group .select {
163
margin-left: -1px !important;
164
}
165
166
.select-marker-size[disabled="disabled"] > .btn:first-child {
167
opacity: 0.75;
168
cursor: not-allowed;
169
}
170
171
.select-marker-size[disabled="disabled"] .btn.active,
172
.select-marker-size[disabled="disabled"] .btn:active {
173
-webkit-box-shadow: none;
174
box-shadow: none;
175
}
176
177
.choose-drawing-tools.bootstrap-select.btn-group ul.dropdown-menu {
178
margin-right: 10px;
179
}
180
181
.choose-marker.bootstrap-select.btn-group ul.dropdown-menu {
182
margin-right: 10px;
183
}
184
185
.bootstrap-select.btn-group .dropdown-toggle .filter-option {
186
text-overflow: ellipsis;
187
}
188
189
.btn-group .btn {
190
margin-bottom: 5px;
191
}
192
193
.btn-group .volume-btn {
194
display: inline-block;
195
float: none;
196
}
197
198
.btn-group {
199
font-size: 0;
200
}
201
202
.ac.glyphicon {
203
font-family: 'Glyphicons Halflings' !important;
204
}
205
206
button.dropdown-toggle {
207
padding-left: 13px !important;
208
padding-right: 25px !important;
209
}
210
211
.filter-option .ac,
212
.dropdown-menu .ac {
213
font-size: 14px;
214
}
215
216
/*Loader------------------------------------------------------------------------------------------------------------------------------------*/
217
.anychart-loader {
218
position: absolute;
219
top: 0;
220
left: 0;
221
width: 100%;
222
height: 100%;
223
z-index: 1000;
224
background: #fff;
225
}
226
227
.anychart-loader .rotating-cover {
228
width: 70px;
229
height: 70px;
230
position: absolute;
231
top: 50%;
232
margin-top: -35px;
233
left: 50%;
234
margin-left: -35px;
235
}
236
237
.anychart-loader .rotating-plane {
238
display: block;
239
width: 100%;
240
height: 100%;
241
border-radius: 20%;
242
border: 5px solid #1c75ba;
243
margin: 0 auto;
244
position: relative;
245
-webkit-animation: rotateplane 3s infinite;
246
animation: rotateplane 3s infinite;
247
}
248
249
.anychart-loader .chart-row {
250
position: absolute;
251
top: 10px;
252
bottom: 0;
253
left: 10px;
254
right: 10px;
255
letter-spacing: -3px;
256
line-height: 0;
257
font-size: 0;
258
white-space: nowrap;
259
}
260
261
.anychart-loader .chart-row .chart-col {
262
display: inline-block;
263
width: 25%;
264
height: 90%;
265
background: #000;
266
margin: 0 12.5% 0 0;
267
vertical-align: bottom;
268
}
269
270
.anychart-loader .chart-row .chart-col.green {
271
background: #26a957;
272
height: 50%;
273
-webkit-animation: blinkplane 1.5s infinite;
274
animation: blinkplane 1.5s infinite;
275
}
276
277
.anychart-loader .chart-row .chart-col.orange {
278
background: #ff8207;
279
height: 70%;
280
-webkit-animation: blinkplane 1.5s infinite 0.15s;
281
animation: blinkplane 1.5s infinite 0.25s;
282
283
}
284
285
.anychart-loader .chart-row .chart-col.red {
286
background: #f0402e;
287
height: 90%;
288
-webkit-animation: blinkplane 1.5s infinite 0.3s;
289
animation: blinkplane 1.5s infinite 0.5s;
290
}
291
292
@keyframes rotateplane {
293
0% {
294
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
295
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
296
opacity: 1;
297
}
298
25% {
299
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
300
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
301
opacity: 0.3;
302
}
303
50% {
304
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
305
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
306
opacity: 1;
307
}
308
75% {
309
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(-180.1deg);
310
transform: perspective(120px) rotateX(0deg) rotateY(-180.1deg);
311
opacity: 0.3;
312
}
313
100% {
314
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
315
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
316
opacity: 1;
317
}
318
}
319
320
@keyframes blinkplane {
321
0% {
322
opacity: 1;
323
}
324
50% {
325
opacity: 0.01;
326
}
327
100% {
328
opacity: 1;
329
}
330
}
331
JavaScriptcopy
717
1
(function () {
2
initTooltip('bottom');
3
4
var chart;
5
var $strokeSettings = $('#select-stroke-settings');
6
var $colorPickerFill = $('.color-picker[data-color="fill"]');
7
var $colorPickerStroke = $('.color-picker[data-color="stroke"]');
8
var $annotationLabel;
9
// var $markerSize = $('#select-marker-size');
10
var $markerSize = $('.volume-btn[data-el-size="marker"]');
11
var $fontSize = $('.volume-btn[data-el-size="label"]');
12
var $markerSizeBtn = $('.select-marker-size');
13
var $fontSettings = $('#select-font-style');
14
15
var $labelMethod = $('[data-label-method]');
16
17
$(function () {
18
// page UI elements
19
createPageColorPicker();
20
21
// init selectpicker
22
$('.selectpicker').selectpicker({
23
iconBase: 'ac',
24
tickIcon: 'ac-check'
25
});
26
27
// init volume bars
28
// marker-size, font-size
29
initVolumeBar();
30
31
// data from https://cdn.anychart.com/csv-data/msft-daily-short.js
32
var data = get_msft_daily_short_data();
33
34
// Create new chart object.
35
chart = anychart.stock();
36
37
// create data table
38
var table = anychart.data.table(0);
39
table.addData(data);
40
41
// create data mappings
42
var mapping = table.mapAs({'value': 4});
43
44
// create line series
45
chart.plot(0).line(mapping)
46
.stroke('2 #253992')
47
.name('MSFT');
48
49
// create ema indicator
50
chart.plot(0).ema(mapping, 50, 'spline')
51
.series()
52
.stroke('#DB2A0E');
53
54
// create scroller series
55
chart.scroller().area(mapping)
56
.color('#253992 0.3')
57
.stroke('#253992');
58
59
// set grid and axis settings
60
chart.plot(0).yAxis(0).orientation('right');
61
chart.plot(0).yAxis(1)
62
.orientation('left')
63
.ticks(false)
64
.labels(false)
65
.minorLabels(false);
66
chart.plot()
67
.xGrid(true)
68
.yGrid(true);
69
70
// set chart padding
71
chart.padding()
72
.right(35)
73
.left(5)
74
.top(10);
75
76
// add annotation items in context menu
77
chart.contextMenu().itemsFormatter(contextMenuItemsFormatter);
78
79
// use annotation events to update application UI elements
80
chart.listen('annotationDrawingFinish', onAnnotationDrawingFinish);
81
chart.listen('annotationSelect', onAnnotationSelect);
82
chart.listen('annotationUnSelect', function () {
83
$colorPickerFill.removeAttr('disabled');
84
// $markerSizeBtn.removeAttr('disabled');
85
$('.drawing-tools-solo').find('.bootstrap-select').each(function () {
86
$(this).removeClass('open');
87
})
88
});
89
chart.listen('chartDraw', function () {
90
hidePreloader();
91
92
var $body = $('body');
93
var $textArea = '<textarea id="annotation-label"></textarea>';
94
95
if (!$body.find('#annotation-label').length) {
96
$body.find('[data-annotation-type="label"]').length ?
97
$body.find('[data-annotation-type="label"]').after($textArea) :
98
$body.append($textArea);
99
$annotationLabel = $('#annotation-label');
100
}
101
});
102
103
// add textarea for label annotation and listen events
104
chart.listen('annotationDrawingFinish', function (e) {
105
if (e.annotation.type === 'label') {
106
107
$annotationLabel.val(e.annotation.text())
108
.focus()
109
.on('change keyup paste', function (e) {
110
if (e.keyCode === 46) return;
111
112
try {
113
var annotation = chart.annotations().getSelectedAnnotation();
114
annotation.enabled();
115
} catch (err) {
116
annotation = null;
117
}
118
119
if (annotation) {
120
$(this).val() ? annotation.text($(this).val()) : annotation.text(' ') && $(this).val(' ');
121
}
122
});
123
124
chart.listen('annotationDrawingFinish', function (e) {
125
if (e.annotation.type === 'label') {
126
$annotationLabel.val(e.annotation.text())
127
.focus();
128
}
129
});
130
131
chart.listen('annotationSelect', function (e) {
132
if (e.annotation.type === 'label') {
133
$annotationLabel.val(e.annotation.text())
134
.focus();
135
}
136
});
137
138
chart.listen('annotationUnselect', function () {
139
if (e.annotation.type === 'label') {
140
$annotationLabel.val('');
141
}
142
});
143
}
144
});
145
146
// set container id for the chart
147
chart.container('chart-container');
148
149
// initiate chart drawing
150
chart.draw();
151
});
152
153
function initVolumeBar() {
154
$('.volume-btn').on('mouseenter', function () {
155
var self = this;
156
157
$(this).popover({
158
placement: 'bottom',
159
html: true,
160
trigger: 'manual',
161
content: function () {
162
return '<div id="volume-popover">\n' +
163
' <div class="volume-bar-value text-center">' + $(this).attr('data-volume') + 'px' +
164
' </div>\n' +
165
' <input type="range" id="volume-bar" class="volume-bar" step="1" value="' + $(this).attr('data-volume') + '"' +
166
' min="5" max="35">\n' +
167
' </div>'
168
}
169
});
170
171
$(this).popover('show');
172
173
$(this).siblings('.popover').on('mouseleave', function () {
174
setTimeout(function () {
175
if (!$('.popover:hover').length) {
176
$(self).popover('hide')
177
}
178
}, 100);
179
});
180
}).on('mouseleave', function () {
181
var self = this;
182
183
setTimeout(function () {
184
if (!$('.popover:hover').length) {
185
$(self).popover('hide')
186
}
187
}, 100);
188
});
189
}
190
191
function createPageColorPicker() {
192
var colorPicker = $('.color-picker');
193
var strokeWidth;
194
var STROKE_WIDTH = 1;
195
colorPicker.colorpicker({
196
'color': '#e06666',
197
'align': 'left'
198
});
199
200
colorPicker.on('create', function () {
201
var color = $(this).data('color');
202
203
if ($(this).find('.color-fill-icon[data-color]').length) {
204
color = $(this).find('.color-fill-icon').attr('data-color');
205
}
206
207
$('.color-fill-icon', $(this)).css('background-color', color);
208
});
209
210
colorPicker.on('showPicker', function () {
211
$(this).parent('div').find('.tooltip.in').tooltip('hide');
212
});
213
214
colorPicker.on('changeColor', function () {
215
var color = $(this).data('color');
216
var annotation = chart.annotations().getSelectedAnnotation();
217
var _annotation = annotation;
218
219
if (annotation) {
220
if (annotation.type === 'label') {
221
$annotationLabel.focus();
222
annotation = annotation.background();
223
}
224
225
switch ($(this).attr('data-color')) {
226
case 'fill' :
227
annotation.fill(color);
228
break;
229
case 'stroke' :
230
strokeWidth = annotation.stroke().thickness || STROKE_WIDTH;
231
strokeDash = annotation.stroke().dash || '';
232
var settings = {
233
thickness: strokeWidth,
234
color: color,
235
dash: strokeDash
236
};
237
238
setAnnotationStrokeSettings(annotation, settings);
239
break;
240
case 'fontColor':
241
if (_annotation.type === 'label') _annotation.fontColor(color);
242
break;
243
}
244
}
245
246
if (color === null) {
247
$('.color-fill-icon', $(this)).addClass('colorpicker-color');
248
} else {
249
$('.color-fill-icon', $(this)).removeClass('colorpicker-color')
250
.css('background-color', color);
251
}
252
});
253
}
254
255
function removeSelectedAnnotation() {
256
var annotation = chart.annotations().getSelectedAnnotation();
257
if (annotation) chart.annotations().removeAnnotation(annotation);
258
259
return !!annotation;
260
}
261
262
function removeAllAnnotation() {
263
chart.annotations().removeAllAnnotations();
264
}
265
266
function onAnnotationDrawingFinish() {
267
setToolbarButtonActive(null);
268
}
269
270
function onAnnotationSelect(evt) {
271
var annotation = evt.annotation;
272
var colorFill;
273
var colorStroke;
274
var strokeWidth;
275
var strokeDash;
276
var strokeType;
277
var markerSize;
278
var fontColor;
279
var fontSize;
280
281
var $colorPickerFontColor = $('.color-picker[data-color="fontColor"]');
282
283
var fontSettings = [];
284
285
if (annotation.fill || annotation.background) {
286
$colorPickerFill.removeAttr('disabled');
287
colorFill = annotation.fill ? annotation.fill() : annotation.background().fill();
288
colorStroke = annotation.stroke ? annotation.stroke() : annotation.background().stroke();
289
} else {
290
$colorPickerFill.attr('disabled', 'disabled');
291
}
292
293
if (annotation.type === 'label') {
294
$annotationLabel.focus();
295
296
fontSize = annotation.fontSize();
297
298
$fontSize.attr('data-volume', fontSize);
299
300
fontColor = annotation.fontColor();
301
302
fontSettings = [];
303
304
$labelMethod.each(function () {
305
var method = $(this).data().labelMethod;
306
307
fontSettings.push(annotation[method]());
308
});
309
310
// update font settings select
311
$fontSettings.val(fontSettings).selectpicker('refresh');
312
313
annotation = annotation.background();
314
}
315
316
if (annotation.fill && typeof annotation.fill() === 'function') {
317
colorFill = $colorPickerFill.find('.color-fill-icon').css('background-color');
318
}
319
320
if (colorStroke !== 'none') {
321
colorStroke = annotation.stroke().color;
322
strokeWidth = annotation.stroke().thickness;
323
strokeDash = annotation.stroke().dash;
324
}
325
326
if (annotation.type === 'marker') {
327
markerSize = annotation.size();
328
$markerSize.attr('data-volume', markerSize);
329
} else {
330
$markerSizeBtn.attr('disabled', 'disabled');
331
}
332
333
if (annotation.fill !== undefined) {
334
annotation.fill(colorFill);
335
}
336
337
if (fontSize) {
338
evt.annotation.fontSize(fontSize);
339
}
340
341
switch (strokeDash) {
342
case '1 1' :
343
strokeType = 7;
344
break;
345
case '10 5' :
346
strokeType = 8;
347
break;
348
default :
349
if (strokeWidth) {
350
strokeType = 6;
351
}
352
break;
353
}
354
355
$colorPickerFill.find('.color-fill-icon').css('background-color', colorFill);
356
$colorPickerStroke.find('.color-fill-icon').css('background-color', colorStroke);
357
$colorPickerFontColor.find('.color-fill-icon').css('background-color', fontColor);
358
$strokeSettings.val([strokeWidth, strokeType]).selectpicker('refresh');
359
}
360
361
function contextMenuItemsFormatter(items) {
362
// insert context menu item on 0 position
363
items['annotations-remove-selected'] = {
364
text: "Remove selected annotation",
365
action: removeSelectedAnnotation,
366
index: -10
367
};
368
369
// insert context menu item on 1 position
370
items['annotations-remove-all'] = {
371
text: "Remove all annotations",
372
action: removeAllAnnotation,
373
index: -5
374
};
375
376
// insert context menu separator
377
items['annotations-separator'] = {
378
index: -4
379
};
380
381
return items;
382
}
383
384
function setToolbarButtonActive(type, markerType) {
385
var $buttons = $('.btn[data-annotation-type]');
386
$buttons.removeClass('active');
387
$buttons.blur();
388
389
if (type) {
390
var selector = '.btn[data-annotation-type="' + type + '"]';
391
if (markerType) selector += '[data-marker-type="' + markerType + '"]';
392
$(selector).addClass('active');
393
}
394
}
395
396
function updatePropertiesBySelectedAnnotation(colorStroke, strokeWidth, strokeType) {
397
var annotation = chart.annotations().getSelectedAnnotation();
398
if (annotation === null) return;
399
400
if (annotation.type === 'label') {
401
$annotationLabel.focus();
402
annotation = annotation.background();
403
}
404
405
switch (strokeType) {
406
case '6' :
407
strokeType = null;
408
break;
409
case '7' :
410
strokeType = '1 1';
411
break;
412
case '8' :
413
strokeType = '10 5';
414
break;
415
}
416
417
var settings = {
418
thickness: strokeWidth,
419
color: colorStroke,
420
dash: strokeType
421
};
422
423
setAnnotationStrokeSettings(annotation, settings);
424
}
425
426
function setAnnotationStrokeSettings(annotation, settings) {
427
annotation.stroke(settings);
428
if (annotation.hovered || annotation.selected) {
429
annotation.hovered().stroke(settings);
430
annotation.selected().stroke(settings);
431
}
432
}
433
434
function hidePreloader() {
435
$('#loader-wrapper').fadeOut('slow');
436
}
437
438
function initTooltip(position) {
439
$(document).ready(function () {
440
$('[data-toggle="tooltip"]').tooltip({
441
'placement': position,
442
'animation': false
443
}).on('show.bs.tooltip', function () {
444
if ($(this).hasClass('color-picker') && $('.colorpicker-visible').length) {
445
return false
446
}
447
})
448
});
449
}
450
451
function normalizeFontSettings(val) {
452
var fontMethods = {};
453
454
$labelMethod.each(function () {
455
fontMethods[$(this).data().labelMethod] = null;
456
});
457
458
val && val.forEach(function (item) {
459
if (item) {
460
$fontSettings.find('[data-label-method]').each(function () {
461
var $that = $(this);
462
var $el = $(this).find('option').length ? $(this).find('option') : $(this);
463
464
$el.each(function () {
465
if ($(this).val() === item) {
466
fontMethods[$that.attr('data-label-method')] = item;
467
}
468
});
469
});
470
}
471
});
472
473
return fontMethods
474
}
475
476
$(document).ready(function () {
477
$('select.choose-drawing-tools').on('change', changeAnnotations);
478
$('select.choose-marker').on('change', changeAnnotations);
479
$('[data-annotation-type]').on('click', changeAnnotations);
480
481
$('#annotation-label-autosize').on('click', function () {
482
var annotation = chart.annotations().getSelectedAnnotation();
483
484
if (annotation && annotation.type === 'label') {
485
annotation.width(null);
486
annotation.height(null);
487
}
488
489
setToolbarButtonActive(null);
490
491
$annotationLabel.focus();
492
});
493
494
function changeAnnotations() {
495
var $that = $(this);
496
497
setTimeout(function () {
498
var $target = $that;
499
var active = $target.hasClass('active');
500
var markerSize = $markerSize.attr('data-volume');
501
var fontSize = $fontSize.attr('data-volume');
502
var fontColor = $('[data-color="fontColor"]').find('.color-fill-icon').css('background-color');
503
504
var colorFill = $colorPickerFill.find('.color-fill-icon').css('background-color');
505
var colorStroke = $colorPickerStroke.find('.color-fill-icon').css('background-color');
506
507
var strokeType;
508
var strokeWidth;
509
var strokeDash;
510
var STROKE_WIDTH = 1;
511
512
if ($strokeSettings.val()) {
513
switch ($strokeSettings.val()[0]) {
514
case '6' :
515
case '7' :
516
case '8' :
517
strokeType = $strokeSettings.val()[0];
518
strokeWidth = $strokeSettings.val()[1] || STROKE_WIDTH;
519
break;
520
default :
521
strokeWidth = $strokeSettings.val()[0];
522
strokeType = $strokeSettings.val()[1];
523
break;
524
}
525
}
526
527
switch (strokeType) {
528
case '6' :
529
strokeDash = null;
530
break;
531
case '7' :
532
strokeDash = '1 1';
533
break;
534
case '8' :
535
strokeDash = '10 5';
536
break;
537
}
538
539
var strokeSettings = {
540
thickness: strokeWidth,
541
color: colorStroke,
542
dash: strokeDash
543
};
544
545
var fontSettings = normalizeFontSettings($fontSettings.val());
546
547
if (active) {
548
chart.annotations().cancelDrawing();
549
setToolbarButtonActive(null);
550
} else {
551
var type = $target.data().annotationType || $target.find('option:selected').data().annotationType;
552
553
if (!$target.data().annotationType) {
554
var markerType = $target.find('option:selected').data().markerType;
555
}
556
557
setToolbarButtonActive(type, markerType);
558
559
if (type) {
560
561
if (!$target.data().annotationType) {
562
var markerAnchor = $target.find('option:selected').data().markerAnchor;
563
}
564
565
var drawingSettings = {
566
type: type,
567
size: markerSize,
568
markerType: markerType,
569
anchor: markerAnchor,
570
fontSize: fontSize,
571
fontColor: fontColor
572
};
573
574
$.extend(drawingSettings, fontSettings);
575
576
if (type === 'label') {
577
drawingSettings.anchor = fontSettings.anchor;
578
579
drawingSettings.background = {
580
fill: colorFill,
581
stroke: strokeSettings
582
};
583
drawingSettings.hovered = {
584
background: {
585
stroke: strokeSettings
586
}
587
};
588
drawingSettings.selected = {
589
background: {
590
stroke: strokeSettings
591
}
592
};
593
} else {
594
drawingSettings.fill = colorFill;
595
drawingSettings.stroke = strokeSettings;
596
drawingSettings.hovered = {
597
stroke: strokeSettings
598
};
599
drawingSettings.selected = {
600
stroke: strokeSettings
601
};
602
}
603
604
chart.annotations().startDrawing(drawingSettings);
605
}
606
}
607
608
var annotation = chart.annotations().getSelectedAnnotation();
609
610
if (annotation.fill || annotation.background) {
611
$colorPickerFill.removeAttr('disabled');
612
} else {
613
$colorPickerFill.attr('disabled', 'disabled');
614
}
615
616
$target.val('');
617
}, 1);
618
}
619
620
$('.btn[data-action-type]').click(function (evt) {
621
var annotation = chart.annotations().getSelectedAnnotation();
622
var $target = $(evt.currentTarget);
623
$target.blur();
624
var type = $target.attr('data-action-type');
625
626
switch (type) {
627
case 'removeAllAnnotations':
628
removeAllAnnotation();
629
break;
630
case 'removeSelectedAnnotation' :
631
removeSelectedAnnotation();
632
break;
633
case 'unSelectedAnnotation' :
634
chart.annotations().unselect(annotation).cancelDrawing();
635
setToolbarButtonActive(null);
636
break;
637
}
638
639
});
640
641
$strokeSettings.on('change', function () {
642
var strokeWidth;
643
var strokeType;
644
var STROKE_WIDTH = 1;
645
var colorStroke = $colorPickerStroke.find('.color-fill-icon').css('background-color');
646
647
if ($(this).val()) {
648
switch ($(this).val()[0]) {
649
case '6' :
650
case '7' :
651
case '8' :
652
strokeType = $(this).val()[0];
653
strokeWidth = $(this).val()[1] || STROKE_WIDTH;
654
break;
655
default :
656
strokeType = $(this).val()[1];
657
strokeWidth = $(this).val()[0];
658
break;
659
}
660
661
updatePropertiesBySelectedAnnotation(colorStroke, strokeWidth, strokeType);
662
}
663
});
664
665
$markerSize.on('change', function () {
666
var annotation = chart.annotations().getSelectedAnnotation();
667
668
if (annotation && annotation.type === 'marker') {
669
annotation.size($(this).val());
670
}
671
});
672
673
$('body').on('change', '.volume-bar', function () {
674
var annotation = chart.annotations().getSelectedAnnotation();
675
676
var $popover = $(this).closest('.popover');
677
678
$popover.prev('.volume-btn')
679
.attr('data-volume', $(this).val());
680
681
$popover.find('.volume-bar-value').text($(this).val() + 'px');
682
683
if (annotation && annotation.type === 'label' &&
684
$popover.prev('.volume-btn').attr('data-el-size') === 'label') {
685
annotation.fontSize($(this).val());
686
$annotationLabel.focus();
687
} else if (annotation && annotation.type === 'marker' &&
688
$popover.prev('.volume-btn').attr('data-el-size') === 'marker') {
689
annotation.size($(this).val());
690
}
691
});
692
693
$fontSettings.on('change', function () {
694
var annotation = chart.annotations().getSelectedAnnotation();
695
696
if (annotation && annotation.type === 'label') {
697
698
var fontSettings = normalizeFontSettings($(this).val());
699
700
$labelMethod.each(function () {
701
var method = $(this).data().labelMethod;
702
703
annotation[method](fontSettings[method]);
704
});
705
706
$annotationLabel.focus();
707
}
708
});
709
710
$('html').keyup(function (e) {
711
if (e.keyCode === 46) {
712
removeSelectedAnnotation();
713
}
714
})
715
}
716
);
717
})();