source: Dev/branches/Cartis/Tiles preview/js/classes/graphs.js @ 283

Last change on this file since 283 was 283, checked in by tjcschipper, 13 years ago

Cartis Mockup werkt!

W
I
N
N
I
N
G

File size: 2.0 KB
Line 
1$(function() {
2   
3    // Graph class
4   
5    function Graph(containerName) {
6        var self = this;
7        var _id;
8        var _type;
9        var _size;
10        var _data;
11        var _graphObject;
12        this._container = document.getElementById(containerName);
13       
14        this.init = function(id, data, type, size) {
15            // Draw the graph to the element
16            _id = id;
17            _data = data;
18            _type = type;
19            _size = size;
20
21            var canvas = document.createElement("canvas");
22            canvas.id = id;
23            canvas.className = "graphDisplay";
24            canvas.width = _size[0];
25            canvas.height = size[1];
26            self._container.appendChild(canvas);
27           
28            switch (_type) {
29                case "Pie":
30                    _graphObject = new RGraph.Pie(_id, _data);
31                    break;
32                case "Bar":
33                    _graphObject = new RGraph.Bar(_id, _data);
34                    _graphObject.Set('chart.labels', ['Jan', 'Piet', 'Shaniqua']);
35                    break;
36                case "Radar":
37                    _graphObject = new RGraph.Radar(_id, _data);
38                    break;
39                case "Rose":
40                    _graphObject = new RGraph.Rose(_id, _data);
41                    break;
42            }
43           
44            // Set standard properties.
45            _graphObject.Set('chart.text.color', '#fff');
46            _graphObject.Set('chart.shadow', false);
47            _graphObject.Set('chart.colors', ['rgba(240,240,240,0.5)', 'rgba(240,240,240,0.5)', 'rgba(240,240,240,0.5)']);
48            _graphObject.Set('chart.axis.color', 'rgba(240,240,240,0.5)');
49            _graphObject.Set('chart.strokestyle', 'rgba(240,240,240,1.0)');
50           
51           
52           
53            // Draw
54            _graphObject.Draw();
55        }
56
57        this.getType = function() {
58            return _type;
59        }
60
61    }
62   
63    window.Graph = Graph;
64   
65});
Note: See TracBrowser for help on using the repository browser.