javascript - Can't find file, chart does not appear -
i have code :
<script> var area = new morris.area({ element: 'revenue-chart', resize: true, data: [ {y: '2011 q1', item1: 2666, item2: 2666}, {y: '2011 q2', item1: 2778, item2: 2294}, {y: '2011 q3', item1: 4912, item2: 1969}, {y: '2011 q4', item1: 3767, item2: 3597}, {y: '2012 q1', item1: 6810, item2: 1914}, {y: '2012 q2', item1: 5670, item2: 4293}, {y: '2012 q3', item1: 4820, item2: 3795}, {y: '2012 q4', item1: 15073, item2: 5967}, {y: '2013 q1', item1: 10687, item2: 4460}, {y: '2013 q2', item1: <?php echo file_get_contents("../adminpanel/pagecounters/totalviewsdecember.txt")?>, item2: 5713} ], xkey: 'y', ykeys: ['item1', 'item2'], labels: ['item 1', 'item 2'], linecolors: ['#a0d0e0', '#3c8dbc'], hidehover: 'auto' }); </script>
but chart doesn't appear when refresh page. (also file exists! tested it.)
how can fix it?
your js code correct, here arbitrary number substituted php:
http://jsbin.com/muzucozivu/1/edit?html,js,output
hence there few possible problems:
- you don't include right libraries
- the php fails reason , page truncated after that
- the element 'revenue-chart' not present or not visible in page.
to sure have libraries, copy them jsbin code (that cloned jsbin code found on morrisjs page).
to check second possibility, open page source , if rest of page absent or if php returned spurious value (if file_get_contents fails, return false).
the last 1 should take visual inspection of code or open firebug in firefox , right element. sure it's spelled correctly. check other js errors in console.
however if file exists, php still fail. common source of problems, php file_get_contents, misunderstanding "working directory" is, relative paths end being screwed. use absolute file path test that.
Comments
Post a Comment