////////////////////////////////////////////// 
//       SoundOutTheBox multipleGraph       // 
//  Copyright © SoundOutTheBox 2012-2013    // 
//           License-CC-BY-NC-ND            // 
////////////////////////////////////////////// 
(function(e){e.widget("mui.multipleGraph",{options:{publicVariables:{Name:{value:"no name",type:"StringData",dynamic:!1},Left:{value:0,type:"IntegerData",dynamic:!1},Top:{value:0,type:"IntegerData",dynamic:!1},Width:{value:400,type:"IntegerData",dynamic:!1},Height:{value:150,type:"IntegerData",dynamic:!1},Renderer:{value:["area","line","bar","scatterplot"],type:"EnumData",defaultvalue:"area",write:!0,dynamic:!0},Series:{value:'[ { data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 17 }, { x: 3, y: 42 } ], color: "steelblue"}, {data: [ { x: 0, y: 22 }, { x: 1, y: 25 }, { x: 2, y: 24 }, { x: 3, y: 12 } ], color: "lightblue"} ]',
type:"StringData",write:!0,dynamic:!0},Unstack:{value:["true","false"],type:"EnumData",defaultvalue:"true",write:!0,dynamic:!0},Min:{value:0,type:"IntegerData",write:!0,dynamic:!0},Max:{value:100,type:"IntegerData",write:!0,dynamic:!0},AdjustY:{value:["PosAutoAdjustment","Auto","MinMax"],type:"EnumData",defaultvalue:"PosAutoAdjustment",dynamic:!1},Visible:{value:["no","yes"],type:"EnumData",defaultvalue:"yes",write:!0,dynamic:!0}},privateVariables:{pageNumber:0,motifType:0,userScreen:0,graph:null},
config:{main:"multipleGraph.js",description:"Draw a line, an area, bars or points to represent an array with many rows.",author:"SoundOutTheBox",version:"1.0.0.0.Final",dependencies:["./js/d3.min.js","./js/d3.layout.min.js","./js/rickshaw.min.js"],widgetID:"5e929164696c719f64646b346166656d9470726b61646c659364916d94699d9c",widgetPackages:["626a646c946f6c9a69669a61619762676c6b696c68636666659393699969706d"]}},_create:function(){},_init:function(){},_destroy:function(){},_setOption:function(){e.Widget.prototype._setOption.apply(this,arguments)},_render:function(){var b=
this.options.publicVariables,a=this.element,d=b.Top.value,c=b.Height.value,e=b.Left.value,h=b.Width.value,j=UTIL.checkEnum(b.Renderer).value,k=b.Series.value,l=UTIL.checkEnum(b.Unstack).value,f=b.Min.value,g=b.Max.value,i=UTIL.checkEnum(b.AdjustY).value;console.log("_render()  object="+b.Name.value);a.disableSelection();a.css({position:"absolute",left:e+"px",top:d+"px",width:h+"px",height:c+"px",zIndex:10});a.addClass("dynamicObject");i==="PosAutoAdjustment"?g=f="":i==="Auto"&&(f="auto",g="");this.options.privateVariables.graph=
new Rickshaw.Graph({element:a[0],width:h,height:c,renderer:j,min:f,max:g,series:eval(k)});this.options.privateVariables.graph.renderer.unstack=eval(l);this.options.privateVariables.graph.render();this.setVisible(b.Visible.value)},readFromXML:function(b){var a=this.options.publicVariables,b=e(b);a.Name.value=UTIL.getStringAttr(b,"Name",a.Name.value);a.Renderer.value=UTIL.getStringAttr(b,"Renderer",a.Renderer.value);a.Series.value=UTIL.getStringAttr(b,"Series",a.Series.value);a.Unstack.value=UTIL.getStringAttr(b,
"Unstack",a.Unstack.value);a.Min.value=UTIL.getIntAttr(b,"Min",a.Min.value);a.Max.value=UTIL.getIntAttr(b,"Max",a.Max.value);a.AdjustY.value=UTIL.getStringAttr(b,"AdjustY",a.AdjustY.value);a.Visible.value=UTIL.getStringAttr(b,"Visible",a.Visible.value);UTIL.readPositionFromXML(b,a)},setRenderer:function(b){var a=this.options.privateVariables.graph;if(!UTIL.isNull(a))a.setRenderer(b),this.options.publicVariables.Renderer.value=b,a.render()},setUnstack:function(b){var a=this.options.privateVariables.graph;
if(!UTIL.isNull(a))this.options.privateVariables.graph.renderer.unstack=b,a.render()},setSeries:function(b){var a=this.options.privateVariables.graph,d=0;if(!UTIL.isNull(a)&&!UTIL.isNull(b)){if(a.series.length>b.length)for(var d=a.series.length,c=d-1;c>=0;c--)if(!UTIL.isNull(a.series[c])&&UTIL.isNull(b[c]))a.series.remove(a.series[c]);else{if(!UTIL.isNull(a.series[c].data)&&!UTIL.isNull(b[c].data))a.series[c].data=b[c].data;if(!UTIL.isNull(a.series[c].color)&&!UTIL.isNull(b[c].color))a.series[c].color=
b[c].color}else{d=b.length;for(c=0;c<d;c++)if(UTIL.isNull(a.series[c])&&!UTIL.isNull(b[c].data)&&!UTIL.isNull(b[c].color))a.series.push({color:b[c].color,data:b[c].data});else{if(!UTIL.isNull(a.series[c].data)&&!UTIL.isNull(b[c].data))a.series[c].data=b[c].data;if(!UTIL.isNull(a.series[c].color)&&!UTIL.isNull(b[c].color))a.series[c].color=b[c].color}}this.options.publicVariables.Series.value=b;a.render()}},setMin:function(b){var a=this.options.privateVariables.graph,d=this.options.publicVariables.AdjustY.value;
this.options.publicVariables.Min.value=b;if(d==="MinMax"&&!UTIL.isNull(a))a.min=b,a.render()},setMax:function(b){var a=this.options.privateVariables.graph,d=this.options.publicVariables.AdjustY.value;this.options.publicVariables.Max.value=b;if(d==="MinMax"&&!UTIL.isNull(a))a.max=b,a.render()},setVisible:function(b){var a=this.options.publicVariables,d=this.element;if(b!==a.Visible.value)a.Visible.value=b;a.Visible.value!=="no"?UTIL.setOpacity(d,1):UTIL.setOpacity(d,0)},onPropertyChange:function(b,
a){switch(b){case "Renderer":this.setRenderer(a);break;case "Series":this.setSeries(eval(a));break;case "Unstack":this.setUnstack(eval(a));break;case "Min":this.setMin(a);break;case "Max":this.setMax(a);break;case "Visible":this.setVisible(a)}},onReleaseCapture:function(){}})})(jQuery);
