Created
February 13, 2015 18:34
-
-
Save stormpython/77d2cde268e77b32c273 to your computer and use it in GitHub Desktop.
Grid Layout
This file contains hidden or 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
// D3 code | |
var $el = $('.visualize-chart')[0]; | |
var data = { | |
type: 'chart', | |
series: [{}, {}, {}] | |
}; | |
var selection = d3.select($el).datum(data).call(split); | |
function split (selection) { | |
selection.each(function (data) { | |
var div = d3.select(this).data([data]); | |
var charts = div.selectAll('div') | |
.data(function (d) { | |
if (d.cols) return d.cols; | |
if (d.rows) return d.rows; | |
if (d.horizontal) return d.horizontal; | |
if (d.vertical) return d.vertical; | |
return d; | |
}) | |
.enter().append('div') | |
.attr('class', function (d) { | |
if (d.type === 'split') ? { | |
return d.horizontal ? 'horizontal' : 'vertical'; | |
} | |
return d.type; | |
}); | |
if (data.type !== 'chart' || data.type !== 'cols' || data.type !== 'rows' ) { | |
charts.call(split); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment