$(document).ready( function() { window.addEventListener('resize', onWindowsSize); $('.darstellung-balkendiagramm').each( function(index) { var theDiv = $(this); var balken = JSON.parse(theDiv.attr("data-array")); var title = theDiv.attr("data-title"); var subtitle = theDiv.attr("data-subtitle"); var footer = theDiv.attr("data-footer"); var export_filename = theDiv .attr("data-export-filename"); var container_id = theDiv.attr("id"); var xAxisEnabled = theDiv.attr("data-xAxisEnabled")=="true"; var labelEnabled = theDiv.attr("data-labelEnabled")=="true"; Praesentation.www.darstellungen.balkendiagramm(title, subtitle, footer, balken, export_filename, container_id, xAxisEnabled, labelEnabled); }); $('.darstellung-saeulendiagramm').each( function(index) { var theDiv = $(this); var balken = JSON.parse(theDiv.attr("data-array")); var title = theDiv.attr("data-title"); var subtitle = theDiv.attr("data-subtitle"); var footer = theDiv.attr("data-footer"); var export_filename = theDiv .attr("data-export-filename"); var container_id = theDiv.attr("id"); var xAxisEnabled = theDiv.attr("data-xAxisEnabled")=="true"; var labelEnabled = theDiv.attr("data-labelEnabled")=="true"; Praesentation.www.darstellungen.saeulendiagramm(title, subtitle, footer, balken, export_filename, container_id,xAxisEnabled,labelEnabled); }); $('.darstellung-liniendiagramm').each( function(index) { var theDiv = $(this); var title = theDiv.attr("data-title"); var subtitle = theDiv.attr("data-subtitle"); var footer = theDiv.attr("data-footer"); var export_filename = theDiv .attr("data-export-filename"); var container_id = theDiv.attr("id"); var series_label = theDiv.attr("data-series-label"); var kategorien = JSON.parse(theDiv .attr("data-kategorien")); var data = JSON.parse(theDiv.attr("data-data")); Praesentation.www.darstellungen.liniendiagramm(title, subtitle, footer, kategorien, data, series_label, export_filename, container_id); }); }); //VOT-13677 function onWindowsSize() { var w = window.innerWidth; var h = window.innerHeight; var charts = Highcharts.charts; if (!RESIZED){ charts.forEach(function (chart) { chart.container.hidden = true; }); setTimeout(function () { charts.forEach(function (chart) { chart.container.hidden = false; if (w < 1200){ chart.reflow(); RESIZED = true; } }); }, 100); } else { charts.forEach(function (chart) { console.log(chart); RESIZED = true; $(chart.renderTo).hide().show(0); //from cache setTimeout(function(){ window.location.reload(); window.location.reload(false); }); }); } } function newsbox(wahlid) { $.getJSON("newsbox.json", function(data) { // Newsbox Nachrichten anzeigen $.each(data.newsbox, function(key, news) { if (news.wahlid == wahlid && news.text.length > 0) { var title = news.title; var content = news.text; if (title.length > 0) { title = "" + title + ": "; } $("#newsbox").html( "
" + title + content + "
"); } }); }); } function ergebnisStatus(wahlid) { $.getJSON("status.json", function(data) { // Ergebnis-Status anzeigen $.each(data.ergebnisStatus, function(key, status) { if (status.wahlid == wahlid && status.status.length > 0) { $("#ergebnisStatus").html(status.status).show(); } }); }).fail(function(jqxhr, textStatus, error) { console.log(error); }); } /** * SetUp der Tabellen bei den Wahlgebietsübersichten (Nicht einfache Tabellen, * wie z.B. neben dem Ebenenergebnis) */ function setUpTablePage() { // Sucht in der Tabelle nach dem eingegebenden Suchfeld (on the fly) $('#search').keyup(function() { var inputVal = $(this).val(); var table = $('.searchtable'); table.find('tr').each(function(index, row) { var allCells = $(row).find('td'); if (allCells.length > 0) { var found = false; allCells.each(function(index, td) { var regExp = new RegExp(inputVal, 'i'); if (regExp.test($(td).text())) { found = true; return false; } }); if (found == true) $(row).show(); else $(row).hide(); } }); }); // Wendet das StickyTableHeader jQuery plugin auf die Tabelle an, so dass // beim Scrollen der Tabellen-Header im oberen Bereich des Viewports haften // bleibt. loadScript("js/jquery.stickytableheaders.min.js", function() { $('.stickyheader').stickyTableHeaders({ fixedOffset : $('.navbar-fixed-top') }); $('.tableFloatingHeaderOriginal').css('background-color', 'white'); }) // Baut ein JavaScript um die übergebene Tabelle, damit die Zeilen sortiert // werden können. Die Spalten 0 und 1 werden "textuell" sortiert, die Spalte // 2 numerisch und bei den übrigen Spalten wird von Prozent-Angaben // ausgegangen. loadScript("js/jquery.tablesorter.min.js", function() { jQuery.tablesorter.addParser({ id : 'prozente', is : function(s) { return /^\\d+,\\d+ \37$/.test(s); }, format : function(s) { return jQuery.tablesorter.formatInt(s.replace(/[, \37]/g, '')); }, type : 'numeric' }); jQuery.tablesorter.addParser({ id : 'formatiertezahlen', is : function(s) { return /^\d+{.\d+}+ /.test(s); }, format : function(s) { return jQuery.tablesorter.formatInt(s.replace(/[, \.]/g, '')); }, type : 'numeric' }); $('.tablesorter').tablesorter({ headers : { 0 : { sorter : 'text' }, 1 : { sorter : 'text' }, 2 : { sorter : 'formatiertezahlen' }, 3 : { sorter : 'prozente' }, 4 : { sorter : 'prozente' }, 5 : { sorter : 'prozente' }, 6 : { sorter : 'prozente' }, 7 : { sorter : 'prozente' }, 8 : { sorter : 'prozente' }, 9 : { sorter : 'prozente' }, 10 : { sorter : 'prozente' }, 11 : { sorter : 'prozente' }, } }); }) } function loadScript(url, callback) { var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState) { // IE script.onreadystatechange = function() { if (script.readyState === "loaded" || script.readyState === "complete") { script.onreadystatechange = null; callback(); } }; } else { // Andere script.onload = function() { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } // ///////////////////////////////////// this.Praesentation = this.Praesentation || {}; /** * Andere Namespaces evtl. inhouse, app, .... */ this.Praesentation.www = this.Praesentation.www || {}; this.Praesentation.www.darstellungen = this.Praesentation.www.darstellungen || {}; this.Praesentation.www.darstellungen.saeulendiagramm = function(title, subtitle, footer, balken, export_filename, container_id, xAxisEnabled, labelEnabled) { var series_data = new Array(); var drilldown_data = new Array(); var id = 0; $.each(balken, function(index, element) { var hasDrilldown = element.balken != null; var drilldown_id = "id" + id++; series_data.push({ name : element.name, y : element.y, color : element.color, label : element.label, drilldown : hasDrilldown ? drilldown_id : null }); if (hasDrilldown) { var entries = new Array(); $.each(element.balken, function(index, child_element) { entries.push({ name : child_element.name, y : child_element.y, color : child_element.color, label : child_element.label }); }); drilldown_data.push({ name : element.name, id : drilldown_id, data : entries }); } }); Highcharts.chart(container_id, { chart : { backgroundColor : null, type : 'column', marginBottom : xAxisEnabled?70:50 }, title : { text : title }, subtitle : { text : subtitle }, xAxis : { type : 'category', labels: { enabled: xAxisEnabled } }, yAxis : { title : { enabled : false } }, legend : { enabled : false }, plotOptions : { series : { borderWidth : 0, dataLabels : { enabled : labelEnabled, format : '{point.label}' } } }, tooltip : { headerFormat : null, pointFormat : '{point.label}' }, series : [ { colorByPoint : false, data : series_data } ], drilldown : { series : drilldown_data }, credits : { floating : true, text : '' + footer + '