2 pièce(s) jointe(s)
Graphique avec sélection de courbe
Bonjour,
j'ai écrit un code qui va chercher des données sur phpMyAdmin et les transposent en graphique.
Pièce jointe 395399
J'ai rajouté une option qui permet de supprimer la courbe bleu, mais le soucis c'est que la courbe noir devient bleu et la légende devient celle de la courbe bleu. je ne sais pas comment faire pour que la courbe noir reste noir avec sa légende.
Pièce jointe 395403
Voici le code,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
| <!DOCTYPE html>
<html>
<head>
<!--<meta http-equiv="Refresh" content="0.5; url=Graphe10.php">-->
<meta charset="utf-8" />
<link rel="stylesheet" css" />
<title>Affichage bdd </title>
</head>
<body>
<h1>Affichage Bdd étude V8</h1>
<form method="post" action="<?php echo "$Nom_fichier";?>">
<fieldset>
<legend>Quels paramètres ?</legend> <!-- Titre du fieldset -->
<p>
<!-- Début Tableau -->
<table>
<tr>
<td><label for="serial">Serial</label></td>
<td><select name="serial" id="serial">
<!--<option value="-1">- - - Choisissez un serial - - -</option>-->
<?php
for($i = 0; $i < $Nb_serial; $i++)
{
?>
<option
<?php if($serial_table[$i] == $valeurserial){echo 'selected="selected"';} ?> value="<?php echo($serial_table[$i]);?>"><?php echo ($serial_table[$i]);?>
</option> <?php
} ?>
</select></td>
</tr>
<tr>
<td><label for="X">X</label></td>
<td><select name="X" id="X">
<?php
for($i = 0; $i < $Nb_column; $i++)
{
?>
<option
<?php if($bdd_column_name_data_sigfox[$i] == $valeurX){echo 'selected="selected';} ?> value="<?php echo($bdd_column_name_data_sigfox[$i]);?>"> <?php echo ($bdd_column_name_data_sigfox[$i]);?>
</option> <?php
} ?>
</select></td>
</tr>
<tr>
<td><label for="Y1">Y1</label><br /></td>
<td><select name="Y1" id="Y1">
<?php
for($i = 0; $i < $Nb_column; $i++)
{
?>
<option
<?php if($bdd_column_name_data_sigfox[$i] == $valeurY1){echo 'selected="selected"';} ?> value="<?php echo($bdd_column_name_data_sigfox[$i]);?>"><?php echo ($bdd_column_name_data_sigfox[$i]);?>
</option> <?php
} ?>
</select></td>
</tr>
<tr>
<td><label for="Y2">Y2</label><br /></td>
<td><select name="Y2" id="Y2">
<?php
for($i = 0; $i < $Nb_column; $i++)
{
?>
<option
<?php if($bdd_column_name_data_sigfox[$i] == $valeurY2){echo 'selected="selected"';} ?> value="<?php echo($bdd_column_name_data_sigfox[$i]);?>"><?php echo ($bdd_column_name_data_sigfox[$i]);?>
</option> <?php
} ?>
</select>
</td>
<td>
<label for="case0">Effacer valeur Y2? </label>
<input type="checkbox" name="case0" id="case0"
<?php if($valeurcase0==0){echo 'checked="checked"';} ?>
/>
</td>
</tr>
<tr>
<td><label for="Nb">Nb de données (10080 semaine/min)</label></td>
<td><input type="number" name="Nb" id="Nb" min="1" max="20000" value="<?php echo($valeurNb);?>"></td>
</tr>
<!--
<tr>
<td><label for="case1">Même Echelle ? </label></td>
<td><input type="checkbox" name="case1" id="case1"
<?php if($valeurcase1==0){echo 'checked="checked"';} ?>/></td>
</tr>
<tr>
<td><label for="case2">Sans ligne ? </label></td>
<td><input type="checkbox" name="case2" id="case2"
<?php if($valeurcase2==0){echo 'checked="checked"';} ?>/></td>
</tr>
-->
</table>
<input type="submit" value="Envoyer" />
</p>
</form>
<p>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart()
{
var data = google.visualization.arrayToDataTable(<?php echo json_encode($test); ?>);
var options =
{
title: 'Company Performance',
series:
{
0: {targetAxisIndex: 2, lineWidth: <?php echo ($valeurcase1);?>, pointSize: 7, pointShape: 'triangle', color: 'black'},
1: {targetAxisIndex: 2, lineWidth: <?php echo ($valeurcase0);?>, pointSize: 7, color: 'blue'},
},
//curveType: 'none',
//legend: { position: 'top' }
vAxes:
{
// Adds titles to each axis.
0: {title: '<?php echo ($test[0][1]);?>'},
1: {title: '<?php echo ($test[0][2]);?>'}
}
/*crosshair:
{
color: '#000',
trigger: 'selection'
}*/
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
<div id="curve_chart" style="width: 1700px; height: 600px; padding-left: -10px"></div>
</p>
</fieldset>
<footer>
</footer>
</body>
</html> |