Modification objet javascript
Bonjour à tous,
Après de maintes recherches, je m'adresse à vous pour solutionner mon problème. Débutant en javascript et développement web, je dois rater quelque chose, car je n'y arrive pas du tout.
Je souhaite créer un graphique (bargraph) et mettre à jour ses données.
J'utilise un code javascript (graphs.js) trouvé sur le net que j'intègre dans ma page web que voici :
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
| <%@ Page Language="VB" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<script type="text/javascript" src="graphs.js"></script>
<script type="text/javascript">
function TEST()
{
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Page Test JS</title>
<link rel="stylesheet" type="text/css" href="myHouZe.css" />
</head>
<body onload="">
<form id="form1" runat="server" >
<div id="graph">
<script type="text/javascript" language="JavaScript" id="Consommation">
var graph = new BAR_GRAPH("vBar");
graph.values = "123,456,789,987,654,321";
graph.labels = "Janvier,Février,Mars,Avril,Mai,Juin, Juillet, Aout, Septembre, Octobre, Novembre, Décembre";
graph.showValues = 2;
graph.barWidth = 40;
graph.barLength = 1;
graph.labelSize = 12;
graph.absValuesSize = 12;
graph.percValuesSize = 12;
graph.graphPadding = 10;
//Couleur du background général
graph.graphBGColor = "Black";
//Contour du bloc
graph.graphBorder = "";
graph.barColors = "#ADCF4F";
graph.barBGColor = "Black";
graph.barBorder = "4px outset #AEEE00";
graph.labelColor = "White";
graph.labelBGColor = "Black";
graph.labelBorder = "";
graph.absValuesColor = "White";
graph.absValuesBGColor = "Black";
graph.absValuesBorder = "";
document.write(graph.create());
</script>
</div>
<div id="start">Test button</div>
<div><input id="Device" type="text" size="30" value="" /></div>
<div><input onclick="TEST();" id="Button1" type="button" value="button" />
</div>
</form>
</body>
</html> |
Jusque là, tout va bien et mon graphique s'affiche comme je veux.
Maintenant, je souhaite changer les valeurs de ce graphique lorsque l'on appuie sur le button1. Mon problème est que je n'arrive pas à retrouver mon objet javascript "graph" lorsque je suis dans la fonction TEST pour faire un truc du genre:
mongraph.values = "200,500,789,987,654,321"; (et donc changer le graphique).
Merci d'éclairer ma lanterne.
Grigou25