FusionCharts -Hiding gauge labels in 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>
<!-- Hiding gauge labels in a simple Horizontal Linear Gauge showing Server CPU Utilization using attribute:
# showGaugeLabels - Whether to show labels on Gauge.
Deviation from theme
# valueFontSize
# valueFontBold
-->
<div id="chart-container">FusionCharts will render here</div>
<div id="checkbox-container">
<input type="checkbox" id="showLbl" name="padding" value="1" checked>Show Labels ?</input>
</div>
JavaScript
FusionCharts.ready(function() {
var showLabelCB = document.getElementById('showLbl'),
cpuGauge = new FusionCharts({
type: 'hlineargauge',
renderAt: 'chart-container',
id: 'cpu-linear-gauge',
width: '400',
height: '170',
dataFormat: 'json',
dataSource: {
"chart": {
"theme": "fusion",
"caption": "Server CPU Utilization",
"lowerLimit": "0",
"upperLimit": "100",
"numberSuffix": "%",
"chartBottomMargin": "20",
"valueFontSize": "11",
"valueFontBold": "0",
"showGaugeLabels": "1",
"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
showLabelCB.addEventListener && showLabelCB.addEventListener("click", showLabels);
//Function to show/hide labels
function showLabels() {
//Using showGaugeLabels attribute to show hide gauge labels
if (showLbl.checked) {
cpuGauge.setChartAttribute('showGaugeLabels', 1);
} else {
cpuGauge.setChartAttribute('showGaugeLabels', 0);
}
}
});