-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useViewBoxResizing option for resizing examples
for #1312
- Loading branch information
1 parent
de7310e
commit 3e6e4e3
Showing
8 changed files
with
72 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
div.fullsize { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var find_query = function() { | ||
var _map = window.location.search.substr(1).split('&').map(function(a) { | ||
return a.split('='); | ||
}).reduce(function(p, v) { | ||
if(v.length > 1) | ||
p[v[0]] = decodeURIComponent(v[1].replace(/\+/g, " ")); | ||
else | ||
p[v[0]] = true; | ||
return p; | ||
}, {}); | ||
return function(field) { | ||
return _map[field] || null; | ||
}; | ||
}(); | ||
var resizeMode = find_query('resize') || 'widhei'; | ||
|
||
function apply_resizing(chart, adjustX, adjustY, onresize) { | ||
if(resizeMode.toLowerCase() === 'viewbox') { | ||
chart | ||
.width(600) | ||
.height(400) | ||
.useViewBoxResizing(true); | ||
d3.select(chart.anchor()).classed('fullsize', true); | ||
} else { | ||
adjustX = adjustX || 0; | ||
adjustY = adjustY || adjustX || 0; | ||
chart | ||
.width(window.innerWidth-adjustX) | ||
.height(window.innerHeight-adjustY); | ||
window.onresize = function() { | ||
onresize(chart); | ||
chart | ||
.width(window.innerWidth-20) | ||
.height(window.innerHeight-20) | ||
.rescale() | ||
.redraw(); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters