{"id":923,"date":"2011-02-15T22:49:34","date_gmt":"2011-02-15T20:49:34","guid":{"rendered":"http:\/\/sickel.net\/blogg\/?p=923"},"modified":"2013-04-13T22:25:59","modified_gmt":"2013-04-13T20:25:59","slug":"making-stripcharts-using-svg-and-javascript","status":"publish","type":"post","link":"https:\/\/sickel.net\/blogg\/?p=923","title":{"rendered":"Making stripcharts using svg and javascript"},"content":{"rendered":"<p>April 2013: I have made a <a href=\"http:\/\/sickel.net\/blogg\/?p=1506\">new project<\/a> based on this, although for static plotting.<\/p>\n<p>I needed to present data in a webapplication using strip chart. From earlier experiences on data presentation, I knew that making bit mapped graphics to be updated when new data were to be presented, put a fairly high load on the server, as everything was to be reprocessed each time, at the other end, a java applet seemed to be overkill for this application. So to the rescue,  svg and javascript.<\/p>\n<p>The original inspiration was from <a href=\"http:\/\/www.alistapart.com\/articles\/cross-platform-scalable-vector-graphics-with-svgweb\/\">A List Apart<\/a> that showed the possibility of manipulating a svg graphics using javascript. Googling a bit, I came across <a href=\"http:\/\/mblogic.sourceforge.net\/mbhmi\/manualpage\/hmisamplesstripchart-en.html\">mblogics<\/a> and <a href=\"http:\/\/www.anomaly.org\/wade\/projects\/instruments\/\">G Wade Johnsson&#8217;s anomaly.org<\/a>. Although both those were too complicated for what I needed, I was able to steal quite a few ideas from those two implementations.<\/p>\n<p>Presently I am able to run multiple stripcharts in one web page, fetching data from a server and updating the charts and some parts of the web page:<a href=\"http:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"946\" data-permalink=\"https:\/\/sickel.net\/blogg\/?attachment_id=946\" data-orig-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts.png\" data-orig-size=\"1144,771\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Stripchart application\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts-300x202.png\" data-large-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts-1024x690.png\" src=\"http:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts-1024x690.png\" alt=\"Screenshot 17.02.2011\" title=\"Stripchart application\" width=\"640\" height=\"431\" class=\"alignnone size-large wp-image-946\" srcset=\"https:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts-1024x690.png 1024w, https:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts-300x202.png 300w, https:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/stripcharts.png 1144w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Most of the files needed for the front end are available in <a href='http:\/\/sickel.net\/blogg\/wp-content\/2011\/02\/Svg_stripchart110217.zip'>Svg_stripchart110217<\/a>. The backend&#8217;s logic cannot be used without the database, but in the zip file there is a file &#8216;ajaxserver-23.json&#8217; which is an example of a response from the server, just make a normal web server application in php or whatever suits your needs that rather than html for presentation in a web browser returns a selection from your data set as a json-file.<\/p>\n<p>The other files are<br \/>\nstripchart.php.htm &#8211; a &#8216;driver&#8217; html file that loads the neccesary parts into a browser<br \/>\nstripchart.svg &#8211; a svg template to start the plot<br \/>\nchart.js &#8211; javascript defining the strip chart object<br \/>\nstripchart.js &#8211; sets up and uses the chart.js objects<br \/>\nmsi_smarty.css &#8211; some styling &#8211; a lot of it is unused here as this file is used for a complete application<\/p>\n<p>in addition to my files, two external libraries are needed:<\/p>\n<p><a href=\"http:\/\/prototypejs.org\">prototype<\/a> (I am still using 1.6, 1.7 is just released, I cannot see any reason that should cause any problems, but I have still not tested it)<\/p>\n<p><a href=\"http:\/\/code.google.com\/p\/svgweb\/\">svgweb<\/a> &#8211; a compatibility layer to extend svg support to more browsers. It is critical to be able to run the strip charts on internet explorer, If you know you are using svg-supporting browsers (most others) just delete the reference to svg.js in the .html-file. On my server, I have the external libraries installed in \/lib\/.<\/p>\n<p>Stay tuned here to pick up updates.<\/p>\n<p>2011 02 17:<\/p>\n<ul>\n<li>Some cleaning up and commenting of the code<\/li>\n<li>Possible to select scale and parameter to plot per strip chart<\/li>\n<li>Red and yellow signaling too high or too low measurements<\/li>\n<\/ul>\n<p>TODO: <\/p>\n<ul>\n<li>Dynamic handling of parameters. (done, but not yet uploaded)<\/li>\n<li>Using the <a href=\"http:\/\/sickel.net\/blogg\/?p=956\">parent<\/a> object to update the html when a mark is set, rather than waiting for the pe to notice it<\/li>\n<\/ul>\n<p>Another use of many of the same ideas is in <a href=\"http:\/\/sickel.net\/blogg\/?p=1506\">Reading temperature data out of postgresql<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>April 2013: I have made a new project based on this, although for static plotting. I needed to present data in a webapplication using strip chart. From earlier experiences on data presentation, I knew that making bit mapped graphics to &hellip; <a href=\"https:\/\/sickel.net\/blogg\/?p=923\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[24],"tags":[],"class_list":["post-923","post","type-post","status-publish","format-standard","hentry","category-svg"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnVtD-eT","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=923"}],"version-history":[{"count":20,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/923\/revisions"}],"predecessor-version":[{"id":1565,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/923\/revisions\/1565"}],"wp:attachment":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}