netsuite - Using libraries in suitescripts -
so have simple chart made using chart.js, using following code:
<html lang="en"> <head> <meta charset="utf-8" /> <title>chart.js demo</title> <script src='chart.min.js'></script> </head> <body> <canvas id="buyers" width="600" height="400"></canvas> <script> var buyerdata = { labels : ["january","february","march","april","may","june"], datasets : [ { fillcolor : "rgba(172,194,132,0.4)", strokecolor : "#acc26d", pointcolor : "#fff", pointstrokecolor : "#9db86d", data : [203,156,99,251,305,247] } ] } var buyers = document.getelementbyid('buyers').getcontext('2d'); new chart(buyers).line(buyerdata); </script> </body> </html>
i recreate graph in netsuite, problem believe having trying include chart.js library. have tried going scripts, , adding chart.js file in under "library script file"s. tried placing in web hosted files adding <script src="http://www.wndauthors.com/other/chart.min.js"></script>
within code neither seem working correctly.
what correct way recreate above code within suitescript?
tried chart.js worked
for library file uploaded chart.min in file cabinet , gave ur in src
following working code snippet
function demohtml(request, response) { var html = '<html lang="en"><head><title>chart.js demo</title><script src="https://system.netsuite.com/core/media/media.nl............=.js"></script></head><body>hi<canvas id="buyers" width="600" height="400"></canvas><script>var buyerdata = {labels : ["january","february","march","april","may","june"],datasets : [{fillcolor : "rgba(172,194,132,0.4)",strokecolor : "#acc26d",pointcolor : "#fff",pointstrokecolor : "#9db86d",data : [203,156,99,251,305,247]}]};var buyers = document.getelementbyid("buyers").getcontext("2d");new chart(buyers).line(buyerdata); </script> </body></html>'; response.write( html ); //prefix header custom-header. see nlobjresponse.setheader(name, value) response.setheader('custom-header-demo', 'demo'); }
one more missed ; variable buyerdata
Comments
Post a Comment