FusionCharts - Bulb Gauge in Javascript
Created using FusionCharts Suite XT - www.fusioncharts.com
HTML
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>
<!--
Sample for Bulb Gauge.
-->
<div id="chart-container">FusionCharts will render here</div>
CSS
#headerdiv {
font-family: "Arial", "Helvetica";
font-size: 13px;
font-weight: bold;
}
#valueDiv {
color: #EEEEEE;
text-align: center;
font-size: 25px;
padding: 10px;
margin-top: 5px;
font-family: "Arial", "Helvetica";
font-weight: bold;
}
JavaScript
FusionCharts.ready(function() {
var salesChart = new FusionCharts({
type: 'bulb',
renderAt: 'chart-container',
id: 'myChart',
width: '600',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"upperlimit": "-5",
"lowerlimit": "-60",
"chartLeftMargin": "100",
"showshadow": "0",
"showBorder": "1",
"useColorNameAsValue": "1",
"placeValuesInside": "1",
"valueFontSize": "16",
//Tooltext
"plottooltext": "<span id='headerdiv'>Current Temperature:</span>{br}<div id='valueDiv'>$value°C</div>",
//Theme
"theme": "fusion"
},
"colorrange": {
"color": [{
"minvalue": "-60",
"maxvalue": "-35",
"label": "Mission control, <br> we have a situation!",
"code": "#ff0000"
},
{
"minvalue": "-35",
"maxvalue": "-25",
"label": "Something is just not right!",
"code": "#ff9900"
},
{
"minvalue": "-25",
"maxvalue": "-5",
"label": "All well ahoy!",
"code": "#00ff00"
}
]
},
"value": "-5",
"annotations": {
"groups": [{
"items": [{
"type": "text",
"text": "Chart{br}Caption{br}(Text Annotation)",
"x": "$chartStartX+90",
"y": "$chartCenterY",
"fontSize": "24",
"color": "#FF0000"
}]
}]
}
},
"events": {
"rendered": function(evtObj, argObj) {
setInterval(function() {
var num = (Math.floor(Math.random() * 55) * -1) - 5;
FusionCharts("myChart").feedData("&value=" + num);
}, 10000);
}
}
});
salesChart.render();
});