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

	document.getElementById("seuil_Btn").addEventListener("click", () => {
		
		trigger_display = ! trigger_display;
		
		/* T */
		if ( '<?php echo($aqcm_MESURES[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($aqcm_MESURES[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($aqcm_MESURES[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($aqcm_MESURES[3]); ?>' == 'Y' ) {
		}

		/* COV */
		if ( '<?php echo($aqcm_MESURES[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();
		}

		/* PM2.5 et PM10 */
		if ( '<?php echo($aqcm_MESURES[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($aqcm_MESURES[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($aqcm_MESURES[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($aqcm_MESURES[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();
		}

		/* NOX_IAQ */
		if ( '<?php echo($aqcm_MESURES[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("FS_Btn").addEventListener("click", () => {
		
		FS_max = ! FS_max;
		
		if ( FS_max ) {
			document.getElementById("FS_Btn").textContent  = "réduire la pleine échelle";
		}
		else {
			document.getElementById("FS_Btn").textContent  = "augmenter la pleine échelle";
		}

		if ( '<?php echo($aqcm_MESURES[0]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				chart_T.options.scales.y.max = <?php echo($FS_MAX_T_max); ?> ;
				chart_T.options.scales.y.min = <?php echo($FS_MIN_T_min); ?> ;
				chart_T.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_T_TRIG_0; ?> + trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_T_TRIG_0; ?> - trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_T_TRIG_1; ?> + trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_T_TRIG_1; ?> - trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_T_TRIG_2; ?> + trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_T_TRIG_2; ?> - trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_T_TRIG_3; ?> + trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_T_TRIG_3; ?> - trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_T_TRIG_4; ?> + trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_T_TRIG_4; ?> - trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_T_TRIG_5; ?> + trig_line_T_max ;
				chart_T.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_T_TRIG_5; ?> - trig_line_T_max ;
			} else {
				chart_T.options.scales.y.max = <?php echo($FS_MAX_T_moy); ?> ;
				chart_T.options.scales.y.min = <?php echo($FS_MIN_T_moy); ?> ;
				chart_T.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_T_TRIG_0; ?> + trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_T_TRIG_0; ?> - trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_T_TRIG_1; ?> + trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_T_TRIG_1; ?> - trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_T_TRIG_2; ?> + trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_T_TRIG_2; ?> - trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_T_TRIG_3; ?> + trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_T_TRIG_3; ?> - trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_T_TRIG_4; ?> + trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_T_TRIG_4; ?> - trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_T_TRIG_5; ?> + trig_line_T_moy ;
				chart_T.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_T_TRIG_5; ?> - trig_line_T_moy ;
			}

			chart_T.update();

		}

		if ( '<?php echo($aqcm_MESURES[2]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				FS_CO2 = <?php echo($FS_MAX_CO2_max); ?> ;

				chart_CO2.options.scales.y.max = <?php echo($FS_MAX_CO2_max); ?> ;
				chart_CO2.options.scales.y.min = <?php echo($FS_MIN_CO2_min); ?> ;

				OPTIONS_SCALES_Y_padding_index_CO2 = 3;
				if ( <?php echo($FS_MAX_CO2_max); ?> >=  1000 ) { OPTIONS_SCALES_Y_padding_index_CO2 = 4; }
				if ( <?php echo($FS_MAX_CO2_max); ?> >= 10000 ) { OPTIONS_SCALES_Y_padding_index_CO2 = 5; }

				chart_CO2.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_CO2_TRIG_0; ?> + trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_CO2_TRIG_0; ?> - trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_CO2_TRIG_1; ?> + trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_CO2_TRIG_1; ?> - trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_CO2_TRIG_2; ?> + trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_CO2_TRIG_2; ?> - trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_CO2_TRIG_3; ?> + trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_CO2_TRIG_3; ?> - trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_CO2_TRIG_4; ?> + trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_CO2_TRIG_4; ?> - trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_CO2_TRIG_5; ?> + trig_line_CO2_max ;
				chart_CO2.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_CO2_TRIG_5; ?> - trig_line_CO2_max ;

			} else {
				
				FS_CO2 = <?php echo($FS_MAX_CO2_moy); ?> ;

				chart_CO2.options.scales.y.max = <?php echo($FS_MAX_CO2_moy); ?> ;
				chart_CO2.options.scales.y.min = <?php echo($FS_MIN_CO2_moy); ?> ;

				OPTIONS_SCALES_Y_padding_index_CO2 = 3;
				if ( <?php echo($FS_MAX_CO2_moy); ?> >=  1000 ) { OPTIONS_SCALES_Y_padding_index_CO2 = 4; }
				if ( <?php echo($FS_MAX_CO2_moy); ?> >= 10000 ) { OPTIONS_SCALES_Y_padding_index_CO2 = 5; }

				chart_CO2.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_CO2_TRIG_0; ?> + trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_CO2_TRIG_0; ?> - trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_CO2_TRIG_1; ?> + trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_CO2_TRIG_1; ?> - trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_CO2_TRIG_2; ?> + trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_CO2_TRIG_2; ?> - trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_CO2_TRIG_3; ?> + trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_CO2_TRIG_3; ?> - trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_CO2_TRIG_4; ?> + trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_CO2_TRIG_4; ?> - trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_CO2_TRIG_5; ?> + trig_line_CO2_moy ;
				chart_CO2.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_CO2_TRIG_5; ?> - trig_line_CO2_moy ;

			}
			
			if ( FS_CO2 > 2000 ) {
				CO2_step_size = 200;
			} else {
				CO2_step_size = 100;
			}
			chart_CO2.options.scales.y.ticks.stepSize = CO2_step_size ;

			chart_CO2.options.scales.y.ticks.padding = OPTIONS_SCALES_Y_padding_array[OPTIONS_SCALES_Y_padding_index_CO2] ;
			chart_CO2.update();

		}

		if ( '<?php echo($aqcm_MESURES[3]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				chart_P.options.scales.y.max = <?php echo($FS_MAX_P_max); ?> ;
				chart_P.options.scales.y.min = <?php echo($FS_MIN_P_min); ?> ;

				OPTIONS_SCALES_Y_padding_index_P = 3;
				if ( <?php echo($FS_MAX_P_max); ?> >= 1000 ) { OPTIONS_SCALES_Y_padding_index_P = 4; }

			} else {
				
				chart_P.options.scales.y.max = <?php echo($FS_MAX_P_moy); ?> ;
				chart_P.options.scales.y.min = <?php echo($FS_MIN_P_moy); ?> ;

				OPTIONS_SCALES_Y_padding_index_P = 3;
				if ( <?php echo($FS_MAX_P_moy); ?> >= 1000 ) { OPTIONS_SCALES_Y_padding_index_P = 4; }

			}
			
			chart_P.options.scales.y.ticks.padding = OPTIONS_SCALES_Y_padding_array[OPTIONS_SCALES_Y_padding_index_P] ;
			chart_P.update();

		}

		if ( '<?php echo($aqcm_MESURES[5]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				chart_PM25.options.scales.y.max = <?php echo($FS_MAX_PM_max); ?> ;
				chart_PM25.options.scales.y.min = <?php echo($FS_MIN_PM_min); ?> ;

				OPTIONS_SCALES_Y_padding_index_PM = 2;
				if ( <?php echo($FS_MAX_PM_max); ?> >=  100 ) { OPTIONS_SCALES_Y_padding_index_PM = 3; }
				if ( <?php echo($FS_MAX_PM_max); ?> >= 1000 ) { OPTIONS_SCALES_Y_padding_index_PM = 4; }

				chart_PM25.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_PM25_TRIG_0; ?> + trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_PM25_TRIG_0; ?> - trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_PM25_TRIG_1; ?> + trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_PM25_TRIG_1; ?> - trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_PM25_TRIG_2; ?> + trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_PM25_TRIG_2; ?> - trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_PM25_TRIG_3; ?> + trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_PM25_TRIG_3; ?> - trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_PM25_TRIG_4; ?> + trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_PM25_TRIG_4; ?> - trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_PM25_TRIG_5; ?> + trig_line_PM_max ;
				chart_PM25.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_PM25_TRIG_5; ?> - trig_line_PM_max ;

			} else {
				
				chart_PM25.options.scales.y.max = <?php echo($FS_MAX_PM_moy); ?> ;
				chart_PM25.options.scales.y.min = <?php echo($FS_MIN_PM_moy); ?> ;

				OPTIONS_SCALES_Y_padding_index_PM = 2;
				if ( <?php echo($FS_MAX_PM_moy); ?> >=  100 ) { OPTIONS_SCALES_Y_padding_index_PM = 3; }
				if ( <?php echo($FS_MAX_PM_moy); ?> >= 1000 ) { OPTIONS_SCALES_Y_padding_index_PM = 4; }

				chart_PM25.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_PM25_TRIG_0; ?> + trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_PM25_TRIG_0; ?> - trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_PM25_TRIG_1; ?> + trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_PM25_TRIG_1; ?> - trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_PM25_TRIG_2; ?> + trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_PM25_TRIG_2; ?> - trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_PM25_TRIG_3; ?> + trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_PM25_TRIG_3; ?> - trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_PM25_TRIG_4; ?> + trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_PM25_TRIG_4; ?> - trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_PM25_TRIG_5; ?> + trig_line_PM_moy ;
				chart_PM25.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_PM25_TRIG_5; ?> - trig_line_PM_moy ;

			}
			
			chart_PM25.options.scales.y.ticks.padding = OPTIONS_SCALES_Y_padding_array[OPTIONS_SCALES_Y_padding_index_PM] ;
			chart_PM25.update();

		}

		if ( '<?php echo($aqcm_MESURES[6]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				chart_HCHO.options.scales.y.max = <?php echo($FS_MAX_HCHO_max); ?> ;
				chart_HCHO.options.scales.y.min = <?php echo($FS_MIN_HCHO_min); ?> ;

				OPTIONS_SCALES_Y_padding_index_HCHO = 2;
				if ( <?php echo($FS_MAX_HCHO_max); ?> >=  100 ) { OPTIONS_SCALES_Y_padding_index_HCHO = 3; }
				if ( <?php echo($FS_MAX_HCHO_max); ?> >= 1000 ) { OPTIONS_SCALES_Y_padding_index_HCHO = 4; }

				chart_HCHO.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_HCHO_TRIG_0; ?> + trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_HCHO_TRIG_0; ?> - trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_HCHO_TRIG_1; ?> + trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_HCHO_TRIG_1; ?> - trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_HCHO_TRIG_2; ?> + trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_HCHO_TRIG_2; ?> - trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_HCHO_TRIG_3; ?> + trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_HCHO_TRIG_3; ?> - trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_HCHO_TRIG_4; ?> + trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_HCHO_TRIG_4; ?> - trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_HCHO_TRIG_5; ?> + trig_line_HCHO_max ;
				chart_HCHO.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_HCHO_TRIG_5; ?> - trig_line_HCHO_max ;

			} else {
				
				chart_HCHO.options.scales.y.max = <?php echo($FS_MAX_HCHO_moy); ?> ;
				chart_HCHO.options.scales.y.min = <?php echo($FS_MIN_HCHO_moy); ?> ;

				OPTIONS_SCALES_Y_padding_index_HCHO = 2;
				if ( <?php echo($FS_MAX_HCHO_moy); ?> >=  100 ) { OPTIONS_SCALES_Y_padding_index_HCHO = 3; }
				if ( <?php echo($FS_MAX_HCHO_moy); ?> >= 1000 ) { OPTIONS_SCALES_Y_padding_index_HCHO = 4; }

				chart_HCHO.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_HCHO_TRIG_0; ?> + trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_HCHO_TRIG_0; ?> - trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_HCHO_TRIG_1; ?> + trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_HCHO_TRIG_1; ?> - trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_HCHO_TRIG_2; ?> + trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_HCHO_TRIG_2; ?> - trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_HCHO_TRIG_3; ?> + trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_HCHO_TRIG_3; ?> - trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_HCHO_TRIG_4; ?> + trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_HCHO_TRIG_4; ?> - trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_HCHO_TRIG_5; ?> + trig_line_HCHO_moy ;
				chart_HCHO.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_HCHO_TRIG_5; ?> - trig_line_HCHO_moy ;

			}
			
			chart_HCHO.options.scales.y.ticks.padding = OPTIONS_SCALES_Y_padding_array[OPTIONS_SCALES_Y_padding_index_HCHO] ;
			chart_HCHO.update();

		}

		if ( '<?php echo($aqcm_MESURES[7]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				chart_LUX.options.scales.y.max = <?php echo($FS_MAX_LUX_max); ?> ;
				chart_LUX.options.scales.y.min = <?php echo($FS_MIN_LUX_min); ?> ;
				
				OPTIONS_SCALES_Y_padding_index_LUX = 3;
				if ( <?php echo($FS_MAX_LUX_max); ?> >=  1000 ) { OPTIONS_SCALES_Y_padding_index_LUX = 4; }
				if ( <?php echo($FS_MAX_LUX_max); ?> >= 10000 ) { OPTIONS_SCALES_Y_padding_index_LUX = 5; }

				chart_LUX.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_LUX_TRIG_0; ?> + trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_LUX_TRIG_0; ?> - trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_LUX_TRIG_1; ?> + trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_LUX_TRIG_1; ?> - trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_LUX_TRIG_2; ?> + trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_LUX_TRIG_2; ?> - trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_LUX_TRIG_3; ?> + trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_LUX_TRIG_3; ?> - trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_LUX_TRIG_4; ?> + trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_LUX_TRIG_4; ?> - trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_LUX_TRIG_5; ?> + trig_line_LUX_max ;
				chart_LUX.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_LUX_TRIG_5; ?> - trig_line_LUX_max ;

			} else {
				
				chart_LUX.options.scales.y.max = <?php echo($FS_MAX_LUX_moy); ?> ;
				chart_LUX.options.scales.y.min = <?php echo($FS_MIN_LUX_moy); ?> ;
				
				OPTIONS_SCALES_Y_padding_index_LUX = 3;
				if ( <?php echo($FS_MAX_LUX_moy); ?> >=  1000 ) { OPTIONS_SCALES_Y_padding_index_LUX = 4; }
				if ( <?php echo($FS_MAX_LUX_moy); ?> >= 10000 ) { OPTIONS_SCALES_Y_padding_index_LUX = 5; }
				
				chart_LUX.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_LUX_TRIG_0; ?> + trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_LUX_TRIG_0; ?> - trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_LUX_TRIG_1; ?> + trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_LUX_TRIG_1; ?> - trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_LUX_TRIG_2; ?> + trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_LUX_TRIG_2; ?> - trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_LUX_TRIG_3; ?> + trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_LUX_TRIG_3; ?> - trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_LUX_TRIG_4; ?> + trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_LUX_TRIG_4; ?> - trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_LUX_TRIG_5; ?> + trig_line_LUX_moy ;
				chart_LUX.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_LUX_TRIG_5; ?> - trig_line_LUX_moy ;
				
			}

			chart_LUX.options.scales.y.ticks.padding = OPTIONS_SCALES_Y_padding_array[OPTIONS_SCALES_Y_padding_index_LUX] ;
			chart_LUX.update();

		}
	
		if ( '<?php echo($aqcm_MESURES[8]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				chart_SPL.options.scales.y.max = <?php echo($FS_MAX_SPL_max); ?> ;
				chart_SPL.options.scales.y.min = <?php echo($FS_MIN_SPL_min); ?> ;

				chart_SPL.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_SPL_TRIG_0; ?> + trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_SPL_TRIG_0; ?> - trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_SPL_TRIG_1; ?> + trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_SPL_TRIG_1; ?> - trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_SPL_TRIG_2; ?> + trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_SPL_TRIG_2; ?> - trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_SPL_TRIG_3; ?> + trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_SPL_TRIG_3; ?> - trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_SPL_TRIG_4; ?> + trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_SPL_TRIG_4; ?> - trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_SPL_TRIG_5; ?> + trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_SPL_TRIG_5; ?> - trig_line_SPL_max ;

			} else {
				
				/*chart_SPL.options.scales.y.max = <?php echo($FS_MAX_SPL_moy); ?> ;
				chart_SPL.options.scales.y.min = <?php echo($FS_MIN_SPL_moy); ?> ;*/
				chart_SPL.options.scales.y.max = <?php echo($FS_MAX_SPL_max); ?> ;
				chart_SPL.options.scales.y.min = <?php echo($FS_MIN_SPL_min); ?> ;
				
				trig_line_SPL_moy = trig_line_SPL_max ;
				chart_SPL.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_SPL_TRIG_0; ?> + trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_SPL_TRIG_0; ?> - trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_SPL_TRIG_1; ?> + trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_SPL_TRIG_1; ?> - trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_SPL_TRIG_2; ?> + trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_SPL_TRIG_2; ?> - trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_SPL_TRIG_3; ?> + trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_SPL_TRIG_3; ?> - trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_SPL_TRIG_4; ?> + trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_SPL_TRIG_4; ?> - trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_SPL_TRIG_5; ?> + trig_line_SPL_moy ;
				chart_SPL.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_SPL_TRIG_5; ?> - trig_line_SPL_moy ;
				
			}

			chart_SPL.update();

		}
	
		if ( '<?php echo($aqcm_MESURES[9]); ?>' == 'Y' ) {
			
			if ( FS_max ) {
				
				chart_NOX_IAQ.options.scales.y.max = <?php echo($FS_MAX_NOX_IAQ_max); ?> ;
				chart_NOX_IAQ.options.scales.y.min = <?php echo($FS_MIN_NOX_IAQ_min); ?> ;

				OPTIONS_SCALES_Y_padding_index_NOX_IAQ = 2;
				if ( <?php echo($FS_MAX_NOX_IAQ_max); ?> >=  100 ) { OPTIONS_SCALES_Y_padding_index_NOX_IAQ = 3; }
				
				chart_NOX_IAQ.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_NOX_TRIG_0; ?> + trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_NOX_TRIG_0; ?> - trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_NOX_TRIG_1; ?> + trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_NOX_TRIG_1; ?> - trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_NOX_TRIG_2; ?> + trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_NOX_TRIG_2; ?> - trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_NOX_TRIG_3; ?> + trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_NOX_TRIG_3; ?> - trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_NOX_TRIG_4; ?> + trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_NOX_TRIG_4; ?> - trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_NOX_TRIG_5; ?> + trig_line_NOX_IAQ_max ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_NOX_TRIG_5; ?> - trig_line_NOX_IAQ_max ;

			} else {
				
				chart_NOX_IAQ.options.scales.y.max = <?php echo($FS_MAX_NOX_IAQ_moy); ?> ;
				chart_NOX_IAQ.options.scales.y.min = <?php echo($FS_MIN_NOX_IAQ_moy); ?> ;
				
				OPTIONS_SCALES_Y_padding_index_NOX_IAQ = 2;
				if ( <?php echo($FS_MAX_NOX_IAQ_moy); ?> >=  100 ) { OPTIONS_SCALES_Y_padding_index_NOX_IAQ = 3; }

				chart_NOX_IAQ.options.plugins.annotation.annotations.line0.yMax = <?php echo $aqcm_NOX_TRIG_0; ?> + trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line0.yMin = <?php echo $aqcm_NOX_TRIG_0; ?> - trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line1.yMax = <?php echo $aqcm_NOX_TRIG_1; ?> + trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line1.yMin = <?php echo $aqcm_NOX_TRIG_1; ?> - trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line2.yMax = <?php echo $aqcm_NOX_TRIG_2; ?> + trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line2.yMin = <?php echo $aqcm_NOX_TRIG_2; ?> - trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line3.yMax = <?php echo $aqcm_NOX_TRIG_3; ?> + trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line3.yMin = <?php echo $aqcm_NOX_TRIG_3; ?> - trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line4.yMax = <?php echo $aqcm_NOX_TRIG_4; ?> + trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line4.yMin = <?php echo $aqcm_NOX_TRIG_4; ?> - trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line5.yMax = <?php echo $aqcm_NOX_TRIG_5; ?> + trig_line_NOX_IAQ_moy ;
				chart_NOX_IAQ.options.plugins.annotation.annotations.line5.yMin = <?php echo $aqcm_NOX_TRIG_5; ?> - trig_line_NOX_IAQ_moy ;
				
			}

			chart_NOX_IAQ.options.scales.y.ticks.padding = OPTIONS_SCALES_Y_padding_array[OPTIONS_SCALES_Y_padding_index_NOX_IAQ] ;
			chart_NOX_IAQ.update();

		}

	});

	document.getElementById("tooltip_Btn").addEventListener("click", () => {
		
		tooltip_enabled = ! tooltip_enabled;
		
		if ( '<?php echo($aqcm_MESURES[0]); ?>' == 'Y' ) {
			chart_T.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_T.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[1]); ?>' == 'Y' ) {
			chart_HR.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_HR.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[2]); ?>' == 'Y' ) {
			chart_CO2.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_CO2.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[3]); ?>' == 'Y' ) {
			chart_P.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_P.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[4]); ?>' == 'Y' ) {
			chart_COV.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_COV.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[5]); ?>' == 'Y' ) {
			chart_PM25.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_PM25.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[6]); ?>' == 'Y' ) {
			chart_HCHO.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_HCHO.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[7]); ?>' == 'Y' ) {
			chart_LUX.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_LUX.update();
		}
		
		if ( '<?php echo($aqcm_MESURES[8]); ?>' == 'Y' ) {
			chart_SPL.options.plugins.tooltip.enabled = tooltip_enabled ;
			chart_SPL.update();
		}
		
		if ( tooltip_enabled ) {
			document.getElementById("tooltip_Btn").textContent  = "cacher les info-bulles";
		}
		else {
			document.getElementById("tooltip_Btn").textContent  = "montrer les info-bulles";
		}


	});

	function requestDateSonde() {
		$.ajax({
			url: '/set_time/JSON_get_date_sonde.php',
			data: "",
			dataType: 'json',
			success: function(data) {
				var newDateSonde = data[0];
				$('#timeNowServer').html(newDateSonde);
			}
		});
	}
	setInterval("requestDateSonde()", 1000)
	
</script>

