Hello,
J'aimerai créer une librarie graphique pour créer un barchart ( je sais qu'il en existe déjà des tas mais ceci est juste dans un but d'apprentissage ).
J'ai d'en l'idée de créer un objet style jquery ex : monobj("divtoto").createGraph(200,300); j'ai tenté de m'appuyer sur le code jquery pour le faire, mais je n'y arrive pas.
Voici le début de mon code.
Mais si j'exécute Graph('canvas').createGraph(200,300) cela ne marche pas quelqu'un pourrait-il m'aider ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 (function(window){ var _version= "0.0.1", _canvas; AnimatedGraph = function (className){ return new AnimatedGraph.fn.init(className); }; AnimatedGraph.fn = AnimatedGraph.prototype = { constructor: AnimatedGraph, init: function(className){ _canvas = AnimatedGraph.search(className); _canvas.innerHTML = "Youpi"; }, search: function(className){ var elm = document.getElementsByTagName("div"); for(i=0;i<elm.length;i++){ if(elm[i].className == className) return elm[i]; } }, createGraph: function(width,height){ var title = document.createElement("div"); title.innerHTML="tutu"; _canvas.appendChild(title); } }; return (function(){ var ret = new AnimatedGraph(); ret.createGraph = createGraph; return ret; }); AnimatedGraph.search = AnimatedGraph.fn.search; function createGraph(width,height){ var title = document.createElement("div"); title.innerHTML="tutu"; _canvas.appendChild(title); }; window.Graph = AnimatedGraph; })(window);
D'avance merci
Partager