├── .eslint-default-config.yml ├── .eslintrc ├── README.md ├── bower.json ├── css └── styles.css ├── gulpfile.js ├── index.html ├── js ├── annotations.js └── demo.js ├── license.txt ├── manifest.json └── package.json /.eslint-default-config.yml: -------------------------------------------------------------------------------- 1 | # Copied from https://github.com/eslint/eslint/blob/master/packages/eslint-config-eslint/default.yml 2 | # Updated 2015-04-06 3 | 4 | extends: 5 | "eslint:recommended" 6 | 7 | rules: 8 | array-callback-return: "error" 9 | indent: ["error", 4, {SwitchCase: 1}] 10 | block-spacing: "error" 11 | brace-style: ["error", "1tbs"] 12 | camelcase: ["error", { properties: "never" }] 13 | callback-return: ["error", ["cb", "callback", "next"]] 14 | comma-spacing: "error" 15 | comma-style: ["error", "last"] 16 | consistent-return: "error" 17 | curly: ["error", "all"] 18 | default-case: "error" 19 | dot-notation: ["error", { allowKeywords: true }] 20 | eol-last: "error" 21 | eqeqeq: "error" 22 | func-style: ["error", "declaration"] 23 | guard-for-in: "error" 24 | key-spacing: ["error", { beforeColon: false, afterColon: true }] 25 | keyword-spacing: "error" 26 | lines-around-comment: ["error", { 27 | beforeBlockComment: true, 28 | afterBlockComment: false, 29 | beforeLineComment: true, 30 | afterLineComment: false 31 | }] 32 | new-cap: "error" 33 | newline-after-var: "error" 34 | new-parens: "error" 35 | no-alert: "error" 36 | no-array-constructor: "error" 37 | no-caller: "error" 38 | no-console: 0 39 | no-delete-var: "error" 40 | no-eval: "error" 41 | no-extend-native: "error" 42 | no-extra-bind: "error" 43 | no-fallthrough: "error" 44 | no-floating-decimal: "error" 45 | no-implied-eval: "error" 46 | no-invalid-this: "error" 47 | no-iterator: "error" 48 | no-label-var: "error" 49 | no-labels: "error" 50 | no-lone-blocks: "error" 51 | no-loop-func: "error" 52 | no-mixed-spaces-and-tabs: ["error", false] 53 | no-multi-spaces: "error" 54 | no-multi-str: "error" 55 | no-native-reassign: "error" 56 | no-nested-ternary: "error" 57 | no-new: "error" 58 | no-new-func: "error" 59 | no-new-object: "error" 60 | no-new-wrappers: "error" 61 | no-octal: "error" 62 | no-octal-escape: "error" 63 | no-process-exit: "error" 64 | no-proto: "error" 65 | no-redeclare: "error" 66 | no-return-assign: "error" 67 | no-script-url: "error" 68 | no-self-assign: "error" 69 | no-sequences: "error" 70 | no-shadow: "error" 71 | no-shadow-restricted-names: "error" 72 | no-spaced-func: "error" 73 | no-trailing-spaces: "error" 74 | no-undef: "error" 75 | no-undef-init: "error" 76 | no-undefined: "error" 77 | no-underscore-dangle: ["error", {allowAfterThis: true}] 78 | no-unmodified-loop-condition: "error" 79 | no-unused-expressions: "error" 80 | no-unused-vars: ["error", {vars: "all", args: "after-used"}] 81 | no-use-before-define: "error" 82 | no-useless-concat: "error" 83 | no-with: "error" 84 | one-var-declaration-per-line: "error" 85 | quotes: ["error", "double"] 86 | radix: "error" 87 | require-jsdoc: "error" 88 | semi: "error" 89 | semi-spacing: ["error", {before: false, after: true}] 90 | space-before-blocks: "error" 91 | space-before-function-paren: ["error", "never"] 92 | space-in-parens: "error" 93 | space-infix-ops: "error" 94 | space-unary-ops: ["error", {words: true, nonwords: false}] 95 | spaced-comment: ["error", "always", { exceptions: ["-"]}] 96 | strict: ["error", "global"] 97 | valid-jsdoc: ["error", { prefer: { "return": "returns"}}] 98 | wrap-iife: "error" 99 | yoda: ["error", "never"] 100 | 101 | # Previously on by default in node environment 102 | no-catch-shadow: "off" 103 | no-mixed-requires: "error" 104 | no-new-require: "error" 105 | no-path-concat: "error" 106 | handle-callback-err: ["error", "err"] -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | extends: 2 | ".eslint-default-config.yml" 3 | 4 | rules: 5 | camelcase: [2, {"properties": "always"}] 6 | comma-dangle: [2, "never"] 7 | dot-location: [2, "property"] 8 | lines-around-comment: 0 9 | newline-after-var: 0 10 | no-alert: 2 11 | no-console: 2 12 | no-debugger: 2 13 | no-else-return: 2 14 | no-unmodified-loop-condition: 0 15 | object-curly-spacing: [2, "always"] 16 | operator-linebreak: [2, "after"] 17 | space-before-function-paren: [2, {"anonymous": "always", "named": "never"}] # JSLint style 18 | strict: 0 19 | quotes: [2, "single"] 20 | 21 | no-trailing-spaces: ["error", { "skipBlankLines": true }] 22 | indent: ["error", "tab", {SwitchCase: 1}] 23 | no-nested-ternary: 0 24 | no-invalid-this: 0 25 | eol-last: 0 26 | require-jsdoc: 0 27 | brace-style: [2, "1tbs", { "allowSingleLine": true }] 28 | wrap-iife: [2, "any"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### ![#f03c15](https://placehold.it/15/f03c15/000000?text=+) Annotations are a part of Highstock 6+ and Highcharts 6+ as a module. This plugin was build for older versions of Highstock. 2 | 3 |

Annotations module

4 | 5 |

If you're interested in adding new features or modifying existing ones, please contact us: start@blacklabel.pl
6 | You may also want to check our other demo here: http://demo.blacklabel.pl.

7 | 8 |

Installation

9 | 10 |

Like any other Highcharts module (e.g. exporting), add <script> tag pointing to annotations.js below Highcharts script tag.

11 | 12 |

For NPM users:

13 |
var Highcharts = require('highcharts'),
 14 |     HighchartsAnnotations = require('annotations')(Highcharts);
15 |

For BOWER users:

16 |
bower install highcharts-annotations
17 | 18 |

Sample code

19 | 20 |
new Highcharts.Chart({
 21 |   chart: {
 22 |     renderTo: container
 23 |   },
 24 |   series: [{
 25 |       data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0]
 26 |   }],
 27 |   annotations: [{
 28 |     xValue: 4,
 29 |     yValue: 125,
 30 |     title: {
 31 |         text: "Annotated chart!"
 32 |     },
 33 |     events: {
 34 |         click: function(e) { console.log("Annotation clicked:", this); }
 35 |     }
 36 |   }]
 37 | })
 38 | 
39 | 40 |

Available options

41 | 42 |

Chart options

