{"id":571,"date":"2007-08-13T07:41:40","date_gmt":"2007-08-13T14:41:40","guid":{"rendered":"http:\/\/www.latenightsw.com\/blogfs5\/?p=45"},"modified":"2012-05-05T18:26:16","modified_gmt":"2012-05-06T01:26:16","slug":"graphx-plugin","status":"publish","type":"post","link":"https:\/\/markalldritt.com\/?p=571","title":{"rendered":"GraphX Plugin"},"content":{"rendered":"<p>The recent FaceSpan 5.0d42 build includes a graphing plugin based on Chad Weider&#8217;s <a href=\"http:\/\/blog.oofn.net\/projects\/graphx\">GraphX<\/a> framework.  Chad&#8217;s framework provides three graphing views: curve, histogram and scatter plot.<\/p>\n\n<p>As always when creating FaceSpan plugins from Cocoa frameworks, the tough part is converting the Cocoa APIs into a simple to use AppleScript syntax.  In the case of these graphing views, I have substituted the &#8216;Data Source&#8217; based APIs with a simple event for the curve view, and a <em>value<\/em> property that accepts a list of values to be graphed (a list of reals for the histogram and a list of x-y points for the scatter plot).<\/p>\n\n<p>Here&#8217;s how it all looks running in a FaceSpan-built application:<\/p>\n\n<p><img id=\"image44\" src=\"http:\/\/blog.latenightsw.com\/wp-content\/uploads\/2007\/08\/graphx.jpg\" alt=\"graphx.jpg\" \/><\/p>\n\n<p>The code for the curve view looks like this:<\/p>\n\n<pre>\n--\n--  CT curve uses this event handler to get the data to be graphed\n--\non CT get y value theCTCurve for theXValue\n    return theXValue * theXValue * theXValue + 1.0\nend CT get y value\n<\/pre>\n\n<p>The event is called repeatedly by the curve view to generate the data to be graphed.<\/p>\n\n<p>The code for the histogram looks like this:<\/p>\n\n<pre>\non initialize theResponder\n    --  CT histogram needs a list of reals to graph\n    set theData to {}\n\n    repeat with i from (x axis minimim) to (x axis maximum)\n        set end of theData to random number from 1 to 10\n    end repeat\n    set value to theData\n\nend initialize\n<\/pre>\n\n<p>Here I simply generate a random series of values and assign them to the view&#8217;s <em>value<\/em> property.  The plugin does the rest.<\/p>\n\n<p>And finally, the code for the scatter plot looks like this:<\/p>\n\n<pre>\non initialize theResponder\n    --  CT scatter plot requires a list of points (x, y pairs) to graph...\n\n    set yValue to 1.0\n    set theData to {}\n\n    repeat with i from (x axis minimim) to (x axis maximum)\n        set end of theData to {i, yValue}\n        set yValue to yValue + (random number from 0 to 2.0)\n    end repeat\n    set value to theData\n\nend initialize\n<\/pre>\n\n<p>Again, I simply generate a random series of point values and assign them to the view&#8217;s <em>value<\/em> property.  The plugin does the rest.<\/p>\n\n<p>The sources for the plugin are included in the FaceSpan 5.0d42 SDK.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The recent FaceSpan 5.0d42 build includes a graphing plugin based on Chad Weider&#8217;s GraphX framework. Chad&#8217;s framework provides three graphing views: curve, histogram and scatter&#8230;<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/markalldritt.com\/?p=571\">Continue Reading<span class=\"screen-reader-text\">GraphX Plugin<\/span><\/a><\/div><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7AQk-9d","_links":{"self":[{"href":"https:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts\/571"}],"collection":[{"href":"https:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=571"}],"version-history":[{"count":2,"href":"https:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts\/571\/revisions"}],"predecessor-version":[{"id":605,"href":"https:\/\/markalldritt.com\/index.php?rest_route=\/wp\/v2\/posts\/571\/revisions\/605"}],"wp:attachment":[{"href":"https:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/markalldritt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}