javascript - flot chart get data from span using jquery -


i'm using php create span contains data flot chart. want data using jquery using

var somevar= $('span#someid').text(); 

it takes data span, chart not being drawn. know data correct if copy span , assign var directly in javascript, chart comes straight away

here's copy of data (it's stored this

<span id="someid">[["19.00","0.04833"],["18.45","0.04717"],["18.35","0.04833"],["18.20","0.04686"],["18.10","0.04718"],["18.00","0.04937"],["17.50","0.04674"],["17.35","0.04804"],["17.20","0.04810"],["17.10","0.04723"],["17.00","0.04989"],["16.45","0.05519"],["16.35","0.08635"],["16.20","0.04742"],["16.10","0.04712"],["16.00","0.04861"],["15.50","0.04607"],["15.40","0.04758"],["15.30","0.04662"],["15.20","0.04768"]]</span> <script> $("#flot-dashboard-chart").length && $.plot($("#flot-dashboard-chart"), [             somevar         ], </script> 

i don't know if values have representarion because run test code , gives me simple line.

the thing need parse span

var flotarray = $.parsejson($("#someid").text()); 

here fiddle example of flot data (the blue line)

http://jsfiddle.net/kdfk8ej9/


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -