////////////////////////////////////////////// 
//        SoundOutTheBox simpleGraph        // 
//  Copyright © SoundOutTheBox 2012-2013    // 
//           License-CC-BY-NC-ND            // 
////////////////////////////////////////////// 
(function(d){d.widget("mui.simpleGraph",{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},Color:{value:"000,128,255",type:"StringData",subtype:"Color",write:!0,dynamic:!0},Data:{value:"[ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 17 }, { x: 3, y: 42 } ]",
type:"StringData",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:"simpleGraph.js",description:"Draw a line, an area, bars or points to represent an array with only one row.",
author:"SoundOutTheBox",version:"1.0.0.0.Final",dependencies:["./js/d3.min.js","./js/d3.layout.min.js","./js/rickshaw.min.js"],widgetID:"92629b61976998916799626a646b9668719a6392686665656d699c6a6c956270",widgetPackages:["66696a69976f6991686b6692649c6369726860636e3163966e93996e9c60676b"]}},_create:function(){},_init:function(){},_destroy:function(){},_setOption:function(){d.Widget.prototype._setOption.apply(this,arguments)},_render:function(){var b=this.options.publicVariables,a=this.element,c=b.Top.value,d=b.Height.value,i=b.Left.value,g=b.Width.value,j=UTIL.checkEnum(b.Renderer).value,
k=b.Color.value,l=eval(b.Data.value),e=b.Min.value,f=b.Max.value,h=UTIL.checkEnum(b.AdjustY).value;console.log("_render()  object="+b.Name.value);a.disableSelection();a.css({position:"absolute",left:i+"px",top:c+"px",width:g+"px",height:d+"px",zIndex:10});a.addClass("dynamicObject");h==="PosAutoAdjustment"?f=e="":h==="Auto"&&(e="auto",f="");this.options.privateVariables.graph=new Rickshaw.Graph({element:a[0],width:g,height:d,renderer:j,min:e,max:f,series:[{color:k,data:l}]});this.options.privateVariables.graph.render();
this.setVisible(b.Visible.value)},readFromXML:function(b){var a=this.options.publicVariables,b=d(b);a.Name.value=UTIL.getStringAttr(b,"Name",a.Name.value);a.Renderer.value=UTIL.getStringAttr(b,"Renderer",a.Renderer.value);a.Color.value=UTIL.getColorAttr(b,"Color",a.Color.value);a.Data.value=UTIL.getStringAttr(b,"Data",a.Data.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()},setColor:function(b){var a=this.options.privateVariables.graph;if(!UTIL.isNull(a))a.series[0].color=b,this.options.publicVariables.Color.value=b,a.render()},setData:function(b){var a=this.options.privateVariables.graph;if(!UTIL.isNull(a))a.series[0].data=b,this.options.publicVariables.Data.value=
b,a.render()},setMin:function(b){var a=this.options.privateVariables.graph,c=this.options.publicVariables.AdjustY.value;this.options.publicVariables.Min.value=b;if(c==="MinMax"&&!UTIL.isNull(a))a.min=b,a.render()},setMax:function(b){var a=this.options.privateVariables.graph,c=this.options.publicVariables.AdjustY.value;this.options.publicVariables.Max.value=b;if(c==="MinMax"&&!UTIL.isNull(a))a.max=b,a.render()},setVisible:function(b){var a=this.options.publicVariables,c=this.element;if(b!==a.Visible.value)a.Visible.value=
b;a.Visible.value!=="no"?UTIL.setOpacity(c,1):UTIL.setOpacity(c,0)},onPropertyChange:function(b,a){switch(b){case "Renderer":this.setRenderer(a);break;case "Color":this.setColor(UTIL.defineColorEmbossed(a));break;case "Data":this.setData(eval(a));break;case "Min":this.setMin(a);break;case "Max":this.setMax(a);break;case "Visible":this.setVisible(a)}},onReleaseCapture:function(){}})})(jQuery);
