|
From: <j-...@us...> - 2011-11-23 19:43:45
|
Revision: 540
http://openautomation.svn.sourceforge.net/openautomation/?rev=540&view=rev
Author: j-n-k
Date: 2011-11-23 19:43:39 +0000 (Wed, 23 Nov 2011)
Log Message:
-----------
FR 3128533 : Added diagram_info (combined diagram_popup/info) widget
Modified Paths:
--------------
CometVisu/tags/post_0.6.0/visu/plugins/diagram/structure_plugin.js
CometVisu/tags/post_0.6.0/visu/visu_config.xsd
CometVisu/tags/post_0.6.0/visu/visu_config_demo.xml
Modified: CometVisu/tags/post_0.6.0/visu/plugins/diagram/structure_plugin.js
===================================================================
--- CometVisu/tags/post_0.6.0/visu/plugins/diagram/structure_plugin.js 2011-11-20 21:45:11 UTC (rev 539)
+++ CometVisu/tags/post_0.6.0/visu/plugins/diagram/structure_plugin.js 2011-11-23 19:43:39 UTC (rev 540)
@@ -185,6 +185,140 @@
content: {type: "string", required: true}
});
+VisuDesign_Custom.prototype.addCreator("diagram_info", {
+ create: function( page, path ) {
+ var $p = $(page);
+
+ var address = {};
+ $p.find('address').each( function(){
+ var src = this.textContent;
+ ga_list.push( src )
+ address[ '_' + src ] = [ this.getAttribute('transform') ];
+ });
+
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+
+ var id = "diagram_" + uniqid();
+
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'diagram' );
+
+ var labelElement = $p.find('label')[0];
+ var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
+
+ var actor = '<div class="actor switchUnpressed ';
+ if ( $p.attr( 'align' ) )
+ actor += $p.attr( 'align' );
+ actor += '">';
+ var map = $p.attr('mapping');
+ if( mappings[map] && mappings[map][value] )
+ actor += '<div class="value">' + mappings[map][value] + '</div>';
+ else
+ actor += '<div class="value">-</div>';
+ actor += '</div>';
+
+ var $actor = $(actor).data({
+ 'address' : address,
+ 'format' : $p.attr('format'),
+ 'mapping' : $p.attr('mapping'),
+ 'styling' : $p.attr('styling')
+ });
+ for( var addr in address ) $actor.bind( addr, this.update );
+
+ ret_val.append(label).append($actor);
+
+ $actor.addClass("clickable");
+
+ var bDiagram = $("<div class=\"diagram\" id=\"" + id + "_big\"/>");
+
+ bDiagram.data("id", id);
+ bDiagram.data("rrd", $p.attr("rrd"));
+ bDiagram.data("unit", $p.attr("unit") || "");
+ bDiagram.data("series", $p.attr("series") || "day");
+ bDiagram.data("period", $p.attr("period") || 1);
+ bDiagram.data("datasource", $p.attr("datasource") || "AVERAGE");
+ bDiagram.data("label", labelElement.textContent);
+ bDiagram.data("refresh", $p.attr("refresh"));
+ bDiagram.data("linecolor", $p.attr("linecolor") || "");
+ bDiagram.data("gridcolor", $p.attr("gridcolor") || "");
+
+ var data = jQuery.extend({}, bDiagram.data());
+
+ $actor.bind("click", function() {
+ bDiagram.data(data);
+ bDiagram.css({height: "90%"});
+
+ showPopup("unknown", {title: labelElement.textContent, content: bDiagram});
+ bDiagram.parent("div").css({height: "100%", width: "90%", margin: "auto"}); // define parent as 100%!
+
+ var bDiagramOpts = {yaxis: {labelWidth: null}};
+ if ($p.attr("tooltip") == "true") {
+ // if we want to display a tooltip, we need to listen to the event
+ var previousPoint = null;
+ jQuery(bDiagram).bind("plothover", function (event, pos, item) {
+ jQuery("#x").text(pos.x.toFixed(2));
+ jQuery("#y").text(pos.y.toFixed(2));
+
+ if (item) {
+ if (previousPoint != item.datapoint) {
+ previousPoint = item.datapoint;
+
+ $("#diagramTooltip").remove();
+ var x = item.datapoint[0],
+ y = item.datapoint[1].toFixed(2);
+
+ //This is a mess but toLocaleString expects UTC again
+ var offset = new Date().getTimezoneOffset() * 60 * 1000;
+ var dte = new Date(x + offset);
+ showDiagramTooltip(item.pageX, item.pageY,
+ dte.toLocaleString() + ": " + y + jQuery(this).data("unit"));
+ }
+ }
+ else {
+ $("#diagramTooltip").remove();
+ previousPoint = null;
+ }
+
+ })
+ .bind("click", function(event) {
+ // don't let the popup know about the click, or it will close on touch-displays
+ event.stopPropagation();
+ });
+
+ bDiagramOpts = jQuery.extend(bDiagramOpts, {grid: {hoverable: true, clickable: true} });
+ }
+
+ refreshDiagram(bDiagram, bDiagramOpts);
+ return false;
+ });
+
+ return ret_val;
+ },
+ update: defaultUpdate,
+ attributes: {
+ rrd: {type: "string", required: true},
+ unit: {type: "string", required: false},
+ series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
+ period: {type: "numeric", required: false},
+ datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
+ refresh: {type: "numeric", required: false},
+ tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ linecolor: {type: "string", required: false},
+ gridcolor: {type: "string", required: false},
+ format: { type: 'format', required: false },
+ mapping: { type: 'mapping', required: false },
+ styling: { type: 'styling', required: false }
+ },
+ elements: {
+ label: { type: 'string', required: true, multi: false },
+ address: { type: 'address', required: true, multi: true }
+ },
+ content: {type: "string", required: true}
+});
+
diagramColors = {
data: $("<span class='link'><a href='#' /></a>").find("a").css("color")
};
Modified: CometVisu/tags/post_0.6.0/visu/visu_config.xsd
===================================================================
--- CometVisu/tags/post_0.6.0/visu/visu_config.xsd 2011-11-20 21:45:11 UTC (rev 539)
+++ CometVisu/tags/post_0.6.0/visu/visu_config.xsd 2011-11-23 19:43:39 UTC (rev 540)
@@ -393,6 +393,26 @@
</xsd:simpleContent>
</xsd:complexType>
+<xsd:complexType name="diagram_info" >
+ <xsd:choice maxOccurs="unbounded" minOccurs="1">
+ <xsd:element name="label" type="xsd:string" maxOccurs="1" />
+ <xsd:element name="address" type="address" minOccurs="1"/>
+ </xsd:choice>
+ <xsd:attribute ref="format" use="optional" />
+ <xsd:attribute ref="styling" use="optional" />
+ <xsd:attribute ref="mapping" use="optional" />
+ <xsd:element name="label" type="xsd:string" maxOccurs="1" />
+ <xsd:attribute name="rrd" type="xsd:string" use="required" />
+ <xsd:attribute name="unit" type="xsd:string" use="optional" />
+ <xsd:attribute name="series" type="xsd:string" use="optional" />
+ <xsd:attribute name="refresh" type="xsd:integer" use="optional" />
+ <xsd:attribute name="period" type="xsd:string" use="optional" />
+ <xsd:attribute name="datasource" type="xsd:string" use="optional" />
+ <xsd:attribute name="tooltip" type="xsd:string" use="optional" />
+ <xsd:attribute name="linecolor" type="xsd:string" use="optional" />
+ <xsd:attribute name="gridcolor" type="xsd:string" use="optional" />
+</xsd:complexType>
+
<xsd:complexType name="break" />
<xsd:complexType name="line" />
Modified: CometVisu/tags/post_0.6.0/visu/visu_config_demo.xml
===================================================================
--- CometVisu/tags/post_0.6.0/visu/visu_config_demo.xml 2011-11-20 21:45:11 UTC (rev 539)
+++ CometVisu/tags/post_0.6.0/visu/visu_config_demo.xml 2011-11-23 19:43:39 UTC (rev 540)
@@ -271,6 +271,10 @@
</slide>
<diagram_popup rrd="200_DALI_Linie_1_Strom" unit="mA" series="day" refresh="300">DALI Strom L1</diagram_popup>
<diagram_inline rrd="200_DALI_Linie_1_Strom" width="600" height="400"/>
+ <diagram_info rrd="200_DALI_Linie_1_Strom" unit="mA" series="day" refresh="300">
+ <label>DALI Strom L1</label>
+ <address transform="DPT:9.021">14/2/7</address>
+ </diagram_info>
<infotrigger uplabel="wärmer" downlabel="kälter" upvalue="1" downvalue="0" align="center" format="%.1f °C">
<label>Temperatur Sollwert</label>
<address transform="DPT:1.001">4/1/3</address>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|