<script language="javascript" type="text/javascript">

	document.getElementById("width_Btn").addEventListener("click", () => {
		
		if ( borderWidth_value == 1 ) { 
			borderWidth_value = 2;
			graphs_line_width = 2 ;
			document.getElementById("width_Btn").textContent  = "réduire l'épaisseur";
		}
		else { 
			borderWidth_value = 1; 
			graphs_line_width = 1 ;
			document.getElementById("width_Btn").textContent  = "augmenter l'épaisseur";
		}
		
		// T
		if ( '<?php echo($mesures_sondes_str[0]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_T.data.datasets.length; i++) { 
				chart_T.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_T.update();
		}
		
		// HR
		if ( '<?php echo($mesures_sondes_str[1]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_HR.data.datasets.length; i++) { 
				chart_HR.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_HR.update();
		}
		
		// CO2
		if ( '<?php echo($mesures_sondes_str[2]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_CO2.data.datasets.length; i++) { 
				chart_CO2.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_CO2.update();
		}
		
		// P
		if ( '<?php echo($mesures_sondes_str[3]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_P.data.datasets.length; i++) { 
				chart_P.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_P.update();
		}
		
		// COV
		if ( '<?php echo($mesures_sondes_str[4]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_COV.data.datasets.length; i++) { 
				chart_COV.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_COV.update();
		}
		
		// PM25
		if ( '<?php echo($mesures_sondes_str[5]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_PM25.data.datasets.length; i++) { 
				chart_PM25.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_PM25.update();
		}
		
		// HCHO
		if ( '<?php echo($mesures_sondes_str[6]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_HCHO.data.datasets.length; i++) { 
				chart_HCHO.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_HCHO.update();
		}
		
		// LUX
		if ( '<?php echo($mesures_sondes_str[7]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_LUX.data.datasets.length; i++) { 
				chart_LUX.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_LUX.update();
		}
		
		// SPL et SPL_peak
		if ( '<?php echo($mesures_sondes_str[8]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_SPL.data.datasets.length; i++) { 
				chart_SPL.data.datasets[i].borderWidth = borderWidth_value;
				chart_SPL_peak.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_SPL.update();
			chart_SPL_peak.update();
		}
		
		// NOX_IAQ
		if ( '<?php echo($mesures_sondes_str[9]); ?>' == 'Y' ) {
			for (let i = 0; i < chart_NOX_IAQ.data.datasets.length; i++) { 
				chart_NOX_IAQ.data.datasets[i].borderWidth = borderWidth_value;
			}
			chart_NOX_IAQ.update();
		}
		
	});

	document.getElementById("seuil_Btn").addEventListener("click", () => {
		
		trigger_display = ! trigger_display;
		
		/* T */
		if ( '<?php echo($mesures_sondes_str[0]); ?>' == 'Y' ) {
			chart_T.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_T.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_T.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_T.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_T.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_T.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_T.update();
		}
		
		/* HR */
		if ( '<?php echo($mesures_sondes_str[1]); ?>' == 'Y' ) {
			chart_HR.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_HR.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_HR.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_HR.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_HR.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_HR.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_HR.update();
		}
		
		/* CO2 */
		if ( '<?php echo($mesures_sondes_str[2]); ?>' == 'Y' ) {
			chart_CO2.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_CO2.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_CO2.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_CO2.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_CO2.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_CO2.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_CO2.update();
		}

		/* P */
		if ( '<?php echo($mesures_sondes_str[3]); ?>' == 'Y' ) {
			chart_P.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_P.update();
		}
		
		/* COV */
		if ( '<?php echo($mesures_sondes_str[4]); ?>' == 'Y' ) {
			chart_COV.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_COV.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_COV.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_COV.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_COV.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_COV.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_COV.update();
		}

		/* PM25 */
		if ( '<?php echo($mesures_sondes_str[5]); ?>' == 'Y' ) {
			chart_PM25.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_PM25.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_PM25.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_PM25.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_PM25.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_PM25.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_PM25.update();
		}

		/* HCHO */
		if ( '<?php echo($mesures_sondes_str[6]); ?>' == 'Y' ) {
			chart_HCHO.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_HCHO.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_HCHO.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_HCHO.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_HCHO.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_HCHO.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_HCHO.update();
		}

		/* LUX */
		if ( '<?php echo($mesures_sondes_str[7]); ?>' == 'Y' ) {
			chart_LUX.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_LUX.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_LUX.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_LUX.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_LUX.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_LUX.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_LUX.update();
		}

		/* SPL */
		if ( '<?php echo($mesures_sondes_str[8]); ?>' == 'Y' ) {
			chart_SPL.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_SPL.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_SPL.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_SPL.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_SPL.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_SPL.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_SPL.update();
		}
		if ( '<?php echo($mesures_sondes_str[8]); ?>' == 'Y' ) {
			chart_SPL_peak.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_SPL_peak.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_SPL_peak.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_SPL_peak.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_SPL_peak.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_SPL_peak.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_SPL_peak.update();
		}

		/* NOX_IAQ */
		if ( '<?php echo($mesures_sondes_str[9]); ?>' == 'Y' ) {
			chart_NOX_IAQ.options.plugins.annotation.annotations.line0.display = trigger_display;
			chart_NOX_IAQ.options.plugins.annotation.annotations.line1.display = trigger_display;
			chart_NOX_IAQ.options.plugins.annotation.annotations.line2.display = trigger_display;
			chart_NOX_IAQ.options.plugins.annotation.annotations.line3.display = trigger_display;
			chart_NOX_IAQ.options.plugins.annotation.annotations.line4.display = trigger_display;
			chart_NOX_IAQ.options.plugins.annotation.annotations.line5.display = trigger_display;
			chart_NOX_IAQ.update();
		}


		if ( trigger_display ) {
			document.getElementById("seuil_Btn").textContent  = " cacher les seuils";
		}
		else {
			document.getElementById("seuil_Btn").textContent  = "montrer les seuils";
		}

	});



	document.getElementById("tooltip_Btn").addEventListener("click", () => {
		
		tooltip_enabled = ! tooltip_enabled;
		
		if ( '<?php echo($mesures_sondes_str[0]); ?>' == 'Y' ) {
			chart_T.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_T.update();
		}

		if ( '<?php echo($mesures_sondes_str[1]); ?>' == 'Y' ) {
			chart_HR.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_HR.update();
		}

		if ( '<?php echo($mesures_sondes_str[2]); ?>' == 'Y' ) {
			chart_CO2.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_CO2.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[3]); ?>' == 'Y' ) {
			chart_P.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_P.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[4]); ?>' == 'Y' ) {
			chart_COV.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_COV.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[5]); ?>' == 'Y' ) {
			chart_PM25.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_PM25.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[6]); ?>' == 'Y' ) {
			chart_HCHO.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_HCHO.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[7]); ?>' == 'Y' ) {
			chart_LUX.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_LUX.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[8]); ?>' == 'Y' ) {
			chart_SPL.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_SPL.update();
		}
		if ( '<?php echo($mesures_sondes_str[8]); ?>' == 'Y' ) {
			chart_SPL_peak.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_SPL_peak.update();
		}
		
		if ( '<?php echo($mesures_sondes_str[9]); ?>' == 'Y' ) {
			chart_NOX_IAQ.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_NOX_IAQ.update();
		}
		

		if ( tooltip_enabled ) {
			document.getElementById("tooltip_Btn").textContent  = " cacher les info-bulles";
		}
		else {
			document.getElementById("tooltip_Btn").textContent  = "montrer les info-bulles";
		}


	});


	
</script>

