// PropBarChart.js // Javascript Behavior for the VBarChart Control // Copyright (c) by Matthias Hertel, http://www.mathertel.de // This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx // ----- // 09/17/2005 14:05:26 created by Matthias Hertel // 25.08.2007 created from PropBarChartBehaviour // 18.12.2007 Simplifications and documentation. var VBarChartBehavior = { // ----- Attributes ----- eventname: "", /// <summary>The local or complete event name that is used for publishing OpenAjax events.</summary> maxvalue: 100, // maximal value of the event data init: function () { // register for a event-value if the propname attribute is set. if ((this.eventname != null) && (this.eventname != "")) { // retrieve complete event name if (this.eventname.indexOf('.') < 0) { var formElem = jcl.FindBehaviourElement(this, DataFormBehavior); if ((formElem != null) && (formElem.eventnamespace != null)) this.eventname = formElem.eventnamespace + "." + this.eventname; } // if OpenAjax.hub.subscribe(this.eventname, this.handleEvent, this); } // if }, // init handleEvent: function (eventName, eventData) { eventData = eventData * 100 / this.maxvalue; eventData = Math.min(100, Math.max(0, Math.round(eventData))); this.style.height = eventData + "px"; }, // handleEvent // ----- Methods ----- GetValue: function (propName, propValue) { if (this.properties.indexOf(";" + propName.toLowerCase() + ";") >= 0) { propValue = propValue * 100 / this.maxvalue; propValue = Math.min(100, Math.max(0, Math.round(propValue))); var bar = document.getElementById("barchart_" + propName); bar.style.height = propValue + "px"; } // if } // GetValue }; // VBarChartBehavior
This page is part of the http://www.mathertel.de/ web site.
For updates and discussions see http://ajaxaspects.blogspot.com/.