/*
Demonstrate no-data-to-display plugin.
The plugin will automatically display a customizable message when there is no data visible in the chart.
It can alternatively be displayed/hidden at any time manually, optionally with custom text. There is also
a new function "hasData()" for charts and series, returning true if there is data visible in the plot area.
*/
$(function () {
var chart,
btnRemove = $('#remove'),
btnAdd = $('#add'),
btnShow = $('#showCustom');
btnAdd.click(function () {
chart.series[0].addPoint(Math.floor(Math.random() * 10 + 1));
});
btnRemove.click(function () {
if(chart.series[0].points[0]) {
chart.series[0].points[0].remove();
}
});
// Show a custom message
btnShow.click(function () {
if(!chart.hasData()) { // Only if there is no data
chart.hideNoData(); // Hide old message
chart.showNoData("Your custom error message");
}
});
$('#container').highcharts({
title: {
text: 'No data in line chart - with custom options'
},
series: [{
type: 'line',
name: 'Random data',
data: []
}],
lang: {
// Custom language option
//noData: "Nichts zu anzeigen"
},
/* Custom options */
noData: {
// Custom positioning/aligning options
position: {
//align: 'right',
//verticalAlign: 'bottom'
},
// Custom svg attributes
attr: {
//'stroke-width': 1,
//stroke: '#cccccc'
},
// Custom css
style: {
//fontWeight: 'bold',
//fontSize: '15px',
//color: '#202030'
}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.