1 //Class s.chart.composite.CompositeChart1 : Chart
  2 //This is the custom wrapper class for protovis bar charts
  3 
  4 //Constructor
  5 wso2vis.s.chart.composite.CompositeChart1 = function(canvas, chartTitle, chartDesc) {
  6     wso2vis.s.chart.Chart.call(this, canvas, chartTitle, chartDesc);
  7 
  8     /* @private */
  9     this.vis = null;
 10     this.y = null;
 11     this.x = null;
 12 	this.chart = null;
 13 	this.chartType(0);
 14 	
 15 
 16     //this.legendText("Data 1");
 17 }
 18 
 19 // this makes s.chart.composite.CompositeChart1.prototype inherits
 20 // from Chart.prototype
 21 wso2vis.extend(wso2vis.s.chart.composite.CompositeChart1, wso2vis.s.chart.Chart);
 22 
 23 wso2vis.s.chart.composite.CompositeChart1.prototype
 24     .property("dataField")
 25     .property("dataValue")
 26     .property("dataLabel")
 27     .property("ySuffix")
 28     .property("xSuffix")
 29     .property("titleTop")
 30     .property("titleLeft")
 31     .property("titleRight")
 32     .property("titleBottom")
 33     .property("xTitle")
 34     .property("yTitle")
 35     .property("legendText")
 36     .property("segmentBorderColor")
 37 	.property("labelLength")
 38     .property("thickness")
 39 	.property("chartType");
 40 	
 41 wso2vis.s.chart.composite.CompositeChart1.prototype.load = function (w, h) {
 42     if (this.chartType() == 0) {
 43 		this.chart = new wso2vis.s.chart.protovis.BarChart(this.divEl(), this.title(), this.description());
 44 	}
 45 	else if (this.chartType() == 1) {
 46 		this.chart = new wso2vis.s.chart.protovis.ColumnChart(this.divEl(), this.title(), this.description());
 47 	}
 48 	else if (this.chartType() == 2) {
 49 		this.chart = new wso2vis.s.chart.protovis.WedgeChart(this.divEl(), this.title(), this.description());
 50 	}
 51 	else if (this.chartType() == 3) {
 52 		this.chart = new wso2vis.s.chart.protovis.PieChart(this.divEl(), this.title(), this.description());
 53 	}
 54 	
 55 	this.chart.dataField(this.dataField());
 56 	this.chart.dataValue(this.dataValue());
 57 	this.chart.dataLabel(this.dataLabel());
 58 	this.chart.ySuffix(this.ySuffix());
 59 	this.chart.xSuffix(this.xSuffix());
 60 	this.chart.tooltip(this.tooltip());
 61 	this.chart.legend(this.legend());
 62 	this.chart.marks(this.marks());
 63 	this.chart.width(this.width());
 64 	this.chart.height(this.height());
 65 	this.chart.titleFont(this.titleFont());
 66 	this.chart.labelFont(this.labelFont());
 67 	this.chart.legendX(this.legendX());
 68 	this.chart.legendY(this.legendY());
 69 	this.chart.paddingTop(this.paddingTop());
 70 	this.chart.paddingLeft(this.paddingLeft());
 71 	this.chart.paddingRight(this.paddingRight());
 72 	this.chart.paddingBottom(this.paddingBottom());
 73 
 74 	this.chart.load(w, h);
 75 };
 76 
 77 /**
 78 * @private
 79 */
 80 wso2vis.s.chart.composite.CompositeChart1.prototype.populateData = function (thisObject) {    
 81 	this.chart.populateData(thisObject.chart);
 82 };
 83 
 84 wso2vis.s.chart.composite.CompositeChart1.prototype.update = function () {
 85     this.chart.update();
 86 };
 87 
 88 wso2vis.s.chart.composite.CompositeChart1.prototype.getDataLabel = function (i) {
 89     if (this.data !== null){
 90         var rootObj = this.traverseToDataField(this.data, this.dataField());
 91         if( rootObj instanceof Array ) {
 92             return  this.traverseToDataField(rootObj[i], this.dataLabel());
 93         }
 94         else {
 95             return  this.traverseToDataField(rootObj, this.dataLabel());
 96         }
 97     }
 98     
 99     return i;
100 };
101 
102 wso2vis.s.chart.composite.CompositeChart1.prototype.pushData = function (d) {
103     if( this.validateData(d) ){
104         this.chart.data = d;
105         this.chart.update();
106     } else {
107         this.updateMessageDiv(this.messageInterceptFunction());
108     }
109 };
110