Thanks David,<div><br></div><div>As an update, HJScript is a bit of a nightmare to figure out (missing documentation, examples). And the model of JS values:</div><div><div> <a href="http://hackage.haskell.org/packages/archive/language-javascript/0.4.10/doc/html/Language-JavaScript-Parser.html#t:Node">http://hackage.haskell.org/packages/archive/language-javascript/0.4.10/doc/html/Language-JavaScript-Parser.html#t:Node</a></div>
</div><div>Seems less human comprehensible than, for example, WebBits':</div><div><div> <a href="http://hackage.haskell.org/packages/archive/WebBits/2.0/doc/html/BrownPLT-JavaScript-Syntax.html">http://hackage.haskell.org/packages/archive/WebBits/2.0/doc/html/BrownPLT-JavaScript-Syntax.html</a><br>
</div><div><br></div><div>However, jmacro is a breeze for spitting out JS code. The little script below will make a simple line plot with google charts.</div><div><br></div><div>I'll give flot a try latter. Zooming / panning sounds nice.</div>
<div><br></div><div>Cheers,</div><div> -Ryan</div><div><div><br></div><div>Aforementioned script:</div><div>-------------------------------------------------------------------------------</div><div><br></div><div>{-# LANGUAGE QuasiQuotes #-}</div>
<div><br></div><div>import Language.Javascript.JMacro</div><div><br></div><div>hdr :: String</div><div>hdr = "<html> <head> <script type=\"text/javascript\" src=\"<a href="https://www.google.com/jsapi\">https://www.google.com/jsapi\</a>"></script> <script type=\"text/javascript\">"</div>
<div><br></div><div>ftr :: String</div><div>ftr = " </script> </head> <body> <div id=\"chart_div\" style=\"width: 900px; height: 500px;\"></div> </body> </html>"</div>
<div><br></div><div><br></div><div>testdata :: [(String, Int, Int)]</div><div>testdata = [</div><div> ("2004", 100, 400),</div><div> ("2005", 1170, 460),</div><div> ("2006", 860, 580),</div>
<div> ("2007", 1030, 540)</div><div> ]</div><div><br></div><div>-- | This provides a set of basic functional programming primitives, a few utility functions</div><div>-- and, more importantly, a decent sample of idiomatic jmacro code. View the source for details.</div>
<div>-- body :: JStat</div><div>body :: (ToJExpr a3, ToJExpr a2, ToJExpr a1, ToJExpr a) => (a, a1, a2) -> a3 -> JStat</div><div>body (title,line1,line2) testdata = [$jmacro|</div><div><br></div><div> google.load("visualization", "1", {packages:["corechart"]});</div>
<div><br></div><div> fun drawChart {</div><div> var dat = new google.visualization.DataTable();</div><div> dat.addColumn('string', `(title)` );</div><div> dat.addColumn('number', `(line1)` );</div>
<div> dat.addColumn('number', `(line2)` );</div><div><br></div><div> // -- Here's our data... this can get BIG:</div><div> dat.addRows( `(testdata)` );</div><div><br></div><div> var options = { title: `(title)` };</div>
<div> var chart = new google.visualization.LineChart(document.getElementById('chart_div'));</div><div> chart.draw(dat, options);</div><div> }</div><div><br></div><div> google.setOnLoadCallback(drawChart);</div>
<div>|]</div><div><br></div><div>main = do</div><div> putStrLn hdr</div><div> print$ renderJs$ body ("blah","line1","line2") testdata</div><div> putStrLn ftr</div></div></div><div><br></div>