!function(){var t,e=document.querySelector("#graph-1"),a=null,r=0;function n(){var t=Math.round((e.parentNode||e).getBoundingClientRect().width)||600,n=t<520,i=Math.min(680,t),s=n?Math.round(.95*i):Math.max(420,Math.min(600,Math.round(.8*window.innerHeight)-90));if(i+"x"+s!==r){r=i+"x"+s,a&&a.disconnect(),d3.select(e).selectAll("svg").remove();var o=n?{top:64,right:58,bottom:52,left:34}:{top:64,right:80,bottom:60,left:64},l=i-o.left-o.right,c=s-o.top-o.bottom,f=d3.select("#graph-1").append("svg").style("overflow","visible").attr("width",l+o.left+o.right).attr("height",c+o.top+o.bottom),u=f.append("text").attr("class","chart-title").attr("x",0).attr("y",30).attr("fill","#1a1a1a").style("font-family","effra, sans-serif").style("font-size","1.8rem").style("font-weight",700).text("CO₂ emissions over lifetime of a car"),d=window.wrapChartTitle(u,l+o.left+o.right);f.attr("height",c+o.top+o.bottom+d);var p=f.append("g").attr("transform","translate("+o.left+","+(o.top+d)+")"),h={BEV:"#4D45FF",Petrol:"#9a9a9a"};d3.csv("https://uploads.transportenvironment.org/production/datasets/2026_emissions.csv?v="+Date.now()).then(function(t){var r=t.columns.slice(1).map(Number),s=t.map(function(t){return{name:t.Year,values:r.map(function(e){return{year:e,value:+t[e]}})}}),u=d3.scaleLinear().domain([0,d3.max(s,function(t){return d3.max(t.values,function(t){return t.value})})]).nice().range([c,0]),m=p.append("g").style("font-size","0.8rem").call(d3.axisLeft(u).ticks(5)),g=Math.ceil(-m.node().getBBox().x);m.remove(),l=i-g-o.right,p.attr("transform","translate("+g+","+(o.top+d)+")");var x=d3.scaleLinear().domain(d3.extent(r)).range([0,l]);p.append("g").attr("class","axis").attr("transform","translate(0,"+c+")").style("font-size","1rem").call(d3.axisBottom(x).ticks(n?4:r.length/3).tickSizeOuter(0)).call(function(t){t.select(".domain").remove()}),p.append("g").attr("class","axis axis-y").style("font-size","0.8rem").call(d3.axisLeft(u).ticks(5)).call(function(t){t.select(".domain").remove()}),p.selectAll(".axis path, .axis line").attr("stroke","#E5E5E5"),p.selectAll(".axis text").attr("fill","#E5E5E5"),p.insert("g",":first-child").attr("class","em-grid").selectAll("line").data(u.ticks(5)).join("line").attr("x1",0).attr("x2",l).attr("y1",function(t){return u(t)}).attr("y2",function(t){return u(t)}).attr("stroke","#E5E5E5").attr("stroke-width",1),p.append("text").attr("class","axis-title").attr("x",l/2).attr("y",c+44).attr("text-anchor","middle").attr("fill","#6f6f6f").style("font-family","Roboto, sans-serif").style("font-size","0.9rem").text("Age of the car");var y=p.select(".axis-y").node().getBBox().x;p.append("text").attr("class","axis-title").attr("x",y).attr("y",u(u.ticks(5).slice(-1)[0])-18).attr("text-anchor","start").attr("fill","#6f6f6f").style("font-family","Roboto, sans-serif").style("font-size","0.9rem").text("tCO₂ emissions from a single car");var v=d3.line().x(function(t){return x(t.year)}).y(function(t){return u(t.value)}),b=f.append("defs").append("filter").attr("id","lca-bev-glow").attr("filterUnits","userSpaceOnUse").attr("x",-20).attr("y",-20).attr("width",l+40).attr("height",c+40);b.append("feGaussianBlur").attr("in","SourceGraphic").attr("stdDeviation",5).attr("result","blur"),b.append("feComponentTransfer").attr("in","blur").attr("result","soft").append("feFuncA").attr("type","linear").attr("slope",.7);var w=b.append("feMerge");w.append("feMergeNode").attr("in","soft"),w.append("feMergeNode").attr("in","SourceGraphic");var k=p.selectAll(".em-line").data(s).join("path").attr("class","em-line").attr("fill","none").attr("stroke",function(t){return h[t.name]||"#1a1a1a"}).attr("stroke-width",3).attr("filter",function(t){return"BEV"===t.name?"url(#lca-bev-glow)":null}).attr("d",function(t){return v(t.values)}),E=p.selectAll(".em-label").data(s).join("text").attr("class","em-label").attr("x",l+8).attr("y",function(t){return u(t.values[t.values.length-1].value)}).attr("dy","0.35em").attr("fill",function(t){return h[t.name]||"#1a1a1a"}).style("font-family","Roboto, sans-serif").style("font-weight",700).text(function(t){return t.name});function M(){k.interrupt().each(function(){var t=this.getTotalLength();d3.select(this).attr("stroke-dasharray",t+" "+t).attr("stroke-dashoffset",t)}),E.interrupt().style("opacity",0)}M(),(a=new IntersectionObserver(function(t){t.forEach(function(t){t.isIntersecting?(k.interrupt().each(function(){var t=this.getTotalLength();d3.select(this).attr("stroke-dasharray",t+" "+t).attr("stroke-dashoffset",t).transition().duration(1800).ease(d3.easeCubicInOut).attr("stroke-dashoffset",0)}),E.interrupt().style("opacity",0).transition().delay(1600).duration(400).style("opacity",1)):M()})},{threshold:.5})).observe(e)})}}n(),window.addEventListener("resize",function(){clearTimeout(t),t=setTimeout(n,150)})}();