if($( window ).width() >= '600'){ var width = 35; var height = 20; var xleft = 20; var right = 50; } else { var width = 25; var height = 17; var xleft = 15; var right = 20; } // Chart 638f66738ada1 const images638f66738ada1 = ['/assets/images/laender/jpg/deutschland.jpg', '/assets/images/laender/jpg/frankreich.jpg', '/assets/images/laender/jpg/niederlande.jpg', '/assets/images/laender/jpg/grossbritannien.jpg', '/assets/images/laender/jpg/usa.jpg']; const config638f66738ada1 = { type: 'bar', plugins: [{ afterDraw: chart => { var ctx = chart.ctx; var xAxis = chart.scales.x; var yAxis = chart.scales.y; chart.scales.x.ticks.forEach((value, index) => { var x = xAxis.getPixelForTick(index); var image = new Image(); image.src = images638f66738ada1[index]; ctx.drawImage(image, x - xleft, yAxis.bottom + 10, width, height) }); } }], data: { labels: ['GER','FR','NL','UK','USA',], datasets: [{ label: ['GER','FR','NL','UK','USA',], data: ['4.7','6.9','6.0','13.5','16.0',], borderWidth: 1, backgroundColor: [ '#ffe78e', '#2e2d2c', '#2e2d2c', '#2e2d2c', '#2e2d2c', ], }] }, options: { responsive: true, maintainAspectRatio: false, aspectRatio: 1, plugins: { legend: false, tooltip: { enabled: false }, datalabels: { align: 'end', anchor: 'end', color: '#000000', font: function(context) { var w = context.chart.width; return { size: w < 512 ? 12 : 14, weight: 'bold', }; }, formatter: function(value, context) { return Number(value).toLocaleString('de-DE', { minimumFractionDigits: 1, maximumFractionDigits: 1, }) + '%'; }, } }, layout: { padding: { right: 0, top: 30, } }, scales: { y: { display: false, beginAtZero: true, tooltip: false, grid: { display:false }, border: { display: false } }, x: { tooltip: false, grid: { display:false, tickLength: 30, }, ticks: { padding: 0, color: '#fff', font: { size: 1 }, crossAlign: 'start' }, }, }, } } Chart.register(ChartDataLabels); chart638f66738ada1 = new Chart(document.getElementById('638f66738ada1').getContext('2d'), config638f66738ada1); // Chart 638f620548541 const config638f620548541 = { type: 'bar', data: { labels: ['2018','2019','2020','2021','2022',], datasets: [{ label: '# of Votes', data: ['27','44','54','117','168',], borderWidth: 1, backgroundColor: [ '#2e2d2c', '#2e2d2c', '#2e2d2c', '#2e2d2c', '#ffe78e', ], }] }, options: { responsive: true, maintainAspectRatio: false, aspectRatio: 1, plugins: { legend: false, tooltip: { enabled: false }, datalabels: { align: 'end', anchor: 'end', color: '#000000', font: function(context) { var w = context.chart.width; return { size: w < 512 ? 12 : 14, weight: 'bold', }; }, formatter: function(value, context) { return Number(value).toLocaleString('de-DE'); }, } }, layout: { padding: { right: 0, top: 20, } }, scales: { y: { display: false, beginAtZero: true, tooltip: false, grid: { display:false }, border: { display: false } }, x: { tooltip: false, grid: { display:false }, }, }, } }; Chart.register(ChartDataLabels); chart638f620548541 = new Chart(document.getElementById('638f620548541').getContext('2d'), config638f620548541); // Chart 638f4eeb53749 const config638f4eeb53749 = { type: 'bar', data: { labels: ['2022','2021','2020','2019',], datasets: [{ label: '# of Votes', data: ['2618','3196','2732','2416',], borderWidth: 1, backgroundColor: [ '#ffe78e', '#2e2d2c', '#2e2d2c', '#2e2d2c', ], }] }, options: { indexAxis: 'y', responsive: true, maintainAspectRatio: false, aspectRatio: 1, plugins: { legend: false, tooltip: { enabled: false }, datalabels: { align: 'end', anchor: 'end', color: '#000', color: '#000000', font: function(context) { var w = context.chart.width; return { size: w < 512 ? 12 : 14, weight: 'bold', }; }, formatter: function(value, context) { return Number(value).toLocaleString('de-DE'); }, } }, layout: { padding: { right: right } }, scales: { y: { beginAtZero: true, tooltip: false, grid: { display:false }, border: { display: false } }, x: { display: false, tooltip: false, grid: { display:false }, }, }, } }; Chart.register(ChartDataLabels); chart638f4eeb53749 = new Chart(document.getElementById('638f4eeb53749').getContext('2d'), config638f4eeb53749); $(window).on('resize scroll', function() { $( ".viewport-chart:in-viewport" ).each(function( index ) { var chartanimation = $(this).attr("data-chart-animation"); var chartid = $(this).attr("data-chartid"); if(chartanimation == 'false' && chartid == '638f4eeb53749'){ chart638f4eeb53749.destroy(); chart638f4eeb53749 = new Chart(document.getElementById('638f4eeb53749').getContext('2d'), config638f4eeb53749); $(this).attr("data-chart-animation","true"); console.log('test'); } if(chartanimation == 'false' && chartid == '638f620548541'){ chart638f620548541.destroy(); chart638f620548541 = new Chart(document.getElementById('638f620548541').getContext('2d'), config638f620548541); $(this).attr("data-chart-animation","true"); } if(chartanimation == 'false' && chartid == '638f66738ada1'){ chart638f66738ada1.destroy(); chart638f66738ada1 = new Chart(document.getElementById('638f66738ada1').getContext('2d'), config638f66738ada1); $(this).attr("data-chart-animation","true"); } }); });