43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
Option Description
chart.annotations Array containing annotation configuration objects
chart.annotationsOptions Default options for annotations (like buttons' list)
62 | 63 | 64 |

Annotation configuration object

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 | 156 | 157 | 158 |
Option Description
x
y
Annotation position defined in pixels
xValue
yValue
Annotation position defined using axis values
xValueEnd
yValueEnd
Path only. Instead of defining path, set these values to make annotation scalable
xAxis
yAxis
Axis index, default to 0
anchorX
anchorY
Defines annotation anchor point, available values:
anchorX: "left"/"center"/"right"

anchorY: "top"/"middle"/"bottom"
allowDragX
allowDragY
Allow user to drag and drop an annotation. Horizontal and vertical.
linkedTo Link annotation to point or series using it's id
title Title configuration object
title.text Title text
title.x
title.y
Title position in pixels, relative to annotation position
title.style Additional CSS styles for title
title.style.color Title text color
title.style.fontSize Title font size
shape Shape configuration object
shape.type Shape type, available types are "path", "circle" and "rect"
shape.units Defines whether shape uses pixels or axis values
shape.params Shape parameters (parameters are passed to renderer method like rect, circle or path)
events Object of events, supported are: mouseover, mouseout, mousedown, mouseup, click, dblclick. this in a callback refers to the annotation object.
selectionMarker Styles for a selected annotation, defaults to: 149 | { 150 | 'stroke-width': 1, 151 | stroke: 'black', 152 | fill: 'transparent', 153 | dashstyle: 'ShortDash', 154 | 'shape-rendering': 'crispEdges' 155 | }
159 | 160 | 161 |

Available shape parameters

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 |
Option Description Limited to
shape.params.x
shape.params.y
Shape position relative to the annotation position rect
circle
shape.params.width
shape.params.height
Rectangle width and height (only for "rect" type) rect
shape.params.d Path definition (only for "path" type) path
shape.params.r Circle radius circle
shape.params.fill Fill color, default: "transparent" -
shape.params.stroke Stroke color, default: "black" -
shape.params.strokeWidth Stroke width (and line width for path), default: 2 -
209 | 210 | 211 |

Chart.annotations

212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 |
Property Description
chart.addAnnotation(options) Add one annotation with given options
chart.redrawAnnotations() Redraw all annotations
chart.annotations.allItems Array containing all annotations
235 | 236 | 237 |

Annotation object

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 |
Property Description
annotation.update(options) Update an annotation with given options
annotation.destroy() Destroy an annotation
annotation.show() Show an annotation - only for non-linked annotations
annotation.hide() Hide an annotation - only for non-linked annotations
annotation.select() Select an annotation by adding selection box
annotation.deselect() Deselect an annotation by removing selection box
273 | 274 |

Chart.annotationsOptions

275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 338 | 339 | 340 |
Property Description
enabledButtons Enable or disable buttons for drawing annotations.
287 | Selected button prevents from zooming and panning to draw annotation.
buttonsOffsets Offsets for the buttons in array: [x-offset, y-offset]. Useful when placing annotations next to the exporting module, etc. Defaults to [0, 0].
buttons Array of buttons. For example: 296 |
{
297 | 	annotationEvents: {
298 | 		step: callback, // to be called during mouse drag for new annotation
299 | 		stop: callback  // to be called after mouse up / release
300 | 	},
301 | 	annotation: { // standard annotation options, used for new annotation
302 | 		anchorX: 'left',
303 | 		anchorY: 'top',
304 | 		xAxis: 0,
305 | 		yAxis: 0,
306 | 		shape: {
307 | 			type: 'path',
308 | 			params: {
309 | 				d: ['M', 0, 0, 'L', 100, 100 ]
310 | 			}
311 | 		}
312 | 	},
313 | 	symbol: { // button symbol options
314 | 		shape: 'rect', // shape, taken from Highcharts.symbols
315 | 		size: 12,
316 | 		style: {
317 | 			'stroke-width':  2,
318 | 			'stroke': 'black',
319 | 			fill: 'red',
320 | 			zIndex: 121
321 | 		}
322 | 	},
323 | 	style: { // buton style itself
324 | 		fill: 'black',
325 | 		stroke: 'blue',
326 | 		strokeWidth: 2,
327 | 	},
328 | 	size: 12, // buton size
329 | 	states: { // states for button 
330 | 		selected: {
331 | 			fill: '#9BD'
332 | 		},
333 | 		hover: {
334 | 			fill: '#9BD'
335 | 		}
336 | 	}
337 | }
341 | 342 | 343 |

Advanced demo

344 | 345 | 346 |
Go to project page to see this module in action: http://blacklabel.github.io/annotations/
347 | 348 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "highcharts-annotations", 3 | "version": "1.3.3", 4 | "homepage": "http://blacklabel.github.io/annotations/", 5 | "authors": [ 6 | "Sebastian Bochan ", 7 | "Paweł Fus ", 8 | "Kacper Madej " 9 | ], 10 | "description": "Highcharts plugin to add dynamic annotations to charts.", 11 | "main": "annotations.js", 12 | "keywords": [ 13 | "annotations", 14 | "highcharts", 15 | "highstock", 16 | "highcharts-addon" 17 | ], 18 | "license": "Creative Commons Attribution (CC)", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "app/bower_components", 24 | "test", 25 | "tests" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /css/styles.css: -------------------------------------------------------------------------------- 1 | @import 'https://code.highcharts.com/css/highcharts.css'; 2 | 3 | /* content wrapper */ 4 | #main-content { max-width:900px; margin:0px auto; font-size: 1.3em; line-height: 1.3em; } 5 | #main-content ul li { margin-bottom:10px; } 6 | 7 | /* Highcharts */ 8 | 9 | .highcharts-title { width: calc(100% - 30px)!important; } 10 | 11 | .highcharts-background { fill: #f7f7f7; stroke: #e8eaeb; stroke-width: 5;} 12 | .highcharts-navigator-mask-outside { fill-opacity: 0; } 13 | .highcharts-plot-line { stroke-width: 10px; stroke: #a4c08e; } 14 | .highcharts-plot-band { fill: #FCFFC5; fill-opacity: 1; } 15 | 16 | /* Custom */ 17 | 18 | .btn { float: left; background-color: #d4d4d4; border: none; color: #000; cursor: pointer; } 19 | 20 | #flash { color: #000000; background-color: rgb(90, 200, 90); display: none; height: 30px; width: calc(100% + 10px); } 21 | #report { padding: 7px 0px 7px 10px; } 22 | 23 | .chart-title { background-color: #3d3d3d; color: #fff; float: left; font-size: 0.756em; padding: 10px; width: calc(100% - 1px); } 24 | .chart-subtitle { line-height: 1.7em; font-size: 0.8em; padding-right: 10px; color: rgba(255, 0, 0, 0.8); float: right; } 25 | 26 | .chart-href, .chart-href a, .chart-href a:hover { float: right; color: red; text-decoration: none } 27 | 28 | h1, h2, h3, h4, h5, h6, p, blockquote { margin: 0; padding: 0; } 29 | 30 | body { background-color: #fff; color: #737373; font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; font-size: 0.6em; margin: 10px 13px 10px 13px; line-height: 1.2em; } 31 | table { margin: 10px 0 15px 0; border-collapse: collapse; } 32 | td, th { border: 1px solid #ddd; padding: 3px 10px; } 33 | th { padding: 5px 10px; } 34 | a { color: #0069d6; } 35 | a:hover { color: #0050a3; text-decoration: none; } 36 | a img { border: none; } 37 | p { margin-bottom: 9px; } 38 | h1, h2, h3, h4, h5, h6 { color: #404040; line-height: 36px; } 39 | h1 { margin-bottom: 18px; font-size: 30px; } 40 | h2 { font-size: 24px; } 41 | h3 { font-size: 18px; } 42 | h4 { font-size: 16px; } 43 | h5 {font-size: 14px; } 44 | h6 { font-size: 13px; } 45 | hr { margin: 0 0 19px; border: 0; border-bottom: 1px solid #ccc; } 46 | 47 | blockquote {padding: 13px 13px 21px 15px;margin-bottom: 18px;font-family: georgia, serif;font-style: italic; } 48 | blockquote:before {content: "\201C";font-size: 40px;margin-left: -10px;font-family: georgia, serif;color: #eee; } 49 | blockquote p {font-size: 14px;font-weight: 300;line-height: 18px;margin-bottom: 0;font-style: italic; } 50 | code, pre {font-family: Monaco, Andale Mono, Courier New, monospace; } 51 | code {background-color: #fee9cc;color: rgba(0, 0, 0, 0.75);padding: 1px 3px;font-size: 12px;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px; } 52 | pre {display: block;padding: 14px;margin: 0 0 18px;line-height: 16px;font-size: 11px;border: 1px solid #d9d9d9;white-space: pre-wrap;word-wrap: break-word; } 53 | pre code {background-color: #fff;color: #737373;font-size: 11px;padding: 0; } 54 | sup {font-size: 0.83em;vertical-align: super;line-height: 0; } 55 | 56 | * {-webkit-print-color-adjust: exact; } 57 | 58 | @media screen and (min-width: 914px) { 59 | body { width: 100%; margin: 10px auto;} 60 | } 61 | 62 | @media print { 63 | body,code,pre code,h1,h2,h3,h4,h5,h6 { color: black;}table,pre { page-break-inside: avoid;} 64 | } 65 | 66 | #chart, #chart-advanced, #chart-3d {height: 500px;width: 100%;position: relative; } 67 | 68 | 69 | /* Annotations UI */ 70 | 71 | .form {margin-right: 10px;width: 160px;height: 330px;padding: 0px;background-color: #e8eaeb;padding: 5px;float: left;font-size: 1.4em; } 72 | .form .form-header {font-size: 1em;padding: 10px;background: #3d3d3d;color: #fff;line-height: 1.45em; } 73 | .form > p {padding: 5px 10px;margin: 0px; } 74 | .form > p:nth-child(2n) { background: #f7f7f7; } 75 | .form label {width: 140px;float: left;margin-top: 5px;padding-bottom: 3px; } 76 | .form input {width: 140px; } 77 | .form input[type="radio"] {width: auto;margin-left: 55px;margin-bottom: 3px; } 78 | .form .short {width: 60px;float: right;margin: 2px 0px 0px 0px; } 79 | 80 | .highcharts-indicators { fill: none; } 81 | #chart-advanced .highcharts-yaxis .highcharts-axis-line { stroke-width: 2px; } 82 | #chart-advanced .highcharts-plot-line { stroke-width: 1px; stroke: orange; } 83 | 84 | 85 | /* ==== 3d ==== */ 86 | 87 | #chart-3d .highcharts-background { fill: #000;} 88 | #chart-3d .highcharts-series.highcharts-series-0 path { stroke-width: 0; } 89 | #chart-3d .highcharts-grid-line { stroke-width: 1px; stroke: #d8d8d8;} 90 | #chart-3d .chart-title { width: calc(100% + 4px); } 91 | 92 | /* custom gradients */ 93 | #chart-3d .moon { fill-opacity: 1; fill: url(#gradient-2); stroke-width:0; } 94 | #chart-3d .sun { fill-opacity: 1; fill: url(#gradient-1); stroke-width:0; } 95 | #chart-3d .planet { fill-opacity: 1; fill: url(#gradient-0); stroke-width:0; } 96 | #chart-3d .magneticFieldPink { fill-opacity: 1; fill: url(#magneticFieldPink); stroke-width:0; } 97 | #chart-3d .magneticFieldBlue { fill-opacity: 1; fill: url(#magneticFieldBlue); stroke-width:0; } -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var gulp = require('gulp'), 3 | eslint = require('gulp-eslint'); 4 | 5 | gulp.task('lint', function () { 6 | return gulp.src(['js/*.js']) 7 | .pipe(eslint()) 8 | .pipe(eslint.failOnError()) 9 | .pipe(eslint.formatEach()); 10 | }); -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Custom events - Highcharts module 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

Annotations module

18 | 19 |

If you're interested in adding new features or modifying existing ones, please contact us: start@blacklabel.pl
20 | You may also want to check our other demo here: http://demo.blacklabel.pl.

21 | 22 |

Installation

23 | 24 |

Like any other Highcharts module (e.g. exporting), add <script> tag pointing to annotations.js below Highcharts script tag.

25 | 26 |

For NPM users:

27 |
var Highcharts = require('highcharts'),
 28 |     HighchartsAnnotations = require('annotations')(Highcharts);
29 | 30 |

Sample code

31 | 32 |
new Highcharts.Chart({
 33 |   chart: {
 34 |     renderTo: container
 35 |   },
 36 |   series: [{
 37 |       data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0]
 38 |   }],
 39 |   annotations: [{
 40 |     xValue: 4,
 41 |     yValue: 125,
 42 |     title: {
 43 |         text: "Annotated chart!"
 44 |     },
 45 |     events: {
 46 |         click: function(e) { console.log("Annotation clicked:", this); }
 47 |     }
 48 |   }]
 49 | })
 50 | 
