projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
PR Comment: Removing checks for undefined and null. They aren't possible
[dygraphs.git]
/
gallery
/
interaction.js
diff --git
a/gallery/interaction.js
b/gallery/interaction.js
index
69a812c
..
a903737
100644
(file)
--- a/
gallery/interaction.js
+++ b/
gallery/interaction.js
@@
-1,3
+1,6
@@
+/*global Gallery,Dygraph,data */
+/*global NoisyData,downV3,moveV3,upV3,clickV3,dblClickV3,scrollV3,restorePositioning,downV4,moveV4,upV4,dblClickV4,captureCanvas */
+
Gallery.register(
'interaction',
{
Gallery.register(
'interaction',
{
@@
-5,7
+8,7
@@
Gallery.register(
title: 'title',
setup: function(parent) {
parent.innerHTML = [
title: 'title',
setup: function(parent) {
parent.innerHTML = [
- "<h
2>Default interaction model</h2
>",
+ "<h
3>Default interaction model</h3
>",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Zoom: click-drag, Pan: shift-click-drag, Restore: double-click",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Zoom: click-drag, Pan: shift-click-drag, Restore: double-click",
@@
-13,7
+16,7
@@
Gallery.register(
" <div id='div_g' style='width:600px; height:300px;'></div>",
"</div>",
"",
" <div id='div_g' style='width:600px; height:300px;'></div>",
"</div>",
"",
- "<h
2>Empty interaction model</h2
>",
+ "<h
3>Empty interaction model</h3
>",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Click and drag all you like, it won't do anything!",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Click and drag all you like, it won't do anything!",
@@
-22,7
+25,7
@@
Gallery.register(
"</div>",
"<div id='g2_console'></div>", // what is this?
"",
"</div>",
"<div id='g2_console'></div>", // what is this?
"",
- "<h
2>Custom interaction model</h2
>",
+ "<h
3>Custom interaction model</h3
>",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Zoom in: double-click, scroll wheel<br/>",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Zoom in: double-click, scroll wheel<br/>",
@@
-34,25
+37,24
@@
Gallery.register(
" <button id='restore3'>Restore position</button>",
" <div id='div_g3' style='width:600px; height:300px;'></div>",
"</div>",
" <button id='restore3'>Restore position</button>",
" <div id='div_g3' style='width:600px; height:300px;'></div>",
"</div>",
- "<h
2>Fun model!</h2
>",
+ "<h
3>Fun model!</h3
>",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Keep the mouse button pressed, and hover over all points",
" to mark them.",
" </p>",
" <div id='div_g4' style='width:600px; height:300px;'></div>",
"<div style='width:600px;'>",
" <p style='text-align:center;'>",
" Keep the mouse button pressed, and hover over all points",
" to mark them.",
" </p>",
" <div id='div_g4' style='width:600px; height:300px;'></div>",
- "</div>"
,
+ "</div>"
].join('\n');
},
run: function() {
].join('\n');
},
run: function() {
- // TODO(konigsberg): Add cleanup to remove callbacks.
-
Dygraph.addEvent(document,
"mousewheel", function() { lastClickedGraph = null; });
-
Dygraph.addEvent(document,
"click", function() { lastClickedGraph = null; });
-
var g =
new Dygraph(document.getElementById("div_g"),
+ var lastClickedGraph;
+
document.addEventListener(
"mousewheel", function() { lastClickedGraph = null; });
+
document.addEventListener(
"click", function() { lastClickedGraph = null; });
+ new Dygraph(document.getElementById("div_g"),
NoisyData, { errorBars : true });
NoisyData, { errorBars : true });
- var s = document.getElementById("g2_console");
- var g2 = new Dygraph(document.getElementById("div_g2"),
+ new Dygraph(document.getElementById("div_g2"),
NoisyData,
{
errorBars : true,
NoisyData,
{
errorBars : true,
@@
-69,15
+71,22
@@
Gallery.register(
}});
document.getElementById("restore3").onclick = function() {
restorePositioning(g3);
}});
document.getElementById("restore3").onclick = function() {
restorePositioning(g3);
- }
- var g4 = new Dygraph(document.getElementById("div_g4"),
- NoisyData, { errorBars : true, drawPoints : true, interactionModel : {
- 'mousedown' : downV4,
- 'mousemove' : moveV4,
- 'mouseup' : upV4,
- 'dblclick' : dblClickV4,
- },
- underlayCallback : captureCanvas
- });
+ };
+ new Dygraph(document.getElementById("div_g4"),
+ NoisyData, {
+ errorBars : true,
+ drawPoints : true,
+ interactionModel : {
+ 'mousedown' : downV4,
+ 'mousemove' : moveV4,
+ 'mouseup' : upV4,
+ 'dblclick' : dblClickV4
+ },
+ underlayCallback : captureCanvas
+ });
+ },
+ clean: function() {
+ document.removeEventListener('mousewheel');
+ document.removeEventListener('click');
}
});
}
});