-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.html
364 lines (334 loc) · 9.82 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<!doctype html>
<html>
<head>
<title>Custom events - Highcharts module</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.highcharts.com/stock/js/highstock.src.js"></script>
<script src="./js/annotations.js"></script>
<script src="./js/demo.js"></script>
</head>
<body>
<div id="main-content">
<h1>Annotations module</h1>
<p><div class="info">If you're interested in adding new features or modifying existing ones, please contact us: <a href="mailto:[email protected]"> [email protected] </a><br>
You may also want to check our other demo here: <a href="http://demo.blacklabel.pl">http://demo.blacklabel.pl</a>.</div></p>
<h2>Installation</h2>
<p>Like any other Highcharts module (e.g. exporting), add <code><script></code> tag pointing to <code>annotations.js</code> below Highcharts script tag.</p>
<p>For NPM users:</p>
<pre><code>var Highcharts = require('highcharts'),
HighchartsAnnotations = require('annotations')(Highcharts);</code></pre>
<h2>Sample code</h2>
<pre><code>new Highcharts.Chart({
chart: {
renderTo: container
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0]
}],
annotations: [{
xValue: 4,
yValue: 125,
title: {
text: "Annotated chart!"
},
events: {
click: function(e) { console.log("Annotation clicked:", this); }
}
}]
})
</code></pre>
<h2>Available options</h2>
<h3>Chart options</h3>
<table>
<thead>
<tr>
<th align="left">Option </th>
<th align="left"> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">chart.annotations </td>
<td align="left"> Array containing annotation configuration objects</td>
</tr>
<tr>
<td align="left">chart.annotationsOptions </td>
<td align="left"> Default options for annotations (like buttons' list)</td>
</tr>
</tbody>
</table>
<h3>Annotation configuration object</h3>
<table>
<thead>
<tr>
<th align="left">Option </th>
<th align="left"> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">x<br>y </td>
<td align="left"> Annotation position defined in pixels</td>
</tr>
<tr>
<td align="left">xValue<br>yValue </td>
<td align="left"> Annotation position defined using axis values</td>
</tr>
<tr>
<td align="left">xValueEnd<br>yValueEnd </td>
<td align="left"> Path only. Instead of defining path, set these values to make annotation scalable</td>
</tr>
<tr>
<td align="left">xAxis<br>yAxis </td>
<td align="left"> Axis index, default to 0</td>
</tr>
<tr>
<td align="left">anchorX<br>anchorY </td>
<td align="left"> Defines annotation anchor point, available values:<br><pre>anchorX: "left"/"center"/"right"</pre><br><pre>anchorY: "top"/"middle"/"bottom"</pre></td>
</tr>
<tr>
<td align="left">allowDragX<br>allowDragY</td>
<td align="left"> Allow user to drag and drop an annotation. Horizontal and vertical.</td>
</tr>
<tr>
<td align="left">linkedTo </td>
<td align="left"> Link annotation to point or series using it's id</td>
</tr>
<tr>
<td align="left">title </td>
<td align="left"> Title configuration object</td>
</tr>
<tr>
<td align="left">title.text </td>
<td align="left"> Title text</td>
</tr>
<tr>
<td align="left">title.x<br>title.y </td>
<td align="left"> Title position in pixels, relative to annotation position</td>
</tr>
<tr>
<td align="left">title.style </td>
<td align="left"> Additional CSS styles for title</td>
</tr>
<tr>
<td align="left">title.style.color </td>
<td align="left"> Title text color</td>
</tr>
<tr>
<td align="left">title.style.fontSize </td>
<td align="left"> Title font size</td>
</tr>
<tr>
<td align="left">shape </td>
<td align="left"> Shape configuration object</td>
</tr>
<tr>
<td align="left">shape.type </td>
<td align="left"> Shape type, available types are <code>"path"</code>, <code>"circle"</code> and <code>"rect"</code></td>
</tr>
<tr>
<td align="left">shape.units </td>
<td align="left"> Defines whether shape uses pixels or axis values</td>
</tr>
<tr>
<td align="left">shape.params </td>
<td align="left"> Shape parameters (parameters are passed to renderer method like rect, circle or path)</td>
</tr>
<tr>
<td align="left"> events </td>
<td align="left"> Object of events, supported are: <code>mouseover, mouseout, mousedown, mouseup, click, dblclick</code>. <code>this</code> in a callback refers to the annotation object.</td>
</tr>
<tr>
<td align="left"> selectionMarker </td>
<td align="left"> Styles for a selected annotation, defaults to:
<code>{
'stroke-width': 1,
stroke: 'black',
fill: 'transparent',
dashstyle: 'ShortDash',
'shape-rendering': 'crispEdges'
}</code></td>
</tr>
</tbody>
</table>
<h3>Available shape parameters</h3>
<table>
<thead>
<tr>
<th align="left">Option </th>
<th align="left"> Description </th>
<th align="left"> Limited to</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">shape.params.x<br>shape.params.y </td>
<td align="left"> Shape position relative to the annotation position </td>
<td align="left">rect<br>circle</td>
</tr>
<tr>
<td align="left">shape.params.width<br>shape.params.height </td>
<td align="left"> Rectangle width and height (only for <code>"rect"</code> type) </td>
<td align="left"> rect</td>
</tr>
<tr>
<td align="left">shape.params.d </td>
<td align="left"> Path definition (only for <code>"path"</code> type) </td>
<td align="left"> path</td>
</tr>
<tr>
<td align="left">shape.params.r </td>
<td align="left"> Circle radius </td>
<td align="left"> circle</td>
</tr>
<tr>
<td align="left">shape.params.fill </td>
<td align="left"> Fill color, default: <code>"transparent"</code> </td>
<td align="left"> -</td>
</tr>
<tr>
<td align="left">shape.params.stroke </td>
<td align="left"> Stroke color, default: <code>"black"</code> </td>
<td align="left"> -</td>
</tr>
<tr>
<td align="left">shape.params.strokeWidth </td>
<td align="left"> Stroke width (and line width for path), default: <code>2</code> </td>
<td align="left"> -</td>
</tr>
</tbody>
</table>
<h3>Chart.annotations</h3>
<table>
<thead>
<tr>
<th align="left">Property </th>
<th align="left"> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">chart.addAnnotation(options) </td>
<td align="left"> Add one annotation with given options</td>
</tr>
<tr>
<td align="left">chart.redrawAnnotations() </td>
<td align="left"> Redraw all annotations</td>
</tr>
<tr>
<td align="left">chart.annotations.allItems </td>
<td align="left"> Array containing all annotations</td>
</tr>
</tbody>
</table>
<h3>Annotation object</h3>
<table>
<thead>
<tr>
<th align="left">Property </th>
<th align="left"> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">annotation.update(options) </td>
<td align="left"> Update an annotation with given options</td>
</tr>
<tr>
<td align="left">annotation.destroy() </td>
<td align="left"> Destroy an annotation</td>
</tr>
<tr>
<td align="left">annotation.show()</td>
<td align="left"> Show an annotation - only for non-linked annotations</td>
</tr>
<tr>
<td align="left">annotation.hide()</td>
<td align="left"> Hide an annotation - only for non-linked annotations</td>
</tr>
<tr>
<td align="left">annotation.select()</td>
<td align="left"> Select an annotation by adding selection box</td>
</tr>
<tr>
<td align="left">annotation.deselect()</td>
<td align="left"> Deselect an annotation by removing selection box</td>
</tr>
</tbody>
</table>
<h3>Chart.annotationsOptions</h3>
<table>
<thead>
<tr>
<th align="left">Property </th>
<th align="left"> Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"> enabledButtons </td>
<td align="left"> Enable or disable buttons for drawing annotations. <br>
Selected button prevents from zooming and panning to draw annotation. </td>
</tr>
<tr>
<td align="left"> buttonsOffsets </td>
<td align="left"> Offsets for the buttons in array: <code>[x-offset, y-offset]</code>. Useful when placing annotations next to the exporting module, etc. Defaults to <code>[0, 0]</code>. </td>
</tr>
<tr>
<td align="left"> buttons </td>
<td align="left"> Array of buttons. For example:
<pre>{
annotationEvents: {
step: callback, // to be called during mouse drag for new annotation
stop: callback // to be called after mouse up / release
},
annotation: { // standard annotation options, used for new annotation
anchorX: 'left',
anchorY: 'top',
xAxis: 0,
yAxis: 0,
shape: {
type: 'path',
params: {
d: ['M', 0, 0, 'L', 100, 100 ]
}
}
},
symbol: { // button symbol options
shape: 'rect', // shape, taken from Highcharts.symbols
size: 12,
style: {
'stroke-width': 2,
'stroke': 'black',
fill: 'red',
zIndex: 121
}
},
style: { // buton style itself
fill: 'black',
stroke: 'blue',
strokeWidth: 2,
},
size: 12, // buton size
states: { // states for button
selected: {
fill: '#9BD'
},
hover: {
fill: '#9BD'
}
}
}</pre></td>
</tr>
</tbody>
</table>
<h2>Advanced demo</h2>
<h3>Add annotation via buttons</h3>
<div id="container"></div>
</div>
</div>
</body>
</html>