Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show 'no data available' inside dygraph chart when the response contains empty array

Tags:

dygraphs

Is it possible to show 'no data available' inside dygraph chart when the response contains empty array

like image 994
srinivas Avatar asked Oct 20 '25 01:10

srinivas


2 Answers

You can do this :http://jsfiddle.net/60ygwkgk/26/

Code

data = ",\n0,0";
        g = new Dygraph(
            document.getElementById("graph"),
            data,{
                drawYAxis:false,
                title:'no data available',
                pointSize: 0,
                highlightCircleSize: 0,
                showLabelsOnHighlight:false
            } );
like image 189
loli Avatar answered Oct 22 '25 05:10

loli


Thanks @loli, your solution was very useful for me. In my case:

if (contentcsv.length<1) { //if contentcsv is empty
    contentcsv = ",\n0,0";
    var title = "no data available";
}
else {title = "My Title";}

g = new Dygraph(
document.getElementById("graph"),
contentcsv,
{ 
    title: title,
    ylabel: 'Values',
    xlabel: 'Date',
  })
like image 26
Capensis Avatar answered Oct 22 '25 05:10

Capensis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!