51 | 52 |

Available options

53 | 54 |

Chart options

55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
Option Description
chart.annotations Array containing annotation configuration objects
chart.annotationsOptions Default options for annotations (like buttons' list)
74 | 75 | 76 |

Annotation configuration object

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 | 168 | 169 | 170 |
Option Description
x
y
Annotation position defined in pixels
xValue
yValue
Annotation position defined using axis values
xValueEnd
yValueEnd
Path only. Instead of defining path, set these values to make annotation scalable
xAxis
yAxis
Axis index, default to 0
anchorX
anchorY
Defines annotation anchor point, available values:
anchorX: "left"/"center"/"right"

anchorY: "top"/"middle"/"bottom"
allowDragX
allowDragY
Allow user to drag and drop an annotation. Horizontal and vertical.
linkedTo Link annotation to point or series using it's id
title Title configuration object
title.text Title text
title.x
title.y
Title position in pixels, relative to annotation position
title.style Additional CSS styles for title
title.style.color Title text color
title.style.fontSize Title font size
shape Shape configuration object
shape.type Shape type, available types are "path", "circle" and "rect"
shape.units Defines whether shape uses pixels or axis values
shape.params Shape parameters (parameters are passed to renderer method like rect, circle or path)
events Object of events, supported are: mouseover, mouseout, mousedown, mouseup, click, dblclick. this in a callback refers to the annotation object.
selectionMarker Styles for a selected annotation, defaults to: 161 | { 162 | 'stroke-width': 1, 163 | stroke: 'black', 164 | fill: 'transparent', 165 | dashstyle: 'ShortDash', 166 | 'shape-rendering': 'crispEdges' 167 | }
171 | 172 | 173 |

Available shape parameters

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 |
Option Description Limited to
shape.params.x
shape.params.y
Shape position relative to the annotation position rect
circle
shape.params.width
shape.params.height
Rectangle width and height (only for "rect" type) rect
shape.params.d Path definition (only for "path" type) path
shape.params.r Circle radius circle
shape.params.fill Fill color, default: "transparent" -
shape.params.stroke Stroke color, default: "black" -
shape.params.strokeWidth Stroke width (and line width for path), default: 2 -
221 | 222 | 223 |

Chart.annotations

224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 |
Property Description
chart.addAnnotation(options) Add one annotation with given options
chart.redrawAnnotations() Redraw all annotations
chart.annotations.allItems Array containing all annotations
247 | 248 | 249 |

Annotation object

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 |
Property Description
annotation.update(options) Update an annotation with given options
annotation.destroy() Destroy an annotation
annotation.show() Show an annotation - only for non-linked annotations
annotation.hide() Hide an annotation - only for non-linked annotations
annotation.select() Select an annotation by adding selection box
annotation.deselect() Deselect an annotation by removing selection box
285 | 286 |

Chart.annotationsOptions

287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 350 | 351 | 352 |
Property Description
enabledButtons Enable or disable buttons for drawing annotations.
299 | Selected button prevents from zooming and panning to draw annotation.
buttonsOffsets Offsets for the buttons in array: [x-offset, y-offset]. Useful when placing annotations next to the exporting module, etc. Defaults to [0, 0].
buttons Array of buttons. For example: 308 |
{
309 | 	annotationEvents: {
310 | 		step: callback, // to be called during mouse drag for new annotation
311 | 		stop: callback  // to be called after mouse up / release
312 | 	},
313 | 	annotation: { // standard annotation options, used for new annotation
314 | 		anchorX: 'left',
315 | 		anchorY: 'top',
316 | 		xAxis: 0,
317 | 		yAxis: 0,
318 | 		shape: {
319 | 			type: 'path',
320 | 			params: {
321 | 				d: ['M', 0, 0, 'L', 100, 100 ]
322 | 			}
323 | 		}
324 | 	},
325 | 	symbol: { // button symbol options
326 | 		shape: 'rect', // shape, taken from Highcharts.symbols
327 | 		size: 12,
328 | 		style: {
329 | 			'stroke-width':  2,
330 | 			'stroke': 'black',
331 | 			fill: 'red',
332 | 			zIndex: 121
333 | 		}
334 | 	},
335 | 	style: { // buton style itself
336 | 		fill: 'black',
337 | 		stroke: 'blue',
338 | 		strokeWidth: 2,
339 | 	},
340 | 	size: 12, // buton size
341 | 	states: { // states for button 
342 | 		selected: {
343 | 			fill: '#9BD'
344 | 		},
345 | 		hover: {
346 | 			fill: '#9BD'
347 | 		}
348 | 	}
349 | }
353 | 354 | 355 | 356 |

Advanced demo

357 | 358 | 359 |

Add annotation via buttons

360 |
361 |
362 | 363 | 364 | 365 | -------------------------------------------------------------------------------- /js/annotations.js: -------------------------------------------------------------------------------- 1 | /* global $ Highcharts document window module:true */ 2 | (function (factory) { 3 | if (typeof module === 'object' && module.exports) { 4 | module.exports = factory; 5 | } else { 6 | factory(Highcharts); 7 | } 8 | }(function (H) { 9 | 'use strict'; 10 | // Highcharts helper methods 11 | var UNDEFINED, 12 | ALIGN_FACTOR, 13 | Chart = H.Chart, 14 | extend = H.extend, 15 | merge = H.merge, 16 | each = H.each, 17 | inArray = (window.HighchartsAdapter && window.HighchartsAdapter.inArray) || H.inArray, // #52, since Highcharts 4.1.10 HighchartsAdapter is only provided by the Highcharts Standalone Framework 18 | addEvent = H.addEvent, 19 | removeEvent = H.removeEvent, 20 | isOldIE = H.VMLRenderer ? true : false; 21 | 22 | H.ALLOWED_SHAPES = ['path', 'rect', 'circle']; 23 | 24 | ALIGN_FACTOR = { 25 | top: 0, 26 | left: 0, 27 | center: 0.5, 28 | middle: 0.5, 29 | bottom: 1, 30 | right: 1 31 | }; 32 | 33 | 34 | H.SVGRenderer.prototype.symbols.line = function (x, y, w, h) { 35 | var p = 2; 36 | return [ 37 | 'M', x + p, y + p, 'L', x + w - p, y + h - p 38 | ]; 39 | }; 40 | 41 | H.SVGRenderer.prototype.symbols.text = function (x, y, w, h) { 42 | var p = 1; 43 | return [ 44 | // 'M', 0, 0, 'L', 10, 0, 'M', 5, 0, 'L', 5, 5 45 | 'M', x, y + p, 'L', x + w, y + p, 46 | 'M', x + w / 2, y + p, 'L', x + w / 2, y + p + h 47 | ]; 48 | }; 49 | // VML fallback 50 | if (H.VMLRenderer) { 51 | H.VMLRenderer.prototype.symbols.text = H.SVGRenderer.prototype.symbols.text; 52 | H.VMLRenderer.prototype.symbols.line = H.SVGRenderer.prototype.symbols.line; 53 | } 54 | 55 | 56 | // when drawing annotation, don't zoom/select place 57 | H.wrap(H.Pointer.prototype, 'drag', function (c, e) { 58 | if (!this.chart.annotations || this.chart.annotations.allowZoom) { 59 | c.call(this, e); 60 | } 61 | }); 62 | 63 | // deselect active annotation 64 | H.wrap(H.Pointer.prototype, 'onContainerMouseDown', function (c, e) { 65 | c.call(this, e); 66 | if (this.chart.selectedAnnotation) { 67 | this.chart.selectedAnnotation.events.deselect.call(this.chart.selectedAnnotation, e); 68 | } 69 | }); 70 | 71 | // utils for buttons 72 | var utils = { 73 | getRadius: function (e) { 74 | var ann = this, 75 | chart = ann.chart, 76 | bbox = chart.container.getBoundingClientRect(), 77 | x = e.clientX - bbox.left, 78 | y = e.clientY - bbox.top, 79 | xAxis = chart.xAxis[ann.options.xAxis], 80 | yAxis = chart.yAxis[ann.options.yAxis], 81 | dx = Math.abs(x - xAxis.toPixels(ann.options.xValue)), 82 | dy = Math.abs(y - yAxis.toPixels(ann.options.yValue)), 83 | radius = parseInt(Math.sqrt(dx * dx + dy * dy), 10); 84 | ann.shape.attr({ 85 | r: radius 86 | }); 87 | return radius; 88 | }, 89 | getRadiusAndUpdate: function (e) { 90 | var r = utils.getRadius.call(this, e); 91 | this.update({ 92 | shape: { 93 | params: { 94 | r: r, 95 | x: -r, 96 | y: -r 97 | } 98 | } 99 | }); 100 | }, 101 | getPath: function (e) { 102 | var ann = this, 103 | chart = ann.chart, 104 | bbox = chart.container.getBoundingClientRect(), 105 | x = e.clientX - bbox.left, 106 | y = e.clientY - bbox.top, 107 | xAxis = chart.xAxis[ann.options.xAxis], 108 | yAxis = chart.yAxis[ann.options.yAxis], 109 | dx = x - xAxis.toPixels(ann.options.xValue), 110 | dy = y - yAxis.toPixels(ann.options.yValue); 111 | 112 | var path = ['M', 0, 0, 'L', parseInt(dx, 10), parseInt(dy, 10)]; 113 | ann.shape.attr({ 114 | d: path 115 | }); 116 | 117 | return path; 118 | }, 119 | getPathAndUpdate: function (e) { 120 | var ann = this, 121 | chart = ann.chart, 122 | path = utils.getPath.call(ann, e), 123 | xAxis = chart.xAxis[ann.options.xAxis], 124 | yAxis = chart.yAxis[ann.options.yAxis], 125 | x = xAxis.toValue(path[4] + xAxis.toPixels(ann.options.xValue)), 126 | y = yAxis.toValue(path[5] + yAxis.toPixels(ann.options.yValue)); 127 | 128 | this.update({ 129 | xValueEnd: x, 130 | yValueEnd: y, 131 | shape: { 132 | params: { 133 | d: path 134 | } 135 | } 136 | }); 137 | }, 138 | getRect: function (e) { 139 | var ann = this, 140 | chart = ann.chart, 141 | bbox = chart.container.getBoundingClientRect(), 142 | x = e.clientX - bbox.left, 143 | y = e.clientY - bbox.top, 144 | xAxis = chart.xAxis[ann.options.xAxis], 145 | yAxis = chart.yAxis[ann.options.yAxis], 146 | sx = xAxis.toPixels(ann.options.xValue), 147 | sy = yAxis.toPixels(ann.options.yValue), 148 | dx = x - sx, 149 | dy = y - sy, 150 | w = Math.round(dx) + 1, 151 | h = Math.round(dy) + 1, 152 | ret = {}; 153 | 154 | ret.x = w < 0 ? w : 0; 155 | ret.width = Math.abs(w); 156 | ret.y = h < 0 ? h : 0; 157 | ret.height = Math.abs(h); 158 | 159 | ann.shape.attr({ 160 | x: ret.x, 161 | y: ret.y, 162 | width: ret.width, 163 | height: ret.height 164 | }); 165 | return ret; 166 | }, 167 | getRectAndUpdate: function (e) { 168 | var rect = utils.getRect.call(this, e); 169 | this.update({ 170 | shape: { 171 | params: rect 172 | } 173 | }); 174 | }, 175 | getText: function () { 176 | // do nothing 177 | }, 178 | showInput: function (e) { 179 | var ann = this, 180 | chart = ann.chart, 181 | index = chart.annotationInputIndex = chart.annotationInputIndex ? chart.annotationInputIndex : 1, 182 | input = document.createElement('span'), 183 | button; 184 | 185 | input.innerHTML = ''; 186 | input.style.position = 'absolute'; 187 | input.style.left = e.pageX + 'px'; 188 | input.style.top = e.pageY + 'px'; 189 | 190 | document.body.appendChild(input); 191 | input.querySelectorAll('input')[0].focus(); 192 | button = input.querySelectorAll('button')[0]; 193 | button.onclick = function () { 194 | var parent = this.parentNode; 195 | 196 | ann.update({ 197 | title: { 198 | text: parent.querySelectorAll('input')[0].value 199 | } 200 | }); 201 | parent.parentNode.removeChild(parent); 202 | }; 203 | chart.annotationInputIndex++; 204 | } 205 | }; 206 | 207 | function defaultOptions(shapeType) { 208 | var shapeOptions, 209 | options; 210 | 211 | options = { 212 | xAxis: 0, 213 | yAxis: 0, 214 | shape: { 215 | params: { 216 | stroke: '#000000', 217 | fill: 'rgba(0,0,0,0)', 218 | 'stroke-width': 2 219 | } 220 | }, 221 | selectionMarker: { 222 | 'stroke-width': 1, 223 | stroke: 'black', 224 | fill: 'transparent', 225 | dashstyle: 'ShortDash', 226 | 'shape-rendering': 'crispEdges' 227 | } 228 | }; 229 | 230 | shapeOptions = { 231 | circle: { 232 | params: { 233 | x: 0, 234 | y: 0 235 | } 236 | } 237 | }; 238 | 239 | if (shapeOptions[shapeType]) { 240 | options.shape = merge(options.shape, shapeOptions[shapeType]); 241 | } 242 | 243 | return options; 244 | } 245 | 246 | 247 | function defatultMainOptions() { 248 | var buttons = [], 249 | shapes = ['circle', 'line', 'square', 'text'], 250 | types = ['circle', 'path', 'rect', null], 251 | params = [{ 252 | r: 0, 253 | fill: 'rgba(255,0,0,0.4)', 254 | stroke: 'black' 255 | }, { 256 | d: ['M', 0, 0, 'L', 10, 10], 257 | fill: 'rgba(255,0,0,0.4)', 258 | stroke: 'black' 259 | }, { 260 | width: 10, 261 | height: 10, 262 | fill: 'rgba(255,0,0,0.4)', 263 | stroke: 'black' 264 | }], 265 | steps = [utils.getRadius, utils.getPath, utils.getRect, utils.getText], 266 | stops = [utils.getRadiusAndUpdate, utils.getPathAndUpdate, utils.getRectAndUpdate, utils.showInput]; 267 | 268 | each(shapes, function (s, i) { 269 | buttons.push({ 270 | annotationEvents: { 271 | step: steps[i], 272 | stop: stops[i] 273 | }, 274 | annotation: { 275 | anchorX: 'left', 276 | anchorY: 'top', 277 | xAxis: 0, 278 | yAxis: 0, 279 | shape: { 280 | type: types[i], 281 | params: params[i] 282 | } 283 | }, 284 | symbol: { 285 | shape: s, 286 | size: 12, 287 | style: { 288 | 'stroke-width': 2, 289 | 'stroke': 'black', 290 | fill: 'red', 291 | zIndex: 121 292 | } 293 | }, 294 | style: { 295 | fill: 'black', 296 | stroke: 'blue', 297 | strokeWidth: 2 298 | }, 299 | size: 12, 300 | states: { 301 | selected: { 302 | fill: '#9BD' 303 | }, 304 | hover: { 305 | fill: '#9BD' 306 | } 307 | } 308 | }); 309 | }); 310 | 311 | return { 312 | enabledButtons: true, 313 | buttons: buttons, 314 | buttonsOffsets: [0, 0] 315 | }; 316 | } 317 | 318 | function isArray(obj) { 319 | return Object.prototype.toString.call(obj) === '[object Array]'; 320 | } 321 | 322 | function isNumber(n) { 323 | return typeof n === 'number'; 324 | } 325 | 326 | function defined(obj) { 327 | return obj !== UNDEFINED && obj !== null; 328 | } 329 | 330 | function translatePath(d, xAxis, yAxis, xOffset, yOffset) { 331 | var len = d.length, 332 | i = 0, 333 | path = []; 334 | 335 | while (i < len) { 336 | if (typeof d[i] === 'number' && typeof d[i + 1] === 'number') { 337 | path[i] = xAxis.toPixels(d[i]) - xOffset; 338 | path[i + 1] = yAxis.toPixels(d[i + 1]) - yOffset; 339 | i += 2; 340 | } else { 341 | path[i] = d[i]; 342 | i += 1; 343 | } 344 | } 345 | 346 | return path; 347 | } 348 | 349 | function createGroup(chart, i, clipPath) { 350 | var group = chart.renderer.g('annotations-group-' + i); 351 | group.attr({ 352 | zIndex: 7 353 | }); 354 | group.add(); 355 | group.clip(clipPath); 356 | return group; 357 | } 358 | 359 | function createClipPath(chart, y) { 360 | var clipBox = { 361 | x: y.left, 362 | y: y.top, 363 | width: y.width, 364 | height: y.height 365 | }; 366 | 367 | return chart.renderer.clipRect(clipBox); 368 | } 369 | 370 | function attachEvents(chart) { 371 | function step(e) { 372 | var selected = chart.annotations.selected; 373 | chart.annotations.options.buttons[selected].annotationEvents.step.call(chart.drawAnnotation, e); 374 | } 375 | function drag(e) { 376 | var bbox = chart.container.getBoundingClientRect(), 377 | clickX = e.clientX - bbox.left, 378 | clickY = e.clientY - bbox.top; 379 | 380 | if (!chart.isInsidePlot(clickX - chart.plotLeft, clickY - chart.plotTop) || chart.annotations.allowZoom) { 381 | return; 382 | } 383 | 384 | var xAxis = chart.xAxis[0], 385 | yAxis = chart.yAxis[0], 386 | selected = chart.annotations.selected; 387 | 388 | var options = merge(chart.annotations.options.buttons[selected].annotation, { 389 | xValue: xAxis.toValue(clickX), 390 | yValue: yAxis.toValue(clickY), 391 | allowDragX: true, 392 | allowDragY: true 393 | }); 394 | 395 | chart.addAnnotation(options); 396 | 397 | chart.drawAnnotation = chart.annotations.allItems[chart.annotations.allItems.length - 1]; 398 | addEvent(document, 'mousemove', step); 399 | } 400 | 401 | function drop(e) { 402 | removeEvent(document, 'mousemove', step); 403 | 404 | // store annotation details 405 | if (chart.drawAnnotation) { 406 | var selected = chart.annotations.selected; 407 | chart.annotations.options.buttons[selected].annotationEvents.stop.call(chart.drawAnnotation, e); 408 | } 409 | chart.drawAnnotation = null; 410 | } 411 | addEvent(chart.container, 'mousedown', drag); 412 | addEvent(document, 'mouseup', drop); 413 | } 414 | 415 | function getButtonCallback(index, chart) { 416 | return function () { 417 | var self = chart.annotations.buttons[index][0]; 418 | if (self.state === 2) { 419 | chart.annotations.selected = -1; 420 | chart.annotations.allowZoom = true; 421 | self.setState(0); 422 | } else { 423 | if (chart.annotations.selected >= 0) { 424 | chart.annotations.buttons[chart.annotations.selected][0].setState(0); 425 | } 426 | chart.annotations.allowZoom = false; 427 | chart.annotations.selected = index; 428 | self.setState(2); 429 | } 430 | }; 431 | } 432 | 433 | 434 | function renderButton(chart, mainButton, i) { 435 | var userOffset = chart.annotations.options.buttonsOffsets, 436 | xOffset = chart.rangeSelector && chart.rangeSelector.inputGroup ? chart.rangeSelector.inputGroup.offset : 0, 437 | renderer = chart.renderer, 438 | symbol = mainButton.symbol, 439 | offset = 30, 440 | symbolSize = symbol.size, 441 | padding = 8 / 2, // since Highcahrts 5.0, padding = 8 is hardcoded 442 | buttonSize = mainButton.size - padding, 443 | x = chart.plotWidth + chart.plotLeft - ((i + 1) * offset) - xOffset - userOffset[0], 444 | y = chart.plotTop - (chart.rangeSelector ? 23 + buttonSize + padding : 0) + userOffset[1], 445 | callback = mainButton.events && mainButton.events.click ? mainButton.events.click : getButtonCallback(i, chart), 446 | selected = mainButton.states.selected, 447 | hovered = mainButton.states.hover, 448 | button, 449 | s; 450 | 451 | button = renderer.button('', x, y, callback, {}, hovered, selected).attr({ width: buttonSize, height: buttonSize, zIndex: 10 }); 452 | s = renderer.symbol( 453 | symbol.shape, 454 | buttonSize - symbolSize / 2 + padding, 455 | buttonSize - symbolSize / 2 + padding, 456 | symbolSize, 457 | symbolSize 458 | ).attr(symbol.style).add(button); 459 | 460 | button.attr(button.style).add(); 461 | 462 | return [button, s]; 463 | } 464 | 465 | function renderButtons(chart) { 466 | var buttons = chart.annotations.options.buttons; 467 | 468 | chart.annotations.buttons = chart.annotations.buttons || []; 469 | each(buttons, function (button, i) { 470 | chart.annotations.buttons.push(renderButton(chart, button, i)); 471 | }); 472 | } 473 | 474 | // Define annotation prototype 475 | var Annotation = function () { // eslint-disable-line 476 | this.init.apply(this, arguments); 477 | }; 478 | 479 | Annotation.prototype = { 480 | /* 481 | * Initialize the annotation 482 | */ 483 | init: function (chart, options) { 484 | var shapeType = options.shape && options.shape.type; 485 | 486 | this.chart = chart; 487 | this.options = merge({}, defaultOptions(shapeType), options); 488 | this.userOptions = options; 489 | }, 490 | 491 | /* 492 | * Render the annotation 493 | */ 494 | render: function (redraw) { 495 | var annotation = this, 496 | chart = this.chart, 497 | renderer = annotation.chart.renderer, 498 | group = annotation.group, 499 | title = annotation.title, 500 | shape = annotation.shape, 501 | options = annotation.options, 502 | titleOptions = options.title, 503 | shapeOptions = options.shape, 504 | allowDragX = options.allowDragX, 505 | allowDragY = options.allowDragY, 506 | hasEvents = annotation.hasEvents; 507 | 508 | function attachCustomEvents(element, events) { 509 | if (defined(events)) { 510 | for (var name in events) { // eslint-disable-line 511 | (function (n) { 512 | addEvent(element.element, n, function (e) { 513 | events[n].call(annotation, e); 514 | }); 515 | })(name); 516 | } 517 | } 518 | } 519 | 520 | if (!group) { 521 | group = annotation.group = renderer.g(); 522 | group.attr({ 'class': 'highcharts-annotation' }); 523 | } 524 | 525 | if (!shape && shapeOptions && inArray(shapeOptions.type, H.ALLOWED_SHAPES) !== -1) { 526 | shape = annotation.shape = shapeOptions.type === 'rect' ? renderer[options.shape.type]().attr(shapeOptions.params) : renderer[options.shape.type](shapeOptions.params); 527 | shape.add(group); 528 | } 529 | 530 | if (!title && titleOptions) { 531 | title = annotation.title = renderer.label(titleOptions); 532 | title.add(group); 533 | } 534 | if ((allowDragX || allowDragY) && !hasEvents) { 535 | $(group.element).on('mousedown', function (e) { 536 | annotation.events.storeAnnotation(e, annotation, chart); 537 | annotation.events.select(e, annotation); 538 | }); 539 | addEvent(document, 'mouseup', function (e) { 540 | annotation.events.releaseAnnotation(e, chart); 541 | }); 542 | 543 | attachCustomEvents(group, options.events); 544 | } else if (!hasEvents) { 545 | $(group.element).on('mousedown', function (e) { 546 | annotation.events.select(e, annotation); 547 | }); 548 | attachCustomEvents(group, options.events); 549 | } 550 | 551 | this.hasEvents = true; 552 | 553 | group.add(chart.annotations.groups[options.yAxis]); 554 | 555 | // link annotations to point or series 556 | annotation.linkObjects(); 557 | 558 | if (redraw !== false) { 559 | annotation.redraw(); 560 | } 561 | }, 562 | 563 | /* 564 | * Redraw the annotation title or shape after options update 565 | */ 566 | redraw: function (redraw) { 567 | var options = this.options, 568 | chart = this.chart, 569 | group = this.group, 570 | title = this.title, 571 | shape = this.shape, 572 | linkedTo = this.linkedObject, 573 | xAxis = chart.xAxis[options.xAxis], 574 | yAxis = chart.yAxis[options.yAxis], 575 | width = options.width, 576 | height = options.height, 577 | anchorY = ALIGN_FACTOR[options.anchorY], 578 | anchorX = ALIGN_FACTOR[options.anchorX], 579 | shapeParams, 580 | linkType, 581 | series, 582 | bbox, 583 | x, 584 | y; 585 | 586 | if (linkedTo) { 587 | linkType = (linkedTo instanceof H.Point) ? 'point' : (linkedTo instanceof H.Series) ? 'series' : null; 588 | 589 | if (linkType === 'point') { 590 | options.x = linkedTo.plotX + chart.plotLeft; 591 | options.y = linkedTo.plotY + chart.plotTop; 592 | series = linkedTo.series; 593 | } else if (linkType === 'series') { 594 | series = linkedTo; 595 | } 596 | 597 | // #48 - series.grouping and series.stacking may reposition point.graphic 598 | if (series.pointXOffset) { 599 | options.x += series.pointXOffset + (linkedTo.shapeArgs.width / 2 || 0); 600 | } 601 | group.attr({ 602 | visibility: series.group.attr('visibility') 603 | }); 604 | } 605 | 606 | 607 | // Based on given options find annotation pixel position 608 | // what is minPointOffset? Doesn't work in 4.0+ 609 | x = (defined(options.xValue) ? xAxis.toPixels(options.xValue /* + xAxis.minPointOffset */) : options.x); 610 | y = defined(options.yValue) ? yAxis.toPixels(options.yValue) : options.y; 611 | if (chart.inverted && defined(options.xValue) && defined(options.yValue)) { 612 | var tmp = x; x = y; y = tmp; 613 | } 614 | 615 | if (isNaN(x) || isNaN(y) || !isNumber(x) || !isNumber(y)) { 616 | return; 617 | } 618 | 619 | 620 | if (title) { 621 | var attrs = options.title; 622 | if (isOldIE) { 623 | title.attr({ 624 | text: attrs.text 625 | }); 626 | } else { 627 | title.attr(attrs); 628 | } 629 | title.css(options.title.style); 630 | } 631 | 632 | if (shape) { 633 | shapeParams = extend({}, options.shape.params); 634 | if (options.shape.units === 'values') { 635 | var realXAxis = chart.inverted ? yAxis : xAxis; 636 | var realYAxis = chart.inverted ? xAxis : yAxis; 637 | 638 | // For ordinal axis, required are x&Y values - #22 639 | if (defined(shapeParams.x) && shapeParams.width) { 640 | shapeParams.width = xAxis.toPixels(shapeParams.width + shapeParams.x) - xAxis.toPixels(shapeParams.x); 641 | shapeParams.x = xAxis.toPixels(shapeParams.x); 642 | } else if (shapeParams.width) { 643 | shapeParams.width = realXAxis.toPixels(shapeParams.width) - realXAxis.toPixels(0); 644 | } else if (defined(shapeParams.x)) { 645 | shapeParams.x = xAxis.toPixels(shapeParams.x); 646 | } 647 | 648 | if (defined(shapeParams.y) && shapeParams.height) { 649 | shapeParams.height = -yAxis.toPixels(shapeParams.height + shapeParams.y) + yAxis.toPixels(shapeParams.y); 650 | shapeParams.y = yAxis.toPixels(shapeParams.y); 651 | } else if (shapeParams.height) { 652 | shapeParams.height = -realYAxis.toPixels(shapeParams.height) + realYAxis.toPixels(0); 653 | shapeParams.height *= chart.inverted ? -1 : 1; 654 | } else if (defined(shapeParams.y)) { 655 | shapeParams.y = yAxis.toPixels(shapeParams.y); 656 | } 657 | 658 | if (options.shape.type === 'path') { 659 | shapeParams.d = translatePath(shapeParams.d, xAxis, yAxis, x, y); 660 | } 661 | } 662 | if (defined(options.yValueEnd) && defined(options.xValueEnd)) { 663 | shapeParams.d = shapeParams.d || options.shape.d || ['M', 0, 0, 'L', 0, 0]; 664 | shapeParams.d[4] = xAxis.toPixels(options.xValueEnd) - xAxis.toPixels(options.xValue); 665 | shapeParams.d[5] = yAxis.toPixels(options.yValueEnd) - yAxis.toPixels(options.yValue); 666 | } 667 | 668 | // move the center of the circle to shape x/y 669 | if (options.shape.type === 'circle') { 670 | shapeParams.x += shapeParams.r; 671 | shapeParams.y += shapeParams.r; 672 | } 673 | shape.attr(shapeParams); 674 | } 675 | 676 | group.bBox = null; 677 | 678 | // If annotation width or height is not defined in options use bounding box size 679 | if (!isNumber(width)) { 680 | bbox = group.getBBox(); 681 | width = bbox.width; 682 | } 683 | 684 | if (!isNumber(height)) { 685 | // get bbox only if it wasn't set before 686 | if (!bbox) { 687 | bbox = group.getBBox(); 688 | } 689 | 690 | height = bbox.height; 691 | } 692 | // Calculate anchor point 693 | if (!isNumber(anchorX)) { 694 | anchorX = ALIGN_FACTOR.center; 695 | } 696 | 697 | if (!isNumber(anchorY)) { 698 | anchorY = ALIGN_FACTOR.center; 699 | } 700 | 701 | // Translate group according to its dimension and anchor point 702 | x = x - width * anchorX; 703 | y = y - height * anchorY; 704 | 705 | if (this.selectionMarker) { 706 | this.events.select({}, this); 707 | } 708 | 709 | if (redraw && chart.animation && defined(group.translateX) && defined(group.translateY)) { 710 | group.animate({ 711 | translateX: x, 712 | translateY: y 713 | }); 714 | } else { 715 | group.translate(x, y); 716 | } 717 | }, 718 | 719 | /* 720 | * Destroy the annotation 721 | */ 722 | destroy: function () { 723 | var annotation = this, 724 | chart = this.chart, 725 | allItems = chart.annotations.allItems, 726 | index = allItems.indexOf(annotation); 727 | 728 | chart.activeAnnotation = null; 729 | 730 | if (index > -1) { 731 | allItems.splice(index, 1); 732 | chart.options.annotations.splice(index, 1); // #33 733 | } 734 | 735 | each(['title', 'shape', 'group'], function (element) { 736 | if (annotation[element] && annotation[element].destroy) { 737 | annotation[element].destroy(); 738 | annotation[element] = null; 739 | } else if (annotation[element]) { 740 | annotation[element].remove(); 741 | annotation[element] = null; 742 | } 743 | }); 744 | 745 | annotation.group = annotation.title = annotation.shape = annotation.chart = annotation.options = annotation.hasEvents = null; 746 | }, 747 | 748 | /* 749 | * Show annotation, only for non-linked annotations 750 | */ 751 | show: function () { 752 | if (!this.linkedObject) { 753 | this.visible = true; 754 | this.group.attr({ 755 | visibility: 'visible' 756 | }); 757 | } 758 | }, 759 | 760 | /* 761 | * Hide annotation, only for non-linked annotations 762 | */ 763 | hide: function () { 764 | if (!this.linkedObject) { 765 | this.visible = false; 766 | this.group.attr({ 767 | visibility: 'hidden' 768 | }); 769 | } 770 | }, 771 | 772 | /* 773 | * Update the annotation with a given options 774 | */ 775 | update: function (options, redraw) { 776 | var annotation = this, 777 | chart = this.chart, 778 | allItems = chart.annotations.allItems, 779 | index = allItems.indexOf(annotation), 780 | o = merge(this.options, options); 781 | 782 | if (index >= 0) { 783 | chart.options.annotations[index] = o; // #33 784 | } 785 | 786 | this.options = o; 787 | 788 | // update link to point or series 789 | this.linkObjects(); 790 | 791 | this.render(redraw); 792 | return this; 793 | }, 794 | /* 795 | * API select & deselect: 796 | */ 797 | select: function () { 798 | this.events.select(null, this); 799 | return this; 800 | }, 801 | deselect: function () { 802 | this.events.deselect(null, this); 803 | this.chart.selectedAnnotation = null; 804 | return this; 805 | }, 806 | 807 | 808 | linkObjects: function () { 809 | var annotation = this, 810 | chart = annotation.chart, 811 | linkedTo = annotation.linkedObject, 812 | linkedId = linkedTo && (linkedTo.id || linkedTo.options.id), 813 | options = annotation.options, 814 | id = options.linkedTo; 815 | 816 | if (!defined(id)) { 817 | annotation.linkedObject = null; 818 | } else if (!defined(linkedTo) || id !== linkedId) { 819 | annotation.linkedObject = chart.get(id); 820 | } 821 | }, 822 | events: { 823 | select: function (e, ann) { 824 | var chart = ann.chart, 825 | prevAnn = chart.selectedAnnotation, 826 | box, 827 | padding = 10; 828 | 829 | if (prevAnn && prevAnn !== ann) { 830 | prevAnn.deselect(); 831 | } 832 | 833 | if (!ann.selectionMarker) { 834 | box = ann.group.getBBox(); 835 | 836 | ann.selectionMarker = chart.renderer.rect( 837 | box.x - padding / 2, 838 | box.y - padding / 2, 839 | box.width + padding, 840 | box.height + padding 841 | ).attr(ann.options.selectionMarker); 842 | ann.selectionMarker.add(ann.group); 843 | } 844 | chart.selectedAnnotation = ann; 845 | }, 846 | deselect: function () { 847 | if (this.selectionMarker && this.group) { 848 | this.selectionMarker.destroy(); 849 | this.selectionMarker = false; 850 | this.group.bBox = null; 851 | } 852 | }, 853 | destroyAnnotation: function (event, annotation) { 854 | annotation.destroy(); 855 | }, 856 | translateAnnotation: function (event, chart) { 857 | event.stopPropagation(); 858 | event.preventDefault(); 859 | if (chart.activeAnnotation) { 860 | var bbox = chart.container.getBoundingClientRect(), 861 | clickX = event.clientX - bbox.left, 862 | clickY = event.clientY - bbox.top; 863 | 864 | if (!chart.isInsidePlot(clickX - chart.plotLeft, clickY - chart.plotTop)) { 865 | return; 866 | } 867 | var note = chart.activeAnnotation; 868 | 869 | var x = note.options.allowDragX ? event.clientX - note.startX + note.group.translateX : note.group.translateX, 870 | y = note.options.allowDragY ? event.clientY - note.startY + note.group.translateY : note.group.translateY; 871 | 872 | note.transX = x; 873 | note.transY = y; 874 | note.group.attr({ 875 | transform: 'translate(' + x + ',' + y + ')' 876 | }); 877 | note.hadMove = true; 878 | } 879 | }, 880 | storeAnnotation: function (event, annotation, chart) { 881 | if (!chart.annotationDraging) { 882 | event.stopPropagation(); 883 | event.preventDefault(); 884 | } 885 | if ((!isOldIE && event.button === 0) || (isOldIE && event.button === 1)) { 886 | var posX = event.clientX, 887 | posY = event.clientY; 888 | chart.activeAnnotation = annotation; 889 | chart.activeAnnotation.startX = posX; 890 | chart.activeAnnotation.startY = posY; 891 | chart.activeAnnotation.transX = 0; 892 | chart.activeAnnotation.transY = 0; 893 | // translateAnnotation(event); 894 | addEvent(document, 'mousemove', function (e) { 895 | annotation.events.translateAnnotation(e, chart); 896 | }); 897 | // addEvent(chart.container, 'mouseleave', releaseAnnotation); TO BE OR NOT TO BE? 898 | } 899 | }, 900 | releaseAnnotation: function (event, chart) { 901 | event.stopPropagation(); 902 | event.preventDefault(); 903 | if (chart.activeAnnotation && (chart.activeAnnotation.transX !== 0 || chart.activeAnnotation.transY !== 0)) { 904 | var note = chart.activeAnnotation, 905 | x = note.transX, 906 | y = note.transY, 907 | options = note.options, 908 | xVal = options.xValue, 909 | yVal = options.yValue, 910 | xValEnd = options.xValueEnd, 911 | yValEnd = options.yValueEnd, 912 | allowDragX = options.allowDragX, 913 | allowDragY = options.allowDragY, 914 | xAxis = note.chart.xAxis[note.options.xAxis], 915 | yAxis = note.chart.yAxis[note.options.yAxis], 916 | newX = xAxis.toValue(x), 917 | newY = yAxis.toValue(y); 918 | 919 | if (x !== 0 || y !== 0) { 920 | if (allowDragX && allowDragY) { 921 | note.update({ 922 | xValue: defined(xVal) ? newX : null, 923 | yValue: defined(yVal) ? newY : null, 924 | xValueEnd: defined(xValEnd) ? xValEnd - xVal + newX : null, 925 | yValueEnd: defined(yValEnd) ? yValEnd - yVal + newY : null, 926 | x: defined(xVal) ? null : x, 927 | y: defined(yVal) ? null : y 928 | }, false); 929 | } else if (allowDragX) { 930 | note.update({ 931 | xValue: defined(xVal) ? newX : null, 932 | yValue: defined(yVal) ? yVal : null, 933 | xValueEnd: defined(xValEnd) ? xValEnd - xVal + newX : null, 934 | yValueEnd: defined(yValEnd) ? yValEnd : null, 935 | x: defined(xVal) ? null : x, 936 | y: defined(yVal) ? null : note.options.y 937 | }, false); 938 | } else if (allowDragY) { 939 | note.update({ 940 | xValue: defined(xVal) ? xVal : null, 941 | yValue: defined(yVal) ? newY : null, 942 | xValueEnd: defined(xValEnd) ? xValEnd : null, 943 | yValueEnd: defined(yValEnd) ? yValEnd - yVal + newY : null, 944 | x: defined(xVal) ? null : note.options.x, 945 | y: defined(yVal) ? null : y 946 | }, false); 947 | } 948 | } 949 | chart.activeAnnotation = null; 950 | chart.redraw(false); 951 | } else { 952 | chart.activeAnnotation = null; 953 | } 954 | } 955 | } 956 | }; 957 | // Add annotations methods to chart prototype 958 | extend(Chart.prototype, { 959 | /* 960 | * Unified method for adding annotations to the chart 961 | */ 962 | addAnnotation: function (options, redraw) { 963 | var chart = this, 964 | annotations = chart.annotations.allItems, 965 | item, 966 | i, 967 | iter, 968 | len; 969 | 970 | if (!isArray(options)) { 971 | options = [options]; 972 | } 973 | 974 | len = options.length; 975 | 976 | for (iter = 0; iter < len; iter++) { 977 | item = new Annotation(chart, options[iter]); 978 | i = annotations.push(item); 979 | if (i > chart.options.annotations.length) { 980 | chart.options.annotations.push(options[iter]); // #33 981 | } 982 | item.render(redraw); 983 | } 984 | }, 985 | 986 | /* 987 | * Redraw all annotations, method used in chart events 988 | */ 989 | redrawAnnotations: function () { 990 | var chart = this, 991 | yAxes = chart.yAxis, 992 | yLen = yAxes.length, 993 | ann = chart.annotations, 994 | userOffset = ann.options.buttonsOffsets, 995 | i = 0, 996 | clip, y; 997 | 998 | 999 | for (; i < yLen; i++) { 1000 | y = yAxes[i]; 1001 | clip = ann.clipPaths[i]; 1002 | 1003 | if (clip) { 1004 | clip.attr({ 1005 | x: y.left, 1006 | y: y.top, 1007 | width: y.width, 1008 | height: y.height 1009 | }); 1010 | } else { 1011 | var clipPath = createClipPath(chart, y); 1012 | ann.clipPaths.push(clipPath); 1013 | ann.groups.push(createGroup(chart, i, clipPath)); 1014 | } 1015 | } 1016 | 1017 | each(chart.annotations.allItems, function (annotation) { 1018 | annotation.redraw(); 1019 | }); 1020 | each(chart.annotations.buttons, function (button, j) { 1021 | var xOffset = chart.rangeSelector && chart.rangeSelector.inputGroup ? chart.rangeSelector.inputGroup.offset : 0, 1022 | x = chart.plotWidth + chart.plotLeft - ((j + 1) * 30) - xOffset - userOffset[0]; 1023 | button[0].attr({ 1024 | x: x 1025 | }); 1026 | }); 1027 | } 1028 | }); 1029 | 1030 | 1031 | // Initialize on chart load 1032 | Chart.prototype.callbacks.push(function (chart) { 1033 | var options = chart.options.annotations, 1034 | yAxes = chart.yAxis, 1035 | yLen = yAxes.length, 1036 | clipPaths = [], 1037 | groups = [], 1038 | i = 0, 1039 | y, c; 1040 | 1041 | for (; i < yLen; i++) { 1042 | y = yAxes[i]; 1043 | c = createClipPath(chart, y); 1044 | clipPaths.push(c); 1045 | groups.push(createGroup(chart, i, c)); 1046 | } 1047 | 1048 | if (!chart.annotations) { 1049 | chart.annotations = {}; 1050 | } 1051 | 1052 | if (!chart.options.annotations) { 1053 | chart.options.annotations = []; 1054 | } 1055 | 1056 | // initialize empty array for annotations 1057 | if (!chart.annotations.allItems) { 1058 | chart.annotations.allItems = []; 1059 | } 1060 | 1061 | // allow zoom or draw annotation 1062 | chart.annotations.allowZoom = true; 1063 | 1064 | // link chart object to annotations 1065 | chart.annotations.chart = chart; 1066 | 1067 | // link annotations group element to the chart 1068 | chart.annotations.groups = groups; 1069 | 1070 | // add clip path to annotations 1071 | chart.annotations.clipPaths = clipPaths; 1072 | 1073 | if (isArray(options) && options.length > 0) { 1074 | chart.addAnnotation(chart.options.annotations); 1075 | } 1076 | chart.annotations.options = merge(defatultMainOptions(), chart.options.annotationsOptions ? chart.options.annotationsOptions : {}); 1077 | 1078 | if (chart.annotations.options.enabledButtons) { 1079 | renderButtons(chart); 1080 | attachEvents(chart); 1081 | } else { 1082 | chart.annotations.buttons = []; 1083 | } 1084 | 1085 | // update annotations after chart redraw 1086 | addEvent(chart, 'redraw', function () { 1087 | chart.redrawAnnotations(); 1088 | }); 1089 | }); 1090 | 1091 | if (!Array.prototype.indexOf) { 1092 | Array.prototype.indexOf = function (searchElement) { // eslint-disable-line 1093 | if (this === null) { 1094 | throw new TypeError(); 1095 | } 1096 | var t = Object(this); 1097 | var len = t.length >>> 0; 1098 | if (len === 0) { 1099 | return -1; 1100 | } 1101 | var n = 0; 1102 | if (arguments.length > 1) { 1103 | n = Number(arguments[1]); 1104 | if (n !== n) { // shortcut for verifying if it's NaN 1105 | n = 0; 1106 | } else if (n !== 0 && n !== Infinity && n !== -Infinity) { 1107 | n = (n > 0 || -1) * Math.floor(Math.abs(n)); 1108 | } 1109 | } 1110 | if (n >= len) { 1111 | return -1; 1112 | } 1113 | var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); 1114 | for (; k < len; k++) { 1115 | if (k in t && t[k] === searchElement) { 1116 | return k; 1117 | } 1118 | } 1119 | return -1; 1120 | }; 1121 | } 1122 | })); -------------------------------------------------------------------------------- /js/demo.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | var options = { 3 | chart: { 4 | renderTo: 'container', 5 | marginTop: 50 6 | }, 7 | xAxis: { 8 | min: 0, 9 | max: 10 10 | }, 11 | title: { 12 | useHTML: true, 13 | x: -10, 14 | y: 8, 15 | text: ' Drag and drop on a chart to add annotation Black Label plugin by ' 16 | }, 17 | annotations: [{ 18 | title: { 19 | text: 'drag me anywhere
dblclick to remove
', 20 | style: { 21 | color: 'red' 22 | } 23 | }, 24 | anchorX: "left", 25 | anchorY: "top", 26 | allowDragX: true, 27 | allowDragY: true, 28 | x: 515, 29 | y: 155 30 | }, { 31 | title: 'drag me
horizontaly', 32 | anchorX: "left", 33 | anchorY: "top", 34 | allowDragY: false, 35 | allowDragX: true, 36 | xValue: 4, 37 | yValue: 10, 38 | shape: { 39 | type: 'path', 40 | params: { 41 | d: ['M', 0, 0, 'L', 110, 0], 42 | stroke: '#c55' 43 | } 44 | } 45 | }, { 46 | title: 'on point
drag&drop
disabled', 47 | linkedTo: 'high', 48 | allowDragY: false, 49 | allowDragX: false, 50 | anchorX: "center", 51 | anchorY: "center", 52 | shape: { 53 | type: 'circle', 54 | params: { 55 | r: 40, 56 | stroke: '#c55' 57 | } 58 | } 59 | }, { 60 | x: 100, 61 | y: 200, 62 | title: 'drag me
verticaly', 63 | anchorX: "left", 64 | anchorY: "top", 65 | allowDragY: true, 66 | allowDragX: false, 67 | shape: { 68 | type: 'rect', 69 | params: { 70 | x: 0, 71 | y: 0, 72 | width: 55, 73 | height: 40 74 | } 75 | } 76 | }], 77 | series: [{ 78 | data: [13, 4, 5, { 79 | y: 1, 80 | id: 'high' 81 | }, 82 | 2, 1, 3, 2, 11, 6, 5, 13, 6, 9, 11, 2, 3, 7, 9, 11] 83 | }] 84 | }; 85 | 86 | var chart = new Highcharts.StockChart(options); 87 | }); -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 2 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 3 | 1. Definitions 4 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 5 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 6 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; to Distribute and Publicly Perform the Work including as incorporated in Collections; and, to Distribute and Publicly Perform Adaptations. For the avoidance of doubt: 7 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 8 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 9 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 5. Representations, Warranties and Disclaimer 10 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 11 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 12 | 7. Termination 13 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 8. Miscellaneous 14 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 15 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Annotations", 3 | "version": "1.3.3", 4 | "title": "Annotations", 5 | "author": { 6 | "name": "Black Label", 7 | "url": "http://www.blacklabel.pl/" 8 | }, 9 | "licenses": [ 10 | { 11 | "type": "Creative Commons Attribution (CC)", 12 | "url": "https://github.com/blacklabel/annotations/blob/master/license.txt" 13 | } 14 | ], 15 | "dependencies": { 16 | "highcharts": "3.0.7+" 17 | }, 18 | "demo": [ 19 | "https://jsfiddle.net/BlackLabel/7m3Mr/", 20 | "https://jsfiddle.net/BlackLabel/N6GR9/" 21 | ], 22 | "description": "Plugin that add annotations to Highcharts library. Advanced demo is available on the github: http://blacklabel.github.io/annotations/", 23 | "keywords": [ 24 | "annotations", 25 | "highcharts", 26 | "highstock", 27 | "highcharts-addon" 28 | ], 29 | "maintainers": [ 30 | { 31 | "name": "Sebastian Bochan", 32 | "email": "sebastian2@blacklabel.pl", 33 | "url": "http://www.blacklabel.pl" 34 | },{ 35 | "name": "Paweł Fus", 36 | "email": "pawel@blacklabel.pl", 37 | "url": "http://www.blacklabel.pl" 38 | } 39 | ], 40 | "homepage": "http://blacklabel.github.io/annotations/", 41 | "docs": "https://github.com/blacklabel/annotations/", 42 | "bugs": "https://github.com/blacklabel/annotations/issues", 43 | "download": "https://github.com/blacklabel/annotations/archive/master.zip" 44 | } 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "highcharts-annotations", 3 | "version": "1.3.3", 4 | "description": "Highcharts plugin to add dynamic annotations to charts.", 5 | "main": "js/annotations.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/blacklabel/annotations.git" 9 | }, 10 | "keywords": [ 11 | "annotations", 12 | "highcharts", 13 | "highstock", 14 | "highcharts-addon" 15 | ], 16 | "author": "Black Label (http://blacklabel.pl)", 17 | "license": "SEE LICENSE IN license.txt", 18 | "bugs": { 19 | "url": "https://github.com/blacklabel/annotations/issues" 20 | }, 21 | "homepage": "https://github.com/blacklabel/annotations#readme", 22 | "files": [ 23 | "js/annotations.js" 24 | ], 25 | "devDependencies": { 26 | "gulp": "^3.9.1", 27 | "gulp-eslint": "^2.0.0" 28 | } 29 | } 30 | --------------------------------------------------------------------------------