XQuery/Google Chart Bullet Bar

Motivation
To display a Bullet Chart to display the current value of a system parameter with its safe and danger ranges.

Bullet Bars
This is one of the chart types supported by the now deprecated Google Chart API which constructs the chart from URL parameters.

Sample URL
http://chart.apis.google.com/chart?cht=bhs&chs=150x30&chd=t:70&chm=r,ff0000,0,0.0,0.5|r,ffff00,0,0.5,0.75|r,00A000,0,0.75,1.0|r,000000,0,0.8,0.81&chco=000000&chbh=10

Sample Screen Image




Declarative XML Representation
An XML representation of the chart design might be:

Google Chars Representation
Which, when supplied with a current value, must be transformed into the following URL:

Sample XQuery Function
This function takes the specification of the chart and the current value, and generates the corresponding Google Chart URL.

Note that the width of the danger, warn and ok bars (red, yellow and green) are expressed as a percentage digit from 0 to 100.

Generating a bullet bar
[/visualization/bullet-chart.xq Execute]