A place where things actually work,
with a sense of humor.

Meuon
0 comments


keywords:
SVG
Smart
Grid
Data
Visualization
PHP

SVG Based Graphs
I've been playing around with SVG (Scalable Vector Graphics) for a few days as a tool to display data, as graphs/charts as well as ways to visual distribution grids, and more. Absolutely loverly technology, if you are NOT using a Microsoft web browser. Firefox and Opera and others support SVG, and it works very very well. I'm currently evaluating plugins for MSIE, but it's a fragmented world. There may be some SVG support coming in MS's Silverlight, but it is expected to be borken in Microsoft traditional: Embrace, Extend, Extinguish methodology. If you click on the image above to see the results, if you can display SVG in a browser.

If you are using MSIE, (Microsoft Internet Explorer) (32 bit) you can use: a Mozilla Firefox ActiveX plugin for MSIE available from:
a Mozilla Firefox ActiveX plugin for MSIE that seems to work very well.
 

meuon
0 comments


keywords:
PHP
Data
Visualization

Low Tech Data Display.
There is a lot of push towards incredibly powerful web toolkits. Very complex javascript, lots of embedded flash. But that requires powerful client computers, and all that JavaScript/ActionScript has fits crossing domains, for good reasons. So you have to go back to old school. Enter PHP and GDlib creating graphics on the fly at the web server. Geeky kWh Gauge example in PHP will create (given some assumptions) nice looking graphs as an image and will try to resize itself and the data nicely based on parameters given.

It's useful for embedding data displays low tech browsers as well as things like Chumby's, Google Electricity/kWh Gadgets and other widgets where everything but images seem to be cached, relayed, or protected from embedding data from other sources. The best part is the looks you get when showing to "Web 2.0 kids" who can't conceive of doing it without an IDE, JavaScript/ActionScript and possibly a fat embed/object download..

 

admin
0 comments


keywords:
Code
PHP
DOMDocument

PHP DOMDocument()
I've been having to do some weird things parsing HTML lately, and I usually just use a lot of regular expressions (amazing magical things). Sometimes, the target HTML is just so grungy, this is not easy, or even possible. Again, PHP to the rescue. It has some incredible built in tools for dealing with HTML like XML data, and this is some concept testing code from where I needed to start doing this. It's not the specific code I ended up with, but it was where I started.

Goal: Find the link text and the sub text in the a href tag as a span (but no other id/class) and seperate them out for parsing and reporting for other things.


<?php
$content = <<<EOF
This is a bogus HTML document example.
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<span id="info">id info with no a href</span>                   
<span id="info"><a href="#">link text<span>inner span</span></a></span><p>                   
<span>this</span> More body text. and more.      
EOF
;  
$doc = new DOMDocument();
$doc->preserveWhiteSpace = FALSE;
$doc->loadHTML("$content");
$doc->normalizeDocument() ;
$params  = $doc->getElementsByTagName('span') ;
$i = 0 ;
foreach ($params as $param) {
if($param->getAttribute('id') == 'info') {
  print "v: " . $doc->getElementsByTagName('span')->item($i)->firstChild->nodeValue . "<br> " ;
  print "a: " . $param->getElementsByTagName('a')->item(0)->firstChild->nodeValue . "<br> " ; 
  print "s: " . $param->getElementsByTagName('span')->item(0)->firstChild->nodeValue . "<br> " ;
} ;
$i++ ;
}
?>

The output looked like:

v: id info with no a href
a:
s:
v: link textinner span
a: link text
s: inner span
 
535 Chestnut Street - Suite 241 - Chattanooga TN 37402
423-605-6943