|
1 |
| -; |
| 1 | +//jquery.flot.comments.js |
| 2 | +//======================= |
| 3 | +// Copyright (c) 2013 http://zizhujy.com. |
| 4 | +// |
| 5 | +//Flot plugin that shows extra comments to the flot chart. There are several types of comments: |
| 6 | +// - **tooltip**: Show the data point value (x, y) when mouse over a data point; |
| 7 | +//- **comment**: A callout style textbox that always shows at the specified position; |
| 8 | +//- **sidenote**: Texts that shows at the right side of the chart that only associated with the |
| 9 | +// y-axis coordinate. |
| 10 | +// |
| 11 | +// **Usage:** |
| 12 | +// |
| 13 | +//Inside the `<head></head>` area of your html page, add the following lines: |
| 14 | +// |
| 15 | +//```html |
| 16 | +//<script type="text/javascript" src="http://zizhujy.com/Scripts/flot/jquery.flot.comment.js"></script> |
| 17 | +//``` |
| 18 | +// |
| 19 | +//pass your comments, sidenotes to the options object when you draw the flot chart by $.plot(): |
| 20 | +// |
| 21 | +//```javascript |
| 22 | +//var options = { |
| 23 | +// comment: { |
| 24 | +// show: true |
| 25 | +// }, |
| 26 | +// comments: [ |
| 27 | +// { |
| 28 | +// x: -2, |
| 29 | +// y: 1, |
| 30 | +// contents: "this point 1" |
| 31 | +// }, |
| 32 | +// ... |
| 33 | +// ], |
| 34 | +// sidenote: { |
| 35 | +// show: true |
| 36 | +// }, |
| 37 | +// sidenotes: [ |
| 38 | +// { |
| 39 | +// y: -4, |
| 40 | +// contents: "Low Level", |
| 41 | +// offsetX: 0, |
| 42 | +// offsetY: 0, |
| 43 | +// maxWidth: 0.15 |
| 44 | +// }, |
| 45 | +// ... |
| 46 | +// ] |
| 47 | +//}; |
| 48 | +// |
| 49 | +//$.plot("#canvas-wrapper", data, options); |
| 50 | +//``` |
| 51 | +// |
| 52 | +//**Online examples:** |
| 53 | +// |
| 54 | +//- [Comment Example](examples/CommentExample.html "Comment Example") |
| 55 | +// |
| 56 | +//**Dependencies:** |
| 57 | +// |
| 58 | +//- jquery.js |
| 59 | +//- jquery.colorhelpers.js |
| 60 | +//- jquery.flot.js |
| 61 | +// |
| 62 | +//**Customizations:** |
| 63 | +// |
| 64 | +//```javascript |
| 65 | +//options{ |
| 66 | +// comment: { |
| 67 | +// "class": "jquery-flot-comment", |
| 68 | +// wrapperCss: { |
| 69 | +// "position": "absolute", |
| 70 | +// "display": "block", |
| 71 | +// "margin": "0", |
| 72 | +// "line-height": "1em", |
| 73 | +// "background-color": "transparent", |
| 74 | +// "color": "white", |
| 75 | +// "padding": "0", |
| 76 | +// "font-size": "xx-small", |
| 77 | +// "box-sizing": "border-box", |
| 78 | +// "text-align": "center" |
| 79 | +// }, |
| 80 | +// notch: { |
| 81 | +// size: "5px" |
| 82 | +// }, |
| 83 | +// htmlTemplate: function() { |
| 84 | +// return "<div class='{1}'><div class='callout' style='position: relative; margin: 0; padding: 0; background-color: #000; width: 1%\0 /* IE 8 width hack */; box-sizing: border-box; padding: 5px;'><div style='line-height: 1em; position: relative;'>{{0}}</div><b class='notch' style='position: absolute; bottom: -{0}; left: 50%; margin: 0 0 0 -{0}; border-top: {0} solid #000; border-left: {0} solid transparent; border-right: {0} solid transparent; border-bottom: 0; padding: 0; width: 0; height: 0; font-size: 0; line-height: 0; _border-right-color: pink; _border-left-color: pink; _filter: chroma(color=pink);'></b></div></div>".format(this.notch.size, this.class); |
| 85 | +// }, |
| 86 | +// show: true, |
| 87 | +// position: { |
| 88 | +// offsetX: 0, |
| 89 | +// offsetY: 0, |
| 90 | +// x: function (x) { |
| 91 | +// return { |
| 92 | +// "left": x + parseFloat(this.offsetX || 0) |
| 93 | +// }; |
| 94 | +// }, |
| 95 | +// y: function (y) { |
| 96 | +// return { |
| 97 | +// "top": y + parseFloat(this.offsetY || 0) |
| 98 | +// }; |
| 99 | +// } |
| 100 | +// } |
| 101 | +// }, |
| 102 | +// sidenote: { |
| 103 | +// "class": "jquery-flot-sidenote", |
| 104 | +// wrapperCss: { |
| 105 | +// "position": "absolute", |
| 106 | +// "display": "block", |
| 107 | +// "line-height": "1.1em", |
| 108 | +// "margin": "0", |
| 109 | +// "font-size": "smaller" |
| 110 | +// }, |
| 111 | +// maxWidth: 0.2, /* Width percentage of the whole chart width */ |
| 112 | +// show: true, |
| 113 | +// position: { |
| 114 | +// offsetX: "5px", |
| 115 | +// offsetY: 0, |
| 116 | +// x: function(x) { |
| 117 | +// return { |
| 118 | +// "left": x + parseFloat(this.offsetX || 0) |
| 119 | +// }; |
| 120 | +// }, |
| 121 | +// y: function(y) { |
| 122 | +// return { |
| 123 | +// "top": y + parseFloat(this.offsetY || 0) |
| 124 | +// }; |
| 125 | +// } |
| 126 | +// } |
| 127 | +// } |
| 128 | +//} |
| 129 | +//``` |
| 130 | +// |
| 131 | +//**Online demos:** |
| 132 | +// |
| 133 | +//- [Online plotter (tooltip)](http://zizhujy.com/plotter "Online plotter") |
| 134 | +//- [Online Function Grapher (tooltip)](http://zizhujy.com/functiongrapher "Online Function Grapher") |
| 135 | +// |
| 136 | +; |
2 | 137 |
|
3 | 138 | // String extensions:
|
4 | 139 | if (!String.prototype.format) {
|
|
0 commit comments