$(document).ready(function(){ $.jqplot.sprintf.thousandsSeparator = '.'; /* Datuak HTML-aren hizkuntzaren arabera kargatzen dira */ var language = document.getElementById("language").value /* Grafikoa Y ardatzean ondo ikusteko gehitzen zaion kopurua */ var yAddedQuantity_CST_Aporta_PIB_TH = 0.5 /* Serieen datak hartzen ditu */ var datesArray_CST_Aporta_PIB_TH = datajson_CST_Aporta_PIB_TH[0] /* Grafikoaren titulu, azpititulu eta oina hartzen ditu jizkuntzaren arabera */ var graphNames_CST_Aporta_PIB_TH = getGraphNames(datajson_CST_Aporta_PIB_TH, language) document.getElementById("graphTitle_CST_Aporta_PIB_TH").innerHTML=graphNames_CST_Aporta_PIB_TH[0][1]; document.getElementById("graphSubtitle_CST_Aporta_PIB_TH").innerHTML=graphNames_CST_Aporta_PIB_TH[1][1]; document.getElementById("graphFoot_CST_Aporta_PIB_TH").innerHTML=graphNames_CST_Aporta_PIB_TH[2][1]; /* Serieen tituluak hartzen ditu hizkuntzaren arabera*/ var serieNames_CST_Aporta_PIB_TH = getSerieNames(datajson_CST_Aporta_PIB_TH, language) document.getElementById("serie1Name_CST_Aporta_PIB_TH").innerHTML=serieNames_CST_Aporta_PIB_TH[0]; document.getElementById("serie2Name_CST_Aporta_PIB_TH").innerHTML=serieNames_CST_Aporta_PIB_TH[1]; document.getElementById("serie3Name_CST_Aporta_PIB_TH").innerHTML=serieNames_CST_Aporta_PIB_TH[2]; document.getElementById("serie4Name_CST_Aporta_PIB_TH").innerHTML=serieNames_CST_Aporta_PIB_TH[3]; /* Serie guztien Array-a */ var series_CST_Aporta_PIB_TH = createSeriesNoDecimal(datajson_CST_Aporta_PIB_TH); /* Serie kopurua definitu */ var s1_CST_Aporta_PIB_TH = series_CST_Aporta_PIB_TH[0] var s2_CST_Aporta_PIB_TH = series_CST_Aporta_PIB_TH[1] var s3_CST_Aporta_PIB_TH = series_CST_Aporta_PIB_TH[2] var s4_CST_Aporta_PIB_TH = series_CST_Aporta_PIB_TH[3] /* Slider-aren minimoa eta maximoa */ var minSlider_CST_Aporta_PIB_TH = 0 var maxSlider_CST_Aporta_PIB_TH = s1_CST_Aporta_PIB_TH.length - 1 /* Slider-aren hasierako eta amaierako balioak lortzen dira*/ var firstRangeDate_CST_Aporta_PIB_TH = datajson_CST_Aporta_PIB_TH[datajson_CST_Aporta_PIB_TH.length-1][0] var lastRangeDate_CST_Aporta_PIB_TH = datajson_CST_Aporta_PIB_TH[datajson_CST_Aporta_PIB_TH.length-1][1] var minSliderPos_CST_Aporta_PIB_TH = getPositionInArrayOfDate(datesArray_CST_Aporta_PIB_TH, firstRangeDate_CST_Aporta_PIB_TH) var maxSliderPos_CST_Aporta_PIB_TH = getPositionInArrayOfDate(datesArray_CST_Aporta_PIB_TH, lastRangeDate_CST_Aporta_PIB_TH) /* Slider-a tartekatuta dagoenean mainGraph-eko Y ardatzaren minimoa eta maximoak finkatzeko*/ var startGraphSerie_CST_Aporta_PIB_TH = getAllValuesY([s1_CST_Aporta_PIB_TH,s2_CST_Aporta_PIB_TH,s3_CST_Aporta_PIB_TH,s4_CST_Aporta_PIB_TH], minSliderPos_CST_Aporta_PIB_TH, maxSliderPos_CST_Aporta_PIB_TH) var minYMainGraph_CST_Aporta_PIB_TH = getSerieMin(startGraphSerie_CST_Aporta_PIB_TH) var maxYMainGraph_CST_Aporta_PIB_TH = getSerieMax(startGraphSerie_CST_Aporta_PIB_TH) /* Serie guztiak array bakar batean batzen dira maximoa eta minimoa kalkulatzeko */ var sliderGraphSerie_CST_Aporta_PIB_TH = getAllValuesY([s1_CST_Aporta_PIB_TH,s2_CST_Aporta_PIB_TH,s3_CST_Aporta_PIB_TH,s4_CST_Aporta_PIB_TH],minSlider_CST_Aporta_PIB_TH,maxSlider_CST_Aporta_PIB_TH)//getAllValues(s1,s2,s3,s4) var minYSliderGraph_CST_Aporta_PIB_TH = getSerieMin(sliderGraphSerie_CST_Aporta_PIB_TH) var maxYSliderGraph_CST_Aporta_PIB_TH = getSerieMax(sliderGraphSerie_CST_Aporta_PIB_TH) /* Hasierako grafikoa zentratuta dagoenean, jatorrizko serieen azpi-serieak hartzen ditu, zentratze-tartearen araberakoak*/ var s1_zentr_CST_Aporta_PIB_TH = new Array() var s2_zentr_CST_Aporta_PIB_TH = new Array() var s3_zentr_CST_Aporta_PIB_TH = new Array() var s4_zentr_CST_Aporta_PIB_TH = new Array() var datesArray_zentr_CST_Aporta_PIB_TH = new Array() for(i=minSliderPos_CST_Aporta_PIB_TH;i<=maxSliderPos_CST_Aporta_PIB_TH;i++){ s1_zentr_CST_Aporta_PIB_TH.push(s1_CST_Aporta_PIB_TH[i]); s2_zentr_CST_Aporta_PIB_TH.push(s2_CST_Aporta_PIB_TH[i]); s3_zentr_CST_Aporta_PIB_TH.push(s3_CST_Aporta_PIB_TH[i]); s4_zentr_CST_Aporta_PIB_TH.push(s4_CST_Aporta_PIB_TH[i]); datesArray_zentr_CST_Aporta_PIB_TH.push(s1_CST_Aporta_PIB_TH[i][0]) } /* Serieen kopiak x ardatzeko datu numerikoekin (zenbakiak daten ordez) */ s1_kopia_CST_Aporta_PIB_TH = changeSeries(s1_CST_Aporta_PIB_TH) s2_kopia_CST_Aporta_PIB_TH = changeSeries(s2_CST_Aporta_PIB_TH) s3_kopia_CST_Aporta_PIB_TH = changeSeries(s3_CST_Aporta_PIB_TH) s4_kopia_CST_Aporta_PIB_TH = changeSeries(s4_CST_Aporta_PIB_TH) s1_zentr_kopia_CST_Aporta_PIB_TH = changeSeries(s1_zentr_CST_Aporta_PIB_TH) s2_zentr_kopia_CST_Aporta_PIB_TH = changeSeries(s2_zentr_CST_Aporta_PIB_TH) s3_zentr_kopia_CST_Aporta_PIB_TH = changeSeries(s3_zentr_CST_Aporta_PIB_TH) s4_zentr_kopia_CST_Aporta_PIB_TH = changeSeries(s4_zentr_CST_Aporta_PIB_TH) s1_hidden_CST_Aporta_PIB_TH = new Array() for(i=0;i"; html_CST_Aporta_PIB_TH += "
"; html_CST_Aporta_PIB_TH += s_name_CST_Aporta_PIB_TH + ": "; html_CST_Aporta_PIB_TH += "" + number_format(value_CST_Aporta_PIB_TH,2) + ""; html_CST_Aporta_PIB_TH += ""; return html_CST_Aporta_PIB_TH; }, sizeAdjust: 8.5, //tooltipLocation : 'n' } }); function number_format(amount, decimals) { amount += ''; // por si pasan un numero en vez de un string amount = parseFloat(amount.replace(/[^0-9\.\-]/g, '')); // elimino cualquier cosa que no sea numero o punto decimals = decimals || 0; // por si la variable no fue fue pasada //if (amount % 1 != 0) decimals = 2; // si no es un numero o es igual a cero retorno el mismo cero if (isNaN(amount) || amount === 0) return parseFloat(0).toFixed(decimals); // si es mayor o menor que cero retorno el valor formateado como numero amount = '' + amount.toFixed(decimals); var amount_parts = amount.split('.'), regexp = /(\d+)(\d{3})/; while (regexp.test(amount_parts[0])) amount_parts[0] = amount_parts[0].replace(regexp, '$1' + '.' + '$2'); return amount_parts.join(','); } var clickSerie1_CST_Aporta_PIB_TH = true var clickSerie2_CST_Aporta_PIB_TH = true var clickSerie3_CST_Aporta_PIB_TH = true var clickSerie4_CST_Aporta_PIB_TH = true if (!document.getElementById("s1_checkbox_CST_Aporta_PIB_TH").checked) clickSerie1_CST_Aporta_PIB_TH = false; if (!document.getElementById("s2_checkbox_CST_Aporta_PIB_TH").checked) clickSerie2_CST_Aporta_PIB_TH = false; if (!document.getElementById("s3_checkbox_CST_Aporta_PIB_TH").checked) clickSerie3_CST_Aporta_PIB_TH = false; if (!document.getElementById("s4_checkbox_CST_Aporta_PIB_TH").checked) clickSerie4_CST_Aporta_PIB_TH = false; mainChart_CST_Aporta_PIB_TH.series[0].show = clickSerie1_CST_Aporta_PIB_TH; mainChart_CST_Aporta_PIB_TH.series[1].show = clickSerie2_CST_Aporta_PIB_TH; mainChart_CST_Aporta_PIB_TH.series[2].show = clickSerie3_CST_Aporta_PIB_TH; mainChart_CST_Aporta_PIB_TH.series[3].show = clickSerie4_CST_Aporta_PIB_TH; // Ezkutatuta dagoen seriea tooltipa ez agertzeko //mainChart_CST_Aporta_PIB_TH.series[4].show = false; /* Legend-a y ardatzeko canvas overlay-aren gainean ikusteko */ $.jqplot.postDrawHooks.push(function() { $(".jqplot-overlayCanvas-canvas").css('z-index', '0'); //send overlay canvas to back $(".jqplot-highlighter-tooltip").css('z-index', '1'); //make sure the tooltip is over the series }); /* Lehenengo serieari garrantzia emateko */ mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(0) mainChart_CST_Aporta_PIB_TH.replot() /* Legendako serieak erakusteko/ez erakusteko */ var leftSliderPos_CST_Aporta_PIB_TH = minSliderPos_CST_Aporta_PIB_TH var rightSliderPos_CST_Aporta_PIB_TH = maxSliderPos_CST_Aporta_PIB_TH var minLegend_CST_Aporta_PIB_TH var maxLegend_CST_Aporta_PIB_TH var seriesStringAll_CST_Aporta_PIB_TH = ["s1","s2","s3","s4"] var seriesStringActual_CST_Aporta_PIB_TH = ["s1","s2","s3","s4"] var seriesAll_CST_Aporta_PIB_TH = [s1_CST_Aporta_PIB_TH,s2_CST_Aporta_PIB_TH,s3_CST_Aporta_PIB_TH,s4_CST_Aporta_PIB_TH] var seriesActual_CST_Aporta_PIB_TH; seriesStringActual_CST_Aporta_PIB_TH = getSeriesClickedOnLegend(this, seriesStringActual_CST_Aporta_PIB_TH, seriesStringAll_CST_Aporta_PIB_TH, mainChart_CST_Aporta_PIB_TH) seriesActual_CST_Aporta_PIB_TH = getSeriesFromString(seriesStringActual_CST_Aporta_PIB_TH, seriesAll_CST_Aporta_PIB_TH) if(seriesActual_CST_Aporta_PIB_TH.length>0){ allSeries_CST_Aporta_PIB_TH = getAllValuesY(seriesActual_CST_Aporta_PIB_TH,leftSliderPos_CST_Aporta_PIB_TH,rightSliderPos_CST_Aporta_PIB_TH) minLegend_CST_Aporta_PIB_TH = getSerieMin(allSeries_CST_Aporta_PIB_TH) maxLegend_CST_Aporta_PIB_TH = getSerieMax(allSeries_CST_Aporta_PIB_TH) } else{ minLegend_CST_Aporta_PIB_TH=-20 maxLegend_CST_Aporta_PIB_TH=20 } var seriesWidth_CST_Aporta_PIB_TH = [1, 2, 1, 2] $("input[type=checkbox]").click(function(){ if(this.id == "s1_checkbox_CST_Aporta_PIB_TH") clickSerie1_CST_Aporta_PIB_TH = this.checked else if(this.id == "s2_checkbox_CST_Aporta_PIB_TH") clickSerie2_CST_Aporta_PIB_TH = this.checked else if(this.id == "s3_checkbox_CST_Aporta_PIB_TH") clickSerie3_CST_Aporta_PIB_TH = this.checked else if(this.id == "s4_checkbox_CST_Aporta_PIB_TH") clickSerie4_CST_Aporta_PIB_TH= this.checked // Ezkutatuta dagoen seriea tooltipa ez agertzeko mainChart_CST_Aporta_PIB_TH.series[4].show = false; mainChart_CST_Aporta_PIB_TH.series[0].show = clickSerie1_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[1].show = clickSerie2_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[2].show = clickSerie3_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[3].show = clickSerie4_CST_Aporta_PIB_TH seriesStringActual_CST_Aporta_PIB_TH = getSeriesClickedOnLegend(this, seriesStringActual_CST_Aporta_PIB_TH, seriesStringAll_CST_Aporta_PIB_TH, mainChart_CST_Aporta_PIB_TH) seriesActual_CST_Aporta_PIB_TH = getSeriesFromString(seriesStringActual_CST_Aporta_PIB_TH, seriesAll_CST_Aporta_PIB_TH) if(seriesActual_CST_Aporta_PIB_TH.length>0){ allSeries_CST_Aporta_PIB_TH = getAllValuesY(seriesActual_CST_Aporta_PIB_TH,leftSliderPos_CST_Aporta_PIB_TH,rightSliderPos_CST_Aporta_PIB_TH) minLegend_CST_Aporta_PIB_TH = getSerieMin(allSeries_CST_Aporta_PIB_TH) maxLegend_CST_Aporta_PIB_TH = getSerieMax(allSeries_CST_Aporta_PIB_TH) } else{ minLegend_CST_Aporta_PIB_TH=-20 maxLegend_CST_Aporta_PIB_TH=20 } mainChart_CST_Aporta_PIB_TH.axes.yaxis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.axes.y2axis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot() }); $("p").mouseenter(function() { // Ezkutatuta dagoen seriea tooltipa ez agertzeko mainChart_CST_Aporta_PIB_TH.series[4].show = false; elementId_CST_Aporta_PIB_TH = this.id clicks_CST_Aporta_PIB_TH = [clickSerie1_CST_Aporta_PIB_TH,clickSerie2_CST_Aporta_PIB_TH,clickSerie3_CST_Aporta_PIB_TH,clickSerie4_CST_Aporta_PIB_TH] if(elementId_CST_Aporta_PIB_TH == "serie1Name_CST_Aporta_PIB_TH" && clickSerie1_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "enter", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(0) } else if(elementId_CST_Aporta_PIB_TH == "serie2Name_CST_Aporta_PIB_TH" && clickSerie2_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "enter", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(1) } else if(elementId_CST_Aporta_PIB_TH == "serie3Name_CST_Aporta_PIB_TH" && clickSerie3_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "enter", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(2) } else if(elementId_CST_Aporta_PIB_TH == "serie4Name_CST_Aporta_PIB_TH" && clickSerie4_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "enter", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(3) } seriesStringActual_CST_Aporta_PIB_TH = getSeriesClickedOnLegend(this, seriesStringActual_CST_Aporta_PIB_TH, seriesStringAll_CST_Aporta_PIB_TH, mainChart_CST_Aporta_PIB_TH) seriesActual_CST_Aporta_PIB_TH = getSeriesFromString(seriesStringActual_CST_Aporta_PIB_TH, seriesAll_CST_Aporta_PIB_TH) if(seriesActual_CST_Aporta_PIB_TH.length>0){ allSeries_CST_Aporta_PIB_TH = getAllValuesY(seriesActual_CST_Aporta_PIB_TH,leftSliderPos_CST_Aporta_PIB_TH,rightSliderPos_CST_Aporta_PIB_TH) minLegend_CST_Aporta_PIB_TH = getSerieMin(allSeries_CST_Aporta_PIB_TH) maxLegend_CST_Aporta_PIB_TH = getSerieMax(allSeries_CST_Aporta_PIB_TH) } else{ minLegend_CST_Aporta_PIB_TH=-20 maxLegend_CST_Aporta_PIB_TH=20 } mainChart_CST_Aporta_PIB_TH.axes.yaxis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.axes.y2axis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.series[0].show = clickSerie1_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[1].show = clickSerie2_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[2].show = clickSerie3_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[3].show = clickSerie4_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.replot() }) $("p").mouseleave(function() { // Ezkutatuta dagoen seriea tooltipa ez agertzeko mainChart_CST_Aporta_PIB_TH.series[4].show = false; elementId_CST_Aporta_PIB_TH = this.id clicks_CST_Aporta_PIB_TH = [clickSerie1_CST_Aporta_PIB_TH,clickSerie2_CST_Aporta_PIB_TH,clickSerie3_CST_Aporta_PIB_TH,clickSerie4_CST_Aporta_PIB_TH] if(elementId_CST_Aporta_PIB_TH == "serie1Name_CST_Aporta_PIB_TH" && clickSerie1_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "exit", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) } else if(elementId_CST_Aporta_PIB_TH == "serie2Name_CST_Aporta_PIB_TH" && clickSerie2_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "exit", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) } else if(elementId_CST_Aporta_PIB_TH == "serie3Name_CST_Aporta_PIB_TH" && clickSerie3_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "exit", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) } else if(elementId_CST_Aporta_PIB_TH == "serie4Name_CST_Aporta_PIB_TH" && clickSerie4_CST_Aporta_PIB_TH == true){ series_CST_Aporta_PIB_TH = repaintLineWidth(elementId_CST_Aporta_PIB_TH, "exit", mainChart_CST_Aporta_PIB_TH, clicks_CST_Aporta_PIB_TH, seriesWidth_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot({series:series_CST_Aporta_PIB_TH}) } mainChart_CST_Aporta_PIB_TH.axes.yaxis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.axes.y2axis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.series[0].show = clickSerie1_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[1].show = clickSerie2_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[2].show = clickSerie3_CST_Aporta_PIB_TH mainChart_CST_Aporta_PIB_TH.series[3].show = clickSerie4_CST_Aporta_PIB_TH /* Lehenengo serieari garrantzia emateko */ mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(0) mainChart_CST_Aporta_PIB_TH.replot() }) /* Slider-aren grafikoa marraztu */ var sliderChart_CST_Aporta_PIB_TH = $.jqplot ('chart2_CST_Aporta_PIB_TH', [s1_kopia_CST_Aporta_PIB_TH,s2_kopia_CST_Aporta_PIB_TH,s3_kopia_CST_Aporta_PIB_TH,s4_kopia_CST_Aporta_PIB_TH], { grid: { background: 'white', drawBorder: false, shadow: false, }, seriesColors: ["#0000FF", "#FFA500", "#008000", "#FF0000"], series:[ {label:serieNames_CST_Aporta_PIB_TH[0],renderer:$.jqplot.LineRenderer,color: "#0000FF",lineWidth: 1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {label:serieNames_CST_Aporta_PIB_TH[1],renderer:$.jqplot.LineRenderer,color: "#FFA500",lineWidth: 1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {label:serieNames_CST_Aporta_PIB_TH[2],renderer:$.jqplot.LineRenderer,color: "#008000",lineWidth: 1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {label:serieNames_CST_Aporta_PIB_TH[3],renderer:$.jqplot.LineRenderer,color: "#FF0000",lineWidth: 1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, ], axesDefaults: { labelRenderer: $.jqplot.CanvasAxisLabelRenderer }, axes: { xaxis: { //tickRenderer: $.jqplot.CanvasAxisTickRenderer, tickOptions: { formatter: function (format, val) { tickName_CST_Aporta_PIB_TH = formatTickLabelSlider(val, s1_kopia_CST_Aporta_PIB_TH[0][0], s1_kopia_CST_Aporta_PIB_TH[s1_kopia_CST_Aporta_PIB_TH.length-1][0], s1_CST_Aporta_PIB_TH, language, "yearly_data") return tickName_CST_Aporta_PIB_TH }, textColor: 'black' }, ticks : getXRangeSlider(s1_kopia_CST_Aporta_PIB_TH[0][0], s1_kopia_CST_Aporta_PIB_TH[s1_kopia_CST_Aporta_PIB_TH.length-1][0]), drawMajorGridlines: true, drawMinorGridlines: true }, yaxis: { rendererOptions: {forceTickAt0: true}, tickOptions: {formatString: "%#.1f" }, showTicks: false, min: 1, max:maxYSliderGraph_CST_Aporta_PIB_TH + yAddedQuantity_CST_Aporta_PIB_TH } } }); /* SliderChart-eko hasierako laukizuzenak marrazteko*/ sliderChart_CST_Aporta_PIB_TH.replot({ canvasOverlay: { show: true, objects: [ { rectangle: { xmin:0,xmax: minSliderPos_CST_Aporta_PIB_TH, xminOffset: "0px", xmaxOffset: "0px", yminOffset: "0px", ymaxOffset: "0px", color: "rgba(192,192,192,0.5)"} }, { rectangle: { xmin:maxSliderPos_CST_Aporta_PIB_TH,xmax: s1_kopia_CST_Aporta_PIB_TH[s1_kopia_CST_Aporta_PIB_TH.length - 1][0], xminOffset: "0px", xmaxOffset: "0px", yminOffset: "0px", ymaxOffset: "0px", color: "rgba(192,192,192,0.5)"} } ] } }) sliderChart_CST_Aporta_PIB_TH.moveSeriesToFront(0) /* Slider-a marraztu */ $("#slider_CST_Aporta_PIB_TH").slider({ max: maxSlider_CST_Aporta_PIB_TH, min: minSlider_CST_Aporta_PIB_TH, range: true, values: [ minSliderPos_CST_Aporta_PIB_TH, maxSliderPos_CST_Aporta_PIB_TH ], slide: function(event,ui){ var serie1New_CST_Aporta_PIB_TH = new Array() var serie2New_CST_Aporta_PIB_TH = new Array() var serie3New_CST_Aporta_PIB_TH = new Array() var serie4New_CST_Aporta_PIB_TH = new Array() var datesArrayBerria_CST_Aporta_PIB_TH = new Array() for(i=ui.values[0];i<=ui.values[1];i++) { serie1New_CST_Aporta_PIB_TH.push(s1_CST_Aporta_PIB_TH[i]); serie2New_CST_Aporta_PIB_TH.push(s2_CST_Aporta_PIB_TH[i]); serie3New_CST_Aporta_PIB_TH.push(s3_CST_Aporta_PIB_TH[i]); serie4New_CST_Aporta_PIB_TH.push(s4_CST_Aporta_PIB_TH[i]); datesArrayBerria_CST_Aporta_PIB_TH.push(s1_CST_Aporta_PIB_TH[i][0]) } var valuesNew_CST_Aporta_PIB_TH = getAllValuesY([serie1New_CST_Aporta_PIB_TH, serie2New_CST_Aporta_PIB_TH, serie3New_CST_Aporta_PIB_TH,serie4New_CST_Aporta_PIB_TH],0,serie1New_CST_Aporta_PIB_TH.length-1) min_CST_Aporta_PIB_TH = getSerieMin(valuesNew_CST_Aporta_PIB_TH) max_CST_Aporta_PIB_TH = getSerieMax(valuesNew_CST_Aporta_PIB_TH) serieBerria1_CST_Aporta_PIB_TH = changeSeries(serie1New_CST_Aporta_PIB_TH) serieBerria2_CST_Aporta_PIB_TH = changeSeries(serie2New_CST_Aporta_PIB_TH) serieBerria3_CST_Aporta_PIB_TH = changeSeries(serie3New_CST_Aporta_PIB_TH) serieBerria4_CST_Aporta_PIB_TH = changeSeries(serie4New_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.destroy() mainChart_CST_Aporta_PIB_TH = $.jqplot ('chart1_CST_Aporta_PIB_TH', [serieBerria1_CST_Aporta_PIB_TH,serieBerria2_CST_Aporta_PIB_TH,serieBerria3_CST_Aporta_PIB_TH, serieBerria4_CST_Aporta_PIB_TH,s1_hidden_CST_Aporta_PIB_TH], { grid: { background: 'white', drawBorder: false, shadow: false, }, canvasOverlay: { show: true, objects: [ { horizontalLine:{ y: 0, xminOffset: "0px", xmaxOffset: "0px", lineWidth: 1, color: "black", shadow: false, name: "0" } } ] }, seriesColors: ["#0000FF", "#FFA500", "#008000", "#FF0000", "black"], series:[ {label:serieNames_CST_Aporta_PIB_TH[0],show:document.getElementById("s1_checkbox_CST_Aporta_PIB_TH").checked,renderer:$.jqplot.LineRenderer,color:"#0000FF",lineWidth:1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {label:serieNames_CST_Aporta_PIB_TH[1],show:document.getElementById("s2_checkbox_CST_Aporta_PIB_TH").checked,renderer:$.jqplot.LineRenderer,color:"#FFA500",lineWidth:1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {label:serieNames_CST_Aporta_PIB_TH[2],show:document.getElementById("s3_checkbox_CST_Aporta_PIB_TH").checked,renderer:$.jqplot.LineRenderer,color:"#008000",lineWidth:1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {label:serieNames_CST_Aporta_PIB_TH[3],show:document.getElementById("s4_checkbox_CST_Aporta_PIB_TH").checked,renderer:$.jqplot.LineRenderer,color:"#FF0000",lineWidth:1,rendererOptions:{smooth:true},pointLabels:{show:false},markerOptions:{size:0}}, {yaxis:"y2axis",renderer:$.jqplot.LineRenderer,color:"#FF0000"} ], axesDefaults: { labelRenderer: $.jqplot.CanvasAxisLabelRenderer }, axes: { xaxis: { //tickRenderer: $.jqplot.CanvasAxisTickRenderer, tickOptions: { formatter: function (format, val) { tickName_CST_Aporta_PIB_TH = formatTickLabel(val, serieBerria1_CST_Aporta_PIB_TH[0][0], serieBerria1_CST_Aporta_PIB_TH[serieBerria1_CST_Aporta_PIB_TH.length-1][0], serie1New_CST_Aporta_PIB_TH, language, "yearly_data") return tickName_CST_Aporta_PIB_TH }, textColor: 'black' }, ticks : getXRange(serieBerria1_CST_Aporta_PIB_TH[0][0], serieBerria1_CST_Aporta_PIB_TH[serieBerria1_CST_Aporta_PIB_TH.length-1][0]), drawMajorGridlines: true }, yaxis: { tickOptions: {formatString: "%#.1f" }, ticks:getYRange(0, max_CST_Aporta_PIB_TH) }, y2axis: { rendererOptions: {alignTicks: true}, tickOptions: {formatString: "%#.1f" }, ticks:getYRange(0, max_CST_Aporta_PIB_TH) } }, highlighter: { show: true, tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) { var date_CST_Aporta_PIB_TH = datesArrayBerria_CST_Aporta_PIB_TH[plot.data[seriesIndex][pointIndex][0]]; var s_name_CST_Aporta_PIB_TH = plot.series[seriesIndex]["label"]; num_CST_Aporta_PIB_TH = plot.data[seriesIndex][pointIndex][1] var value_CST_Aporta_PIB_TH = num_CST_Aporta_PIB_TH//plot.data[seriesIndex][pointIndex][1]; var yearString_CST_Aporta_PIB_TH = date_CST_Aporta_PIB_TH.substring(6,10); var monthString_CST_Aporta_PIB_TH = date_CST_Aporta_PIB_TH.substring(3,5); if ("yearly_data"==="yearly_data") { monthName_CST_Aporta_PIB_TH = ""; } else if ("quarterly_data"==="yearly_data") { monthName_CST_Aporta_PIB_TH = getQuarter(monthString_CST_Aporta_PIB_TH, language) + ", "; } else { monthName_CST_Aporta_PIB_TH = getMonthHighlight(monthString_CST_Aporta_PIB_TH, language) + ", "; } var html_CST_Aporta_PIB_TH = "
"; html_CST_Aporta_PIB_TH += "" + monthName_CST_Aporta_PIB_TH + yearString_CST_Aporta_PIB_TH + ""; html_CST_Aporta_PIB_TH += "
"; html_CST_Aporta_PIB_TH += s_name_CST_Aporta_PIB_TH + ": "; html_CST_Aporta_PIB_TH += "" + number_format(value_CST_Aporta_PIB_TH, 2) + ""; html_CST_Aporta_PIB_TH += "
"; return html_CST_Aporta_PIB_TH; }, sizeAdjust: 8.5, //tooltipLocation : 'n' } }); // Ezkutatuta dagoen seriea tooltipa ez agertzeko mainChart_CST_Aporta_PIB_TH.series[4].show = false; /* Line-chart-ari dagokion lehenengo serieari garrantzia emateko */ mainChart_CST_Aporta_PIB_TH.moveSeriesToFront(0) /* SliderChart-eko momentuko laukizuzenak marrazteko*/ sliderChart_CST_Aporta_PIB_TH.replot({ canvasOverlay: { show: true, objects: [ { rectangle: { xmin:0,xmax: ui.values[0], xminOffset: "0px", xmaxOffset: "0px", yminOffset: "0px", ymaxOffset: "0px", color: "rgba(192,192,192,0.5)"} }, { rectangle: { xmin:ui.values[1],xmax: s1_kopia_CST_Aporta_PIB_TH[s1_kopia_CST_Aporta_PIB_TH.length - 1][0], xminOffset: "0px", xmaxOffset: "0px", yminOffset: "0px", ymaxOffset: "0px", color: "rgba(192,192,192,0.5)"} } ] } }) sliderChart_CST_Aporta_PIB_TH.moveSeriesToFront(0) /* Legendan klikatuta dauden serieen maximo eta minimoa eguneratzeko*/ leftSliderPos_CST_Aporta_PIB_TH = ui.values[0] rightSliderPos_CST_Aporta_PIB_TH = ui.values[1] seriesStringActual_CST_Aporta_PIB_TH = getSeriesClickedOnLegend(this, seriesStringActual_CST_Aporta_PIB_TH, seriesStringAll_CST_Aporta_PIB_TH, mainChart_CST_Aporta_PIB_TH) seriesActual_CST_Aporta_PIB_TH = getSeriesFromString(seriesStringActual_CST_Aporta_PIB_TH, seriesAll_CST_Aporta_PIB_TH) allSeries_CST_Aporta_PIB_TH = getAllValuesY(seriesActual_CST_Aporta_PIB_TH,leftSliderPos_CST_Aporta_PIB_TH,rightSliderPos_CST_Aporta_PIB_TH) minLegend_CST_Aporta_PIB_TH = getSerieMin(allSeries_CST_Aporta_PIB_TH) maxLegend_CST_Aporta_PIB_TH = getSerieMax(allSeries_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.axes.yaxis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.axes.y2axis.ticks = getYRange(1, maxLegend_CST_Aporta_PIB_TH) mainChart_CST_Aporta_PIB_TH.replot(); } }); /* */ function repaintLineWidth(serieId, eventType, mainChart, clicks, seriesWidth){ var series_CST_Aporta_PIB_TH; if (serieId == "serie1Name_CST_Aporta_PIB_TH" && eventType == "enter"){ if(clicks[0] == true) seriesWidth[0] = seriesWidth[0] + 1 document.getElementById(serieId).setAttribute("style", "background: rgba(192,192,192,0.5); border-style:solid; border-width:1px; border-color:black; font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } else if (serieId == "serie1Name_CST_Aporta_PIB_TH" && eventType == "exit"){ if(clicks[0] == true) seriesWidth[0] = seriesWidth[0] -1 document.getElementById(serieId).setAttribute("style", "font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } if (serieId == "serie2Name_CST_Aporta_PIB_TH" && eventType == "enter"){ if(clicks[1] == true)seriesWidth[1] = seriesWidth[1] + 1 document.getElementById(serieId).setAttribute("style", "background: rgba(192,192,192,0.5); border-style:solid; border-width:1px; border-color:black; font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } else if (serieId == "serie2Name_CST_Aporta_PIB_TH" && eventType == "exit"){ if(clicks[1] == true)seriesWidth[1] = seriesWidth[1] - 1 document.getElementById(serieId).setAttribute("style", "font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } if (serieId == "serie3Name_CST_Aporta_PIB_TH" && eventType == "enter"){ if(clicks[2] == true)seriesWidth[2] = seriesWidth[2] + 1 document.getElementById(serieId).setAttribute("style", "background: rgba(192,192,192,0.5); border-style:solid; border-width:1px; border-color:black; font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } else if (serieId == "serie3Name_CST_Aporta_PIB_TH" && eventType == "exit"){ if(clicks[2] == true)seriesWidth[2] = seriesWidth[2] - 1 document.getElementById(serieId).setAttribute("style", "font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } if (serieId == "serie4Name_CST_Aporta_PIB_TH" && eventType == "enter"){ if(clicks[3] == true)seriesWidth[3] = seriesWidth[3] + 1 document.getElementById(serieId).setAttribute("style", "background: rgba(192,192,192,0.5); border-style:solid; border-width:1px; border-color:black; font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } else if (serieId == "serie4Name_CST_Aporta_PIB_TH" && eventType == "exit"){ if(clicks[3] == true)seriesWidth[3] = seriesWidth[3] - 1 document.getElementById(serieId).setAttribute("style", "font-family: Verdana !important; font-size: TAMANOpx; font-style: italic; font-weight: normal;"); } series_CST_Aporta_PIB_TH = [{lineWidth: seriesWidth[0]},{lineWidth: seriesWidth[1]},{lineWidth: seriesWidth[2]},{lineWidth: seriesWidth[3]},{lineWidth: 0.01}] return series_CST_Aporta_PIB_TH; } /* Funtzio honek Legend-an klikaturik dauden serieen array-a itzultzen du eta seriea pintatu/ez pintatu */ function getSeriesClickedOnLegend(thisClicked, seriesActual, seriesAll, mainChart){ result_CST_Aporta_PIB_TH = seriesActual if(thisClicked.value=="s1_legend_CST_Aporta_PIB_TH"){ index = indexOfSerieClicked(thisClicked.value, seriesActual) if(thisClicked.checked == true){ result_CST_Aporta_PIB_TH.splice(index, 0, seriesAll[0]); } else{ result_CST_Aporta_PIB_TH.splice(index, 1); } mainChart.series[0].show = thisClicked.checked; } if(thisClicked.value=="s2_legend_CST_Aporta_PIB_TH"){ index = indexOfSerieClicked(thisClicked.value, seriesActual) if(thisClicked.checked == true){ result_CST_Aporta_PIB_TH.splice(index, 0, seriesAll[1]); } else{ result_CST_Aporta_PIB_TH.splice(index, 1); } mainChart.series[1].show = thisClicked.checked; } if(thisClicked.value=="s3_legend_CST_Aporta_PIB_TH"){ index = indexOfSerieClicked(thisClicked.value, seriesActual) if(thisClicked.checked == true){ result_CST_Aporta_PIB_TH.splice(index, 0, seriesAll[2]); } else{ result_CST_Aporta_PIB_TH.splice(index, 1); } mainChart.series[2].show = thisClicked.checked; } if(thisClicked.value=="s4_legend_CST_Aporta_PIB_TH"){ index = indexOfSerieClicked(thisClicked.value, seriesActual) if(thisClicked.checked == true){ result_CST_Aporta_PIB_TH.splice(index, 0, seriesAll[3]); } else{ result_CST_Aporta_PIB_TH.splice(index, 1); } mainChart.series[3].show = thisClicked.checked; } return result_CST_Aporta_PIB_TH } });