FusionCharts - Gallery Example - Doughnut 2D Chart
Created using FusionCharts Suite XT - www.fusioncharts.com
by FusionCharts
HTML
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<!-- This sample shows the usage of the configure() method -->
<div id="indicatorDiv">Method Name: <strong>configure()</strong>
<p>Configures status messages that are displayed while rendering a chart.</p>
<p>For this implementation, the <strong>configure()</strong> method is used with the <a href="http://www.fusioncharts.com/dev/api/fusioncharts.html#FusionCharts-parameters-options-dataEmptyMessage" target="_blank">dataEmptyMessage</a> option.</p>
<p>To show how this method works, no data - or empty data - is passed to the doughnut 2D chart.</p>
<p>
<i>Not data to display.</i> is the default message rendered when empty data is passed to the chart. Using the <strong>configure()</strong> method, this message has been changed to <i>No data to load. Please check the data source.</i>
</p>
<div class="text-center">
<button id="render" class="mb-20">Render Chart</button>
<div id="chart-container">FusionCharts will render here.</div>
</div>
</div>
CSS
#indicatorDiv {
width: 500px;
font-family:'Arial', 'Helvetica';
font-size: 13px;
}
#render {
padding: 10px;
font-size: 13px;
}
#chart-container {
font-family:'Arial', 'Helvetica';
font-size: 13px;
}
strong{
font-weight: bold;
}
.text-center {
text-align: center;
}
p {
margin: 10px auto;
}
.mb-20 {
margin-bottom: 20px;
}
JavaScript
FusionCharts.ready(function () {
var revenueChart = new FusionCharts({
type: 'doughnut2d',
renderAt: 'chart-container',
width: '200',
height: '200',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Split of Revenue by Product Categories",
"animation": "0",
"subCaption": "Last year",
"numberPrefix": "$",
"theme": "fint",
"captionFontSize": "13",
"subcaptionFontSize": "12",
"subcaptionFontBold": "0"
},
"data": [
]
}
});
function render() {
//revenueChart.configure("baseChartMessageColor","#f45b00");
/**
* @description
* The configure() method configures status messages that are displayed while rendering a chart.
.
*
* @param {FusionCharts~chartStatusMessages} option: To set/update multiple attributes at once, an object containing all the key-value pairs is passed. In case of a single value, a string that is the key (the attribute name) is passed.
* @param {String} value: If the option parameter has a single value as the key, this parameter is the value of that key.
* usage: chartObject.setChartAttribute(attribute, value);
*/
revenueChart.configure({
"dataEmptyMessage": "No data to load. Please check the data source."
});
revenueChart.render();
}
document.getElementById("render").addEventListener("click", render);
});