Husholdningsaffald
Hver dansker smider årligt omkring 800 kg ud derhjemme. Noget ender på genbrugspladsen, men rigtig meget ender i en af de tre skraldespande hjemme i indkørslen.
I Varde Kommune indsamlede vi i 2022 cirka 530 kg affald ind per husstand i henholdsvis skraldespanden (413 kg) og genbrugsspanden (119 kg). Vores ambition er at indsamle mere og mere genanvendeligt affald. Det er selvfølgelig godt for miljøet, men det er også bedre for økonomien. Det er dyrere at komme af med restaffald på forbrændingsanlægget end det er at komme af med genanvendelige affaldstyper.
Derfor holder vi nøje øje med mængderne for husholdningsaffald:
Error executing template "/Designs/Paragraph/Chart_B3_1.cshtml" System.Net.WebException: The request was aborted: The connection was closed unexpectedly. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at CompiledRazorTemplates.Dynamic.RazorEngine_913508a814384cd49de89638efe712ce.AffaldsVidenFunc.GetDe10FraktionerYear() in C:\home\site\wwwroot\DinForsyning\Files\Templates\Designs\Paragraph\Chart_B3_1.cshtml:line 170 at CompiledRazorTemplates.Dynamic.RazorEngine_913508a814384cd49de89638efe712ce.Execute() in C:\home\site\wwwroot\DinForsyning\Files\Templates\Designs\Paragraph\Chart_B3_1.cshtml:line 189 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @using System.Net 2 @using System.Text 3 @functions{ 4 public class AffaldsVidenFunc { 5 // private static readonly string API_KEY = "Hdj!^$Pn9Dl*uXTeZ&7fZEmdPG9s&Yg4DQMy13yw"; 6 // 7 // public static Newtonsoft.Json.Linq.JToken GetHKode(string kommune, string hkode) { 8 // var cacheKey = "AffaldsVidenFunc:GetHKode(" + kommune + ", " + hkode + ")"; 9 // var result = default(Newtonsoft.Json.Linq.JToken); 10 // 11 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 12 // using (var wc = new WebClient()) { 13 // wc.Headers["X-API-KEY"] = API_KEY; 14 // wc.Encoding = Encoding.UTF8; 15 // 16 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/hkode-" + hkode); 17 // 18 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 19 // 20 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 21 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 22 // }); 23 // } 24 // } 25 // 26 // return result; 27 // } 28 // 29 // public static Newtonsoft.Json.Linq.JToken GetGenbrugsprocent(string kommune) { 30 // var cacheKey = "AffaldsVidenFunc:GetGenbrugsprocent(" + kommune + ")"; 31 // var result = default(Newtonsoft.Json.Linq.JToken); 32 // 33 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 34 // using (var wc = new WebClient()) { 35 // wc.Headers["X-API-KEY"] = API_KEY; 36 // wc.Encoding = Encoding.UTF8; 37 // 38 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/genbrugsprocent"); 39 // 40 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 41 // 42 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 43 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 44 // }); 45 // } 46 // } 47 // 48 // return result; 49 // } 50 // 51 // public static Newtonsoft.Json.Linq.JToken GetMadaffaldTilEl(string kommune) { 52 // var cacheKey = "AffaldsVidenFunc:GetMadaffaldTilEl(" + kommune + ")"; 53 // var result = default(Newtonsoft.Json.Linq.JToken); 54 // 55 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 56 // using (var wc = new WebClient()) { 57 // wc.Headers["X-API-KEY"] = API_KEY; 58 // wc.Encoding = Encoding.UTF8; 59 // 60 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/madaffald-til-el"); 61 // 62 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 63 // 64 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 65 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 66 // }); 67 // } 68 // } 69 // 70 // return result; 71 // } 72 73 public static Newtonsoft.Json.Linq.JToken GetMadaffaldTilEl(int months) { 74 var cacheKey = "AffaldsVidenFunc:GetMadaffaldTilEl(" + months + ")"; 75 var result = default(Newtonsoft.Json.Linq.JToken); 76 77 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 78 using (var wc = new WebClient()) { 79 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 80 wc.Encoding = Encoding.UTF8; 81 82 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?madaffald-til-el=" + months); 83 84 result = Newtonsoft.Json.Linq.JToken.Parse(json); 85 86 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 87 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 88 }); 89 } 90 } 91 92 return result; 93 } 94 95 public static Newtonsoft.Json.Linq.JToken GetReelGenanvendelse(int months) { 96 var cacheKey = "AffaldsVidenFunc:GetReelGenanvendelse(" + months + ")"; 97 var result = default(Newtonsoft.Json.Linq.JToken); 98 99 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 100 using (var wc = new WebClient()) { 101 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 102 wc.Encoding = Encoding.UTF8; 103 104 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?reel-genanvendelse=" + months); 105 106 result = Newtonsoft.Json.Linq.JToken.Parse(json); 107 108 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 109 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(60.0 * 12) 110 }); 111 } 112 } 113 114 return result; 115 } 116 117 public static Newtonsoft.Json.Linq.JToken GetReelGenanvendelseYear() { 118 var cacheKey = "AffaldsVidenFunc:GetReelGenanvendelseYear()"; 119 var result = default(Newtonsoft.Json.Linq.JToken); 120 121 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 122 using (var wc = new WebClient()) { 123 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 124 wc.Encoding = Encoding.UTF8; 125 126 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?reel-genanvendelse-year"); 127 128 result = Newtonsoft.Json.Linq.JToken.Parse(json); 129 130 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 131 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(60.0 * 12) 132 }); 133 } 134 } 135 136 return result; 137 } 138 139 public static Newtonsoft.Json.Linq.JToken GetDe10Fraktioner(int months) { 140 var cacheKey = "AffaldsVidenFunc:GetDe10Fraktioner(" + months + ")"; 141 var result = default(Newtonsoft.Json.Linq.JToken); 142 143 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 144 using (var wc = new WebClient()) { 145 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 146 wc.Encoding = Encoding.UTF8; 147 148 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?de-10-fraktioner=" + months); 149 150 result = Newtonsoft.Json.Linq.JToken.Parse(json); 151 152 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 153 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 154 }); 155 } 156 } 157 158 return result; 159 } 160 161 public static Newtonsoft.Json.Linq.JToken GetDe10FraktionerYear() { 162 var cacheKey = "AffaldsVidenFunc:GetDe10FraktionerYear()"; 163 var result = default(Newtonsoft.Json.Linq.JToken); 164 165 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 166 using (var wc = new WebClient()) { 167 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 168 wc.Encoding = Encoding.UTF8; 169 170 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?de-10-fraktioner-year"); 171 172 result = Newtonsoft.Json.Linq.JToken.Parse(json); 173 174 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 175 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 176 }); 177 } 178 } 179 180 return result; 181 } 182 } 183 } 184 @using System.Globalization 185 @{ 186 var paragraphId = GetInteger("ParagraphID"); 187 var pageId = GetInteger("ParagraphPageID"); 188 189 var jTkn = AffaldsVidenFunc.GetDe10FraktionerYear()? 190 .Where(o => int.Parse((string)o["year"]) != DateTime.Now.Year) 191 .ToArray(); 192 193 var series = (new[] { "Restaffald", "Genanvendelse" }).Select(o => { 194 var data = o == "Restaffald" ? 195 jTkn?.Select(x => (double)x["Restaffald"]).ToArray() : 196 jTkn?.Select(x => (double)x["Glas"] + 197 (double)x["Mad- og drikkekartoner"] + 198 (double)x["Madaffald"] + 199 (double)x["Metal"] + 200 (double)x["Miljøkasse"] + 201 (double)x["Pap"] + 202 (double)x["Papir"] + 203 (double)x["Plast"] + 204 (double)x["Tekstiler"]).ToArray(); 205 206 return new { 207 name = o, 208 data, 209 }; 210 }).ToArray(); 211 212 var highchartsJs = Dynamicweb.Context.Current.Items?["highcharts_8.2.2"] as Lazy<string>; 213 var highchartsJsIsNull = false; 214 215 if (highchartsJs == null) { 216 highchartsJs = new Lazy<string>(() => "<script src=\"https://cdn.jsdelivr.net/npm/highcharts@8.2.2/highcharts.js\"></script>"); 217 highchartsJsIsNull = true; 218 219 Dynamicweb.Context.Current.Items["highcharts_8.2.2"] = highchartsJs; 220 } 221 } 222 223 <style type="text/css"> 224 #chart_@(paragraphId) .highcharts-tooltip table tr > td { padding: 2px; } 225 #chart_@(paragraphId) .highcharts-tooltip table tr:first-child > td { padding-bottom: 8px; border-bottom: 1px solid #2d3587; } 226 #chart_@(paragraphId) .highcharts-tooltip table tr:first-child + tr > td { padding-top: 8px; } 227 </style> 228 229 <div class="col-sm-12"> 230 <div id="chart_@(paragraphId)" style="margin-bottom: 20px;"></div> 231 </div> 232 233 @(highchartsJsIsNull ? highchartsJs.Value : string.Empty) 234 <script type="text/javascript"> 235 $(function() { 236 (1 === @(highchartsJsIsNull ? 1 : 0)) && Highcharts.setOptions({ 237 lang: { decimalPoint: '@(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)', thousandsSep: '' } 238 }); 239 240 var chartOpt = { 241 chart: { 242 type : 'spline', 243 spacing : [30, 20, 30, 20], 244 borderWidth : 1, 245 borderColor : '#2d3587', 246 height : 500, 247 style : { 248 fontFamily : "'MuseoSans-300', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'" 249 }, 250 }, 251 252 credits: { 253 enabled: false 254 }, 255 256 title: { 257 text : undefined, 258 margin : 20, 259 260 style: { 261 color : '#2d3587', 262 fontSize : '20px', 263 fontWeight : 'bold' 264 } 265 }, 266 267 plotOptions: { 268 series: { 269 dataLabels: { 270 enabled : true, 271 format : '{point.y:.0f}', 272 crop : false, 273 overflow : 'allow', 274 275 style: { 276 color : '#2d3587', 277 fontSize : '12px', 278 fontWeight : 'bold' 279 } 280 } 281 } 282 }, 283 284 tooltip: { 285 enabled : true, 286 valueDecimals : 2, 287 shared : true, 288 useHTML : true, 289 backgroundColor : '#f7f7f7', 290 headerFormat : '<table><tr><td colspan="3"><b>{point.key}</b></td></tr>', 291 pointFormat : '<tr><td><i class="fa fa-circle" style="color: {point.color};" aria-hidden="true"></i> <b>{series.name}</b>:</td><td><span style="display: inline-block; width: 10px;"></span></td><td style="text-align: right"><b>{point.y} tons</b></td></tr>', 292 footerFormat : '</table>' 293 }, 294 295 xAxis: { 296 categories : @(Newtonsoft.Json.JsonConvert.SerializeObject(jTkn.Select(o => (string)o["year"]))) 297 }, 298 299 yAxis: { 300 labels: { 301 format: '{value} tons' 302 }, 303 title: { 304 text: null 305 } 306 }, 307 308 series: @(Newtonsoft.Json.JsonConvert.SerializeObject(series)) 309 310 }; 311 312 var chart = Highcharts.chart('chart_@(paragraphId)', chartOpt); 313 }); 314 </script>
Genanvendelige affaldstyper per måned
Med den nye affaldsordning fra 2023 indsamlet vi de obligatoriske 10 affaldstyper, som kommuner skal indsamle. Her er forventningen, at mængden af restaffald falder, fordi mere og mere af dagligdagens affald kan genanvendes.
Nedenfor kan du se, hvordan det går med hver enkel genanvendelig affaldstype i år frem til forrige måned:
Error executing template "/Designs/Paragraph/Chart_B3_2.cshtml" System.Net.WebException: The request was aborted: The connection was closed unexpectedly. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at CompiledRazorTemplates.Dynamic.RazorEngine_31669a17bc354ba3bd57d6959f4aa9a5.AffaldsVidenFunc.GetDe10Fraktioner(Int32 months) in C:\home\site\wwwroot\DinForsyning\Files\Templates\Designs\Paragraph\Chart_B3_2.cshtml:line 148 at CompiledRazorTemplates.Dynamic.RazorEngine_31669a17bc354ba3bd57d6959f4aa9a5.Execute() in C:\home\site\wwwroot\DinForsyning\Files\Templates\Designs\Paragraph\Chart_B3_2.cshtml:line 191 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @using System.Net 2 @using System.Text 3 @functions{ 4 public class AffaldsVidenFunc { 5 // private static readonly string API_KEY = "Hdj!^$Pn9Dl*uXTeZ&7fZEmdPG9s&Yg4DQMy13yw"; 6 // 7 // public static Newtonsoft.Json.Linq.JToken GetHKode(string kommune, string hkode) { 8 // var cacheKey = "AffaldsVidenFunc:GetHKode(" + kommune + ", " + hkode + ")"; 9 // var result = default(Newtonsoft.Json.Linq.JToken); 10 // 11 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 12 // using (var wc = new WebClient()) { 13 // wc.Headers["X-API-KEY"] = API_KEY; 14 // wc.Encoding = Encoding.UTF8; 15 // 16 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/hkode-" + hkode); 17 // 18 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 19 // 20 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 21 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 22 // }); 23 // } 24 // } 25 // 26 // return result; 27 // } 28 // 29 // public static Newtonsoft.Json.Linq.JToken GetGenbrugsprocent(string kommune) { 30 // var cacheKey = "AffaldsVidenFunc:GetGenbrugsprocent(" + kommune + ")"; 31 // var result = default(Newtonsoft.Json.Linq.JToken); 32 // 33 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 34 // using (var wc = new WebClient()) { 35 // wc.Headers["X-API-KEY"] = API_KEY; 36 // wc.Encoding = Encoding.UTF8; 37 // 38 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/genbrugsprocent"); 39 // 40 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 41 // 42 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 43 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 44 // }); 45 // } 46 // } 47 // 48 // return result; 49 // } 50 // 51 // public static Newtonsoft.Json.Linq.JToken GetMadaffaldTilEl(string kommune) { 52 // var cacheKey = "AffaldsVidenFunc:GetMadaffaldTilEl(" + kommune + ")"; 53 // var result = default(Newtonsoft.Json.Linq.JToken); 54 // 55 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 56 // using (var wc = new WebClient()) { 57 // wc.Headers["X-API-KEY"] = API_KEY; 58 // wc.Encoding = Encoding.UTF8; 59 // 60 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/madaffald-til-el"); 61 // 62 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 63 // 64 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 65 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 66 // }); 67 // } 68 // } 69 // 70 // return result; 71 // } 72 73 public static Newtonsoft.Json.Linq.JToken GetMadaffaldTilEl(int months) { 74 var cacheKey = "AffaldsVidenFunc:GetMadaffaldTilEl(" + months + ")"; 75 var result = default(Newtonsoft.Json.Linq.JToken); 76 77 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 78 using (var wc = new WebClient()) { 79 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 80 wc.Encoding = Encoding.UTF8; 81 82 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?madaffald-til-el=" + months); 83 84 result = Newtonsoft.Json.Linq.JToken.Parse(json); 85 86 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 87 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 88 }); 89 } 90 } 91 92 return result; 93 } 94 95 public static Newtonsoft.Json.Linq.JToken GetReelGenanvendelse(int months) { 96 var cacheKey = "AffaldsVidenFunc:GetReelGenanvendelse(" + months + ")"; 97 var result = default(Newtonsoft.Json.Linq.JToken); 98 99 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 100 using (var wc = new WebClient()) { 101 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 102 wc.Encoding = Encoding.UTF8; 103 104 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?reel-genanvendelse=" + months); 105 106 result = Newtonsoft.Json.Linq.JToken.Parse(json); 107 108 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 109 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(60.0 * 12) 110 }); 111 } 112 } 113 114 return result; 115 } 116 117 public static Newtonsoft.Json.Linq.JToken GetReelGenanvendelseYear() { 118 var cacheKey = "AffaldsVidenFunc:GetReelGenanvendelseYear()"; 119 var result = default(Newtonsoft.Json.Linq.JToken); 120 121 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 122 using (var wc = new WebClient()) { 123 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 124 wc.Encoding = Encoding.UTF8; 125 126 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?reel-genanvendelse-year"); 127 128 result = Newtonsoft.Json.Linq.JToken.Parse(json); 129 130 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 131 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(60.0 * 12) 132 }); 133 } 134 } 135 136 return result; 137 } 138 139 public static Newtonsoft.Json.Linq.JToken GetDe10Fraktioner(int months) { 140 var cacheKey = "AffaldsVidenFunc:GetDe10Fraktioner(" + months + ")"; 141 var result = default(Newtonsoft.Json.Linq.JToken); 142 143 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 144 using (var wc = new WebClient()) { 145 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 146 wc.Encoding = Encoding.UTF8; 147 148 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?de-10-fraktioner=" + months); 149 150 result = Newtonsoft.Json.Linq.JToken.Parse(json); 151 152 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 153 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 154 }); 155 } 156 } 157 158 return result; 159 } 160 161 public static Newtonsoft.Json.Linq.JToken GetDe10FraktionerYear() { 162 var cacheKey = "AffaldsVidenFunc:GetDe10FraktionerYear()"; 163 var result = default(Newtonsoft.Json.Linq.JToken); 164 165 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 166 using (var wc = new WebClient()) { 167 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 168 wc.Encoding = Encoding.UTF8; 169 170 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?de-10-fraktioner-year"); 171 172 result = Newtonsoft.Json.Linq.JToken.Parse(json); 173 174 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 175 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 176 }); 177 } 178 } 179 180 return result; 181 } 182 } 183 } 184 @using System.Globalization 185 @{ 186 var paragraphId = GetInteger("ParagraphID"); 187 var pageId = GetInteger("ParagraphPageID"); 188 189 var dtA = new DateTime(DateTime.Today.Year, 1, 1); 190 var dtB = new DateTime(DateTime.Today.Year, 12, 31); 191 var jTkn = AffaldsVidenFunc.GetDe10Fraktioner(12)? 192 // .Where(o => { 193 // var dt = new DateTime(int.Parse((string)o["year"]), int.Parse((string)o["month"]), 1); 194 // return dtA.Date <= dt.Date && dtB.Date >= dt.Date; 195 // }) 196 .ToArray(); 197 198 var series = (new[] { "Glas", "Mad- og drikkekartoner", "Madaffald", "Metal", "Miljøkasse", "Pap", "Papir", "Plast", "Tekstiler" }).Select(o => { 199 var data = jTkn?.Select(x => (double)x[o]).ToArray(); 200 201 return new { 202 name = o, 203 data, 204 }; 205 }) 206 .Where(x => x.data?.Any(y => y > 0) == true) 207 .ToArray(); 208 209 var highchartsJs = Dynamicweb.Context.Current.Items?["highcharts_8.2.2"] as Lazy<string>; 210 var highchartsJsIsNull = false; 211 212 if (highchartsJs == null) { 213 highchartsJs = new Lazy<string>(() => "<script src=\"https://cdn.jsdelivr.net/npm/highcharts@8.2.2/highcharts.js\"></script>"); 214 highchartsJsIsNull = true; 215 216 Dynamicweb.Context.Current.Items["highcharts_8.2.2"] = highchartsJs; 217 } 218 } 219 220 <style type="text/css"> 221 #chart_@(paragraphId) .highcharts-tooltip table tr > td { padding: 2px; } 222 #chart_@(paragraphId) .highcharts-tooltip table tr:first-child > td { padding-bottom: 8px; border-bottom: 1px solid #2d3587; } 223 #chart_@(paragraphId) .highcharts-tooltip table tr:first-child + tr > td { padding-top: 8px; } 224 </style> 225 226 <div class="col-sm-12"> 227 <div id="chart_@(paragraphId)" style="margin-bottom: 20px;"></div> 228 </div> 229 230 @(highchartsJsIsNull ? highchartsJs.Value : string.Empty) 231 <script type="text/javascript"> 232 $(function() { 233 (1 === @(highchartsJsIsNull ? 1 : 0)) && Highcharts.setOptions({ 234 lang: { decimalPoint: '@(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)', thousandsSep: '' } 235 }); 236 237 var chartOpt = { 238 chart: { 239 type : 'spline', 240 spacing : [30, 20, 30, 20], 241 borderWidth : 1, 242 borderColor : '#2d3587', 243 height : 500, 244 style : { 245 fontFamily : "'MuseoSans-300', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'" 246 }, 247 }, 248 249 credits: { 250 enabled: false 251 }, 252 253 title: { 254 text : undefined, 255 margin : 20, 256 257 style: { 258 color : '#2d3587', 259 fontSize : '20px', 260 fontWeight : 'bold' 261 } 262 }, 263 264 plotOptions: { 265 series: { 266 dataLabels: { 267 enabled : true, 268 format : '{point.y:.0f}', 269 crop : false, 270 overflow : 'allow', 271 272 style: { 273 color : '#2d3587', 274 fontSize : '12px', 275 fontWeight : 'bold' 276 } 277 } 278 } 279 }, 280 281 tooltip: { 282 enabled : true, 283 valueDecimals : 2, 284 shared : true, 285 useHTML : true, 286 backgroundColor : '#f7f7f7', 287 headerFormat : '<table><tr><td colspan="3"><b>{point.key}</b></td></tr>', 288 pointFormat : '<tr><td><i class="fa fa-circle" style="color: {point.color};" aria-hidden="true"></i> <b>{series.name}</b>:</td><td><span style="display: inline-block; width: 10px;"></span></td><td style="text-align: right"><b>{point.y} tons</b></td></tr>', 289 footerFormat : '</table>' 290 }, 291 292 xAxis: { 293 categories : @(Newtonsoft.Json.JsonConvert.SerializeObject(jTkn.Select(o => DateTime.ParseExact((string)o["date"], "yyyy-MM-dd", CultureInfo.InvariantCulture).ToString("MMM yyyy")))) 294 }, 295 296 yAxis: { 297 labels: { 298 format: '{value} tons' 299 }, 300 title: { 301 text: null 302 } 303 }, 304 305 series: @(Newtonsoft.Json.JsonConvert.SerializeObject(series)) 306 307 }; 308 309 var chart = Highcharts.chart('chart_@(paragraphId)', chartOpt); 310 }); 311 </script>
Husholdningsaffald per år
Efterhånden som tiden går, kan du se de genanvendelige affaldstyper indsamlet per år nedenfor:
Error executing template "/Designs/Paragraph/Chart_B3_3.cshtml" System.Net.WebException: The request was aborted: The connection was closed unexpectedly. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at CompiledRazorTemplates.Dynamic.RazorEngine_088f2f09d7334280ad68b9b11c11ef51.AffaldsVidenFunc.GetDe10FraktionerYear() in C:\home\site\wwwroot\DinForsyning\Files\Templates\Designs\Paragraph\Chart_B3_3.cshtml:line 170 at CompiledRazorTemplates.Dynamic.RazorEngine_088f2f09d7334280ad68b9b11c11ef51.Execute() in C:\home\site\wwwroot\DinForsyning\Files\Templates\Designs\Paragraph\Chart_B3_3.cshtml:line 189 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @using System.Net 2 @using System.Text 3 @functions{ 4 public class AffaldsVidenFunc { 5 // private static readonly string API_KEY = "Hdj!^$Pn9Dl*uXTeZ&7fZEmdPG9s&Yg4DQMy13yw"; 6 // 7 // public static Newtonsoft.Json.Linq.JToken GetHKode(string kommune, string hkode) { 8 // var cacheKey = "AffaldsVidenFunc:GetHKode(" + kommune + ", " + hkode + ")"; 9 // var result = default(Newtonsoft.Json.Linq.JToken); 10 // 11 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 12 // using (var wc = new WebClient()) { 13 // wc.Headers["X-API-KEY"] = API_KEY; 14 // wc.Encoding = Encoding.UTF8; 15 // 16 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/hkode-" + hkode); 17 // 18 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 19 // 20 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 21 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 22 // }); 23 // } 24 // } 25 // 26 // return result; 27 // } 28 // 29 // public static Newtonsoft.Json.Linq.JToken GetGenbrugsprocent(string kommune) { 30 // var cacheKey = "AffaldsVidenFunc:GetGenbrugsprocent(" + kommune + ")"; 31 // var result = default(Newtonsoft.Json.Linq.JToken); 32 // 33 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 34 // using (var wc = new WebClient()) { 35 // wc.Headers["X-API-KEY"] = API_KEY; 36 // wc.Encoding = Encoding.UTF8; 37 // 38 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/genbrugsprocent"); 39 // 40 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 41 // 42 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 43 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 44 // }); 45 // } 46 // } 47 // 48 // return result; 49 // } 50 // 51 // public static Newtonsoft.Json.Linq.JToken GetMadaffaldTilEl(string kommune) { 52 // var cacheKey = "AffaldsVidenFunc:GetMadaffaldTilEl(" + kommune + ")"; 53 // var result = default(Newtonsoft.Json.Linq.JToken); 54 // 55 // if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 56 // using (var wc = new WebClient()) { 57 // wc.Headers["X-API-KEY"] = API_KEY; 58 // wc.Encoding = Encoding.UTF8; 59 // 60 // var json = wc.DownloadString("https://api.affaldsviden.info/kommune-" + kommune + "/madaffald-til-el"); 61 // 62 // result = Newtonsoft.Json.Linq.JToken.Parse(json); 63 // 64 // Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 65 // AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 66 // }); 67 // } 68 // } 69 // 70 // return result; 71 // } 72 73 public static Newtonsoft.Json.Linq.JToken GetMadaffaldTilEl(int months) { 74 var cacheKey = "AffaldsVidenFunc:GetMadaffaldTilEl(" + months + ")"; 75 var result = default(Newtonsoft.Json.Linq.JToken); 76 77 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 78 using (var wc = new WebClient()) { 79 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 80 wc.Encoding = Encoding.UTF8; 81 82 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?madaffald-til-el=" + months); 83 84 result = Newtonsoft.Json.Linq.JToken.Parse(json); 85 86 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 87 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 88 }); 89 } 90 } 91 92 return result; 93 } 94 95 public static Newtonsoft.Json.Linq.JToken GetReelGenanvendelse(int months) { 96 var cacheKey = "AffaldsVidenFunc:GetReelGenanvendelse(" + months + ")"; 97 var result = default(Newtonsoft.Json.Linq.JToken); 98 99 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 100 using (var wc = new WebClient()) { 101 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 102 wc.Encoding = Encoding.UTF8; 103 104 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?reel-genanvendelse=" + months); 105 106 result = Newtonsoft.Json.Linq.JToken.Parse(json); 107 108 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 109 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(60.0 * 12) 110 }); 111 } 112 } 113 114 return result; 115 } 116 117 public static Newtonsoft.Json.Linq.JToken GetReelGenanvendelseYear() { 118 var cacheKey = "AffaldsVidenFunc:GetReelGenanvendelseYear()"; 119 var result = default(Newtonsoft.Json.Linq.JToken); 120 121 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 122 using (var wc = new WebClient()) { 123 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 124 wc.Encoding = Encoding.UTF8; 125 126 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?reel-genanvendelse-year"); 127 128 result = Newtonsoft.Json.Linq.JToken.Parse(json); 129 130 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 131 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(60.0 * 12) 132 }); 133 } 134 } 135 136 return result; 137 } 138 139 public static Newtonsoft.Json.Linq.JToken GetDe10Fraktioner(int months) { 140 var cacheKey = "AffaldsVidenFunc:GetDe10Fraktioner(" + months + ")"; 141 var result = default(Newtonsoft.Json.Linq.JToken); 142 143 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 144 using (var wc = new WebClient()) { 145 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 146 wc.Encoding = Encoding.UTF8; 147 148 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?de-10-fraktioner=" + months); 149 150 result = Newtonsoft.Json.Linq.JToken.Parse(json); 151 152 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 153 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 154 }); 155 } 156 } 157 158 return result; 159 } 160 161 public static Newtonsoft.Json.Linq.JToken GetDe10FraktionerYear() { 162 var cacheKey = "AffaldsVidenFunc:GetDe10FraktionerYear()"; 163 var result = default(Newtonsoft.Json.Linq.JToken); 164 165 if (!Dynamicweb.Caching.Cache.Current.TryGet<Newtonsoft.Json.Linq.JToken>(cacheKey, out result)) { 166 using (var wc = new WebClient()) { 167 wc.Headers["Authorization"] = "Basic VmFyZGU6ZExsXjdeRUR5a0VkNDl1amYk"; 168 wc.Encoding = Encoding.UTF8; 169 170 var json = wc.DownloadString("https://affaldsviden.info/vardeapi.php?de-10-fraktioner-year"); 171 172 result = Newtonsoft.Json.Linq.JToken.Parse(json); 173 174 Dynamicweb.Caching.Cache.Current.Set(cacheKey, result, new Dynamicweb.Caching.CacheItemPolicy { 175 AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(5.0) 176 }); 177 } 178 } 179 180 return result; 181 } 182 } 183 } 184 @using System.Globalization 185 @{ 186 var paragraphId = GetInteger("ParagraphID"); 187 var pageId = GetInteger("ParagraphPageID"); 188 189 var jTkn = AffaldsVidenFunc.GetDe10FraktionerYear()? 190 .Where(o => int.Parse((string)o["year"]) != DateTime.Now.Year) 191 .ToArray(); 192 193 var series = (new[] { "Glas", "Mad- og drikkekartoner", "Madaffald", "Metal", "Miljøkasse", "Pap", "Papir", "Plast", "Restaffald", "Tekstiler" }).Select(o => { 194 var data = jTkn?.Select(x => (double)x[o]).ToArray(); 195 196 return new { 197 name = o, 198 data, 199 }; 200 }) 201 .Where(x => x.data?.Any(y => y > 0) == true) 202 .ToArray(); 203 204 var highchartsJs = Dynamicweb.Context.Current.Items?["highcharts_8.2.2"] as Lazy<string>; 205 var highchartsJsIsNull = false; 206 207 if (highchartsJs == null) { 208 highchartsJs = new Lazy<string>(() => "<script src=\"https://cdn.jsdelivr.net/npm/highcharts@8.2.2/highcharts.js\"></script>"); 209 highchartsJsIsNull = true; 210 211 Dynamicweb.Context.Current.Items["highcharts_8.2.2"] = highchartsJs; 212 } 213 } 214 215 <style type="text/css"> 216 #chart_@(paragraphId) .highcharts-tooltip table tr > td { padding: 2px; } 217 #chart_@(paragraphId) .highcharts-tooltip table tr:first-child > td { padding-bottom: 8px; border-bottom: 1px solid #2d3587; } 218 #chart_@(paragraphId) .highcharts-tooltip table tr:first-child + tr > td { padding-top: 8px; } 219 </style> 220 221 <div class="col-sm-12"> 222 <div id="chart_@(paragraphId)" style="margin-bottom: 20px;"></div> 223 </div> 224 225 @(highchartsJsIsNull ? highchartsJs.Value : string.Empty) 226 <script type="text/javascript"> 227 $(function() { 228 (1 === @(highchartsJsIsNull ? 1 : 0)) && Highcharts.setOptions({ 229 lang: { decimalPoint: '@(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)', thousandsSep: '' } 230 }); 231 232 var chartOpt = { 233 chart: { 234 type : 'spline', 235 spacing : [30, 20, 30, 20], 236 borderWidth : 1, 237 borderColor : '#2d3587', 238 height : 500, 239 style : { 240 fontFamily : "'MuseoSans-300', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'" 241 }, 242 }, 243 244 credits: { 245 enabled: false 246 }, 247 248 title: { 249 text : undefined, 250 margin : 20, 251 252 style: { 253 color : '#2d3587', 254 fontSize : '20px', 255 fontWeight : 'bold' 256 } 257 }, 258 259 plotOptions: { 260 series: { 261 dataLabels: { 262 enabled : true, 263 format : '{point.y:.0f}', 264 crop : false, 265 overflow : 'allow', 266 267 style: { 268 color : '#2d3587', 269 fontSize : '12px', 270 fontWeight : 'bold' 271 } 272 } 273 } 274 }, 275 276 tooltip: { 277 enabled : true, 278 valueDecimals : 2, 279 shared : true, 280 useHTML : true, 281 backgroundColor : '#f7f7f7', 282 headerFormat : '<table><tr><td colspan="3"><b>{point.key}</b></td></tr>', 283 pointFormat : '<tr><td><i class="fa fa-circle" style="color: {point.color};" aria-hidden="true"></i> <b>{series.name}</b>:</td><td><span style="display: inline-block; width: 10px;"></span></td><td style="text-align: right"><b>{point.y} tons</b></td></tr>', 284 footerFormat : '</table>' 285 }, 286 287 xAxis: { 288 categories : @(Newtonsoft.Json.JsonConvert.SerializeObject(jTkn.Select(o => (string)o["year"]))) 289 }, 290 291 yAxis: { 292 labels: { 293 format: '{value} tons' 294 }, 295 title: { 296 text: null 297 } 298 }, 299 300 series: @(Newtonsoft.Json.JsonConvert.SerializeObject(series)) 301 302 }; 303 304 var chart = Highcharts.chart('chart_@(paragraphId)', chartOpt); 305 }); 306 </script>