Difference between revisions of "Widget:GraphInteractivity"

From Hackerspace ACKspace
Jump to: navigation, search
m (fixed various (jslint) issues)
m (update color state (experimental))
Line 127: Line 127:
 
powerstrip.textContent = "strip " + powerstrip.value + powerstrip.unit;
 
powerstrip.textContent = "strip " + powerstrip.value + powerstrip.unit;
  
var color = "green";
+
var color;
 +
if ( powerstrip.value < 5 )
 +
color = "lightgray";
 +
else if ( powerstrip.value < 10 )
 +
color = "green";
 +
else if ( powerstrip.value < 100 )
 +
color = "lightgreen";
 +
else if ( powerstrip.value < 200 )
 +
color = "yellow";
 +
else if ( powerstrip.value < 1000 )
 +
color = "orange";
 +
else
 +
color = "red";
 +
 
 
g_coloredNodes.push( [ document.querySelector( "g#" + _powerConsumption.name ), color ] );
 
g_coloredNodes.push( [ document.querySelector( "g#" + _powerConsumption.name ), color ] );
 
} );
 
} );
  
decorateNodes( g_coloredNodes.concat( [ [g_selectedNode, "lightskyblue" ], [ node, "lightsteelblue" ] ].reverse() ).reverse() );
+
decorateNodes( g_coloredNodes.concat( [ [g_selectedNode, "lightskyblue" ] ].reverse() ).reverse() );
 
}
 
}
 
}
 
}

Revision as of 13:48, 29 May 2018

This widget allows you to display the Space API data (provided as JSON)

Created by Xopr

Using this widget

To insert this widget, use the following code:

{{#widget:GraphInteractivity}}

This will add javascript logic that enables 'interactivity' to graphs.

Copy to your site

To use this widget on your site, just install MediaWiki Widgets extension and copy full source code of this page to your wiki as Widget:GraphInteractivity article.