10 * @class Roo.bootstrap.Graph
11 * @extends Roo.bootstrap.Component
12 * Bootstrap Graph class
16 @cfg {String} graphtype bar | vbar | pie
17 @cfg {number} g_x coodinator | centre x (pie)
18 @cfg {number} g_y coodinator | centre y (pie)
19 @cfg {number} g_r radius (pie)
20 @cfg {number} g_height height of the chart (respected by all elements in the set)
21 @cfg {number} g_width width of the chart (respected by all elements in the set)
23 -opts (object) options for the chart
25 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
26 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
28 o colors (array) colors be used repeatedly to plot the bars. If multicolumn bar is used each sequence of bars with use a different color.
29 o stacked (boolean) whether or not to tread values as in a stacked bar chart
33 -opts (object) options for the pie
42 * @param {Object} config The config object
45 Roo.bootstrap.Graph = function(config){
46 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
52 * The img click event for the img.
53 * @param {Roo.EventObject} e
59 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
70 //g_colors: this.colors,
76 getAutoCreate : function(){
87 onRender : function(ct,position){
88 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
89 this.raphael = Raphael(this.el.dom);
91 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
92 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
93 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
94 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
96 r.text(160, 10, "Single Series Chart").attr(txtattr);
97 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
98 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
99 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
101 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
102 r.barchart(330, 10, 300, 220, data1);
103 r.barchart(10, 250, 300, 220, data2, {stacked: true});
104 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
107 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
108 // r.barchart(30, 30, 560, 250, xdata, {
109 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
111 // axisxlabels : xdata
115 var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
117 this.load(null,xdata,{
124 load : function(graphtype,xdata,opts){
125 this.raphael.clear();
127 graphtype = this.graphtype;
132 var chart_title = '',
135 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
138 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
143 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
144 chart_title = 'This is Vertical Barchart';
147 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
148 chart_title = 'This is Horizontal Barchart';
151 opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
152 href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
153 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts);
154 chart_title = 'This is Piechart';
158 this.raphael.text(150,50,chart_title).attr({ font: "20px 'Fontin Sans', Fontin-Sans, sans-serif" });
161 initEvents: function() {
164 this.el.on('click', this.onClick, this);
168 onClick : function(e)
170 Roo.log('img onclick');
171 this.fireEvent('click', this, e);