FusionCharts - Configuring Pointer Position in Horizontal Linear Gauge
Created using FusionCharts Suite XT - www.fusioncharts.com
by FusionCharts
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>
<!-- Configuring Pointer values in a simple Horizontal Linear Gauge showing Server CPU Utilization
Attributes :
# showValue - Whether to show values associated with pointer.
# valueAbovePointer - Whether to show the value above the pointer or below.
Deviation from Theme
# valueFontSize
# valueFontBold
-->
<div id="chart-container">FusionCharts will render here</div>
<div id="checkbox-container">
<input type="checkbox" id="showCB" name="padding" value="1" checked>Show Value</input><br>
<input type="checkbox" id="positionCB" name="padding" value="2">Place Value Above Pointer</input>
</div>
CSS
body {
padding: 10px;
}
#checkbox-container {
margin-top: 10px;
width: 400px;
}
body {
font-family: 'Helvetica Neue', Arial;
font-size: 11px;
font-weight: normal;
}
JavaScript
FusionCharts.ready(function() {
var showCheckBox = document.getElementById('showCB'),
posCheckBox = document.getElementById('positionCB'),
cpuGauge = new FusionCharts({
type: 'hlineargauge',
renderAt: 'chart-container',
width: '400',
height: '150',
dataFormat: 'json',
dataSource: {
"chart": {
"theme": "fusion",
"caption": "Server CPU Utilization",
"subcaptionFontBold": "0",
"lowerLimit": "0",
"upperLimit": "100",
"numberSuffix": "%",
"chartBottomMargin": "20",
"captionPadding": "10",
"valueAbovePointer": "0",
"valueFontSize": "13",
"valueFontBold": "0",
"gaugeFillMix": "{light-10},{light-70},{dark-10}",
"gaugeFillRatio": "40,20,40"
},
"colorRange": {
"color": [{
"minValue": "0",
"maxValue": "35",
"label": "Low"
},
{
"minValue": "35",
"maxValue": "70",
"label": "Moderate"
},
{
"minValue": "70",
"maxValue": "100",
"label": "High"
}
]
},
"pointers": {
"pointer": [{
"value": "75"
}]
}
}
})
.render();
//Set event listener for check boxes
showCheckBox.addEventListener && showCheckBox.addEventListener("click", showValue);
posCheckBox.addEventListener && posCheckBox.addEventListener("click", setPosition);
//Function to show hide value
function showValue(evt, obj) {
//Using showValue attribute to show hide pointer value
if (showCB.checked) {
cpuGauge.setChartAttribute('showValue', 1);
posCheckBox.disabled = false;
} else {
cpuGauge.setChartAttribute('showValue', 0);
posCheckBox.disabled = true;
}
}
//Function to change value pointer
function...