Changeset 296 for Dev/branches/Cartis/Tiles preview/js/classes/graphs.js
- Timestamp:
- 02/29/12 16:32:21 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/Cartis/Tiles preview/js/classes/graphs.js
r290 r296 10 10 var _data; 11 11 var _graphObject; 12 var _title; 12 13 this._container = document.getElementById(containerName); 13 14 14 this.init = function(id, data, type, size ) {15 this.init = function(id, data, type, size, title) { 15 16 // Draw the graph to the element 16 17 _id = id; … … 18 19 _type = type; 19 20 _size = size; 21 if (title) _title = title; 20 22 21 23 var canvas = document.createElement("canvas"); … … 28 30 switch (_type) { 29 31 case "Pie": 32 // Hardcoded data 33 // Participant age 34 _data = [5,7,9,4]; 30 35 _graphObject = new RGraph.Pie(_id, _data); 36 _graphObject.Set('chart.labels', ['20-30 (20 participants)', '30-40 (28 participants)', '40-50 (36 participants)', '50+ (16 participants)']); 37 _graphObject.Set('chart.text.color', '#fff'); 31 38 break; 32 39 case "Bar": 40 // Hardcoded data 41 // Quality of control 42 _data = [4,20,50,18,8]; 33 43 _graphObject = new RGraph.Bar(_id, _data); 34 _graphObject.Set('chart.labels', ['Jan', 'Piet', 'Shaniqua']); 44 _graphObject.Set('chart.labels', ['Bad','Subpar','Average','Above average','Good']); 45 _graphObject.Set('chart.text.color', '#fff'); 35 46 break; 36 47 case "Radar": 37 _graphObject = new RGraph.Radar(_id, _data); 48 //Hardcoded data 49 // Gameplay errors 50 _data = [24,20,26,35,36,29,25,16]; 51 _graphObject = new RGraph.Radar(_id, _data); 52 _graphObject.Set('chart.labels',['Bram','Paula','Jules','Joel','Tyrone','Henk','Darcy','Frans']); 53 _graphObject.Set('chart.text.color', '#000'); 54 _graphObject.Set('chart.strokestyle','black'); 55 38 56 break; 39 57 case "Rose": 40 58 _graphObject = new RGraph.Rose(_id, _data); 59 _graphObject.Set('chart.text.color', '#000'); 41 60 break; 42 61 } 43 62 44 63 // Set standard properties. 45 _graphObject.Set('chart.text.color', '#fff');46 64 _graphObject.Set('chart.shadow', false); 47 65 _graphObject.Set('chart.colors', ['rgba(240,240,240,0.5)', 'rgba(240,240,240,0.5)', 'rgba(240,240,240,0.5)']); 48 66 _graphObject.Set('chart.axis.color', 'rgba(240,240,240,0.5)'); 49 67 _graphObject.Set('chart.strokestyle', 'rgba(240,240,240,1.0)'); 68 if (title) { 69 _graphObject.Set('chart.title', title); 70 _graphObject.Set('chart.title.color', 'white'); 71 } 50 72 51 73 //enlarge click event … … 91 113 */ 92 114 var largeGraph = new Graph("largeContainer"); 93 largeGraph.init("enlarged", _data, _type, [900,550] );115 largeGraph.init("enlarged", _data, _type, [900,550], _title); 94 116 var clearDiv = document.createElement("div"); 95 117 $(clearDiv).css("float", "left").css("clear", "both");
Note: See TracChangeset
for help on using the changeset viewer.