You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varmargin={top: 10,right: 20,bottom: 30,left: 30};varwidth=400-margin.left-margin.right;varheight=600-margin.top-margin.bottom;varsvg=d3.select('.chart').append('svg').attr('width',width+margin.left+margin.right).attr('height',height+margin.top+margin.bottom).call(responsivefy).append('g').attr('transform','translate('+margin.left+', '+margin.top+')');varyScale=d3.scaleLinear().domain([0,100]).range([height,0]);varyAxis=d3.axisLeft(yScale);svg.call(yAxis);varxScale=d3.scaleTime().domain([newDate(2016,0,1,6),newDate(2016,0,1,9)]).range([0,width]);varxAxis=d3.axisBottom(xScale).ticks(5).tickSize(10).tickPadding(5);svg.append('g').attr('transform',`translate(0, ${height})`).call(xAxis);functionresponsivefy(svg){// get container + svg aspect ratiovarcontainer=d3.select(svg.node().parentNode),width=parseInt(svg.style("width")),height=parseInt(svg.style("height")),aspect=width/height;// add viewBox and preserveAspectRatio properties,// and call resize so that svg resizes on inital page loadsvg.attr("viewBox","0 0 "+width+" "+height).attr("preserveAspectRatio","xMinYMid").call(resize);// to register multiple listeners for same event type,// you need to add namespace, i.e., 'click.foo'// necessary if you call invoke this function for multiple svgs// api docs: https://github.com/mbostock/d3/wiki/Selections#ond3.select(window).on("resize",resize);// get width of container and resize svg to fit itfunctionresize(){vartargetWidth=parseInt(container.style("width"));svg.attr("width",targetWidth);svg.attr("height",Math.round(targetWidth/aspect));}}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: