Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sebkopf
Last active December 25, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebkopf/6955612 to your computer and use it in GitHub Desktop.
Save sebkopf/6955612 to your computer and use it in GitHub Desktop.
NVD3 template that supports y2Axis paramters for making lineWithFocusCharts
<script type='text/javascript'>
$(document).ready(function(){
draw{{chartId}}()
});
function draw{{chartId}}(){
var opts = {{{ opts }}},
data = {{{ data }}}
var data = d3.nest()
.key(function(d){
return opts.group === undefined ? 'main' : d[opts.group]
})
.entries(data)
nv.addGraph(function() {
var chart = nv.models[opts.type]()
.x(function(d) { return d[opts.x] })
.y(function(d) { return d[opts.y] })
.width(opts.width)
.height(opts.height)
{{{ chart }}}
{{{ xAxis }}}
{{{ x2Axis }}}
{{{ yAxis }}}
{{{ y2Axis }}}
d3.select("#" + opts.id)
.append('svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment