<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Entrance</title>
	<atom:link href="http://dbentrance.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dbentrance.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 30 Jul 2010 00:28:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CO2 Emitted by Selected Vehicles</title>
		<link>http://dbentrance.com/blog/?p=504</link>
		<comments>http://dbentrance.com/blog/?p=504#comments</comments>
		<pubDate>Fri, 30 Jul 2010 00:28:37 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=504</guid>
		<description><![CDATA[

This chart tells a story, doesn&#8217;t it? 

The approximate value for Lear Jet CO2 emissions is thanks to a calculation on http://benzzo.co.tv/learjet-fuel-consumption and is based on values from the DOE site  http://www.eia.doe.gov/  Here is the Entrance script for producing the chart:

&#160; &#160; plot rotatedbarchart
&#160; &#160; &#160;     skyblue bar,
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/rotated_co2.png" alt="rotated" /></p>
<p>
This chart tells a story, doesn&#8217;t it? </p>
<p>
The approximate value for Lear Jet CO2 emissions is thanks to a calculation on <a href="http://benzzo.co.tv/learjet-fuel-consumption">http://benzzo.co.tv/learjet-fuel-consumption</a> and is based on values from the DOE site  <a href="http://www.eia.doe.gov/">http://www.eia.doe.gov/</a>  Here is the Entrance script for producing the chart:</p>
<p><code><br />
&nbsp; &nbsp; plot rotatedbarchart<br />
&nbsp; &nbsp; &nbsp;     skyblue bar,<br />
&nbsp; &nbsp; &nbsp;    all axislabels,<br />
&nbsp; &nbsp; &nbsp;    datalabels right<br />
&nbsp; &nbsp;   with<br />
&nbsp; &nbsp; &nbsp;      no collar<br />
&nbsp; &nbsp; &nbsp;      no outlines<br />
&nbsp; &nbsp; &nbsp;      baroverlap 0<br />
&nbsp; &nbsp; &nbsp;      barwidth .85<br />
&nbsp; &nbsp; &nbsp;      barseparation 5<br />
&nbsp; &nbsp; &nbsp;      no sides<br />
&nbsp; &nbsp; &nbsp;      no xaxis<br />
&nbsp; &nbsp; &nbsp;      no labels x<br />
&nbsp; &nbsp; &nbsp;      no ticks x<br />
&nbsp; &nbsp; &nbsp;      scale x 0 1800 600<br />
&nbsp; &nbsp; &nbsp;      frame insets 175 40 85 0<br />
&nbsp; &nbsp; select<br />
&nbsp; &nbsp; &nbsp;      `grams_per_km`,name, concat(grams_per_km, ' g/km')<br />
&nbsp; &nbsp; &nbsp;      from co2_emissions<br />
&nbsp; &nbsp;  union<br />
&nbsp; &nbsp; select<br />
&nbsp; &nbsp; &nbsp;      1766, 'Lear Jet', concat(1766, ' g/km')<br />
&nbsp; &nbsp; &nbsp;      order by grams_per_km<br />
;<br />
</code></p>
<p>
Finally, here&#8217;s sample data for the various cars:<br />
&#8220;grams_per_km&#8221;,&#8221;name&#8221;<br />
&#8220;383&#8243;,&#8221;Escalade&#8221;<br />
&#8220;346&#8243;,&#8221;Hummer&#8221;<br />
&#8220;324&#8243;,&#8221;Corvette&#8221;<br />
&#8220;268&#8243;,&#8221;Escalade Hybrid&#8221;<br />
&#8220;198&#8243;,&#8221;Mercedes Benz clc class&#8221;<br />
&#8220;140&#8243;,&#8221;BMW Series 1&#8243;<br />
&#8220;167&#8243;,&#8221;Subaru Forester&#8221;<br />
&#8220;148&#8243;,&#8221;Accord&#8221;<br />
&#8220;119&#8243;,&#8221;Volvo v70&#8243;<br />
&#8220;119&#8243;,&#8221;Ford Fusion&#8221;<br />
&#8220;116&#8243;,&#8221;Ford Fiesta&#8221;<br />
&#8220;104&#8243;,&#8221;Toyota Prius&#8221;<br />
&#8220;101&#8243;,&#8221;Honda Insight&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=504</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counting Cases of H1N1</title>
		<link>http://dbentrance.com/blog/?p=465</link>
		<comments>http://dbentrance.com/blog/?p=465#comments</comments>
		<pubDate>Fri, 16 Jul 2010 15:41:33 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=465</guid>
		<description><![CDATA[

The CDC site, http://www.cdc.gov/flu/weekly/,  has a chart I thought could use a make-over, and this is the result.   The Entrance version is easier to read, and titles on the two vertical axes don&#8217;t collide with the axis labels.  

Reducing chart clutter makes the shape of the H1N1 counts clearer:



The script for [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/flu_good.png" alt="flu" /></p>
<p>
The CDC site, <a href="http://www.cdc.gov/flu/weekly/">http://www.cdc.gov/flu/weekly/</a>,  has a chart I thought could use a make-over, and this is the result.   The Entrance version is easier to read, and titles on the two vertical axes don&#8217;t collide with the axis labels.  </p>
<p>
Reducing chart clutter makes the shape of the H1N1 counts clearer:</p>
<p>
<img src="http://dbentrance.com/blog_images/flu_better.png" alt="better" /></p>
<p>
The script for the top chart is <a href="http://dbentrance.com/demo/flu_good.plotql">here</a> and  the script for the bottom one is <a href="http://dbentrance.com/demo/flu_better.plotql">here</a></p>
<p>
I  started the scripts with Charts | Make a stacked bar chart&#8230; and then tuned up a few things.  As you can see, the Tango Desktop colors LIGHT SKYBLUE and LIGHT TANGOORANGE work well together.</p>
<p>
Finally,  <a href="http://dbentrance.com/demo/flu.csv">here is the CSV data</a> (which can be imported using Entrance Tools | Import file or URL..)</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=465</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Line Styles (Entrance Version 1.7.10)</title>
		<link>http://dbentrance.com/blog/?p=403</link>
		<comments>http://dbentrance.com/blog/?p=403#comments</comments>
		<pubDate>Thu, 10 Jun 2010 01:16:59 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=403</guid>
		<description><![CDATA[ Here is a sampler of line styles supported by Entrance version 1.7.10:



plot
  black dashed line,   -- default
  black dotted line,
  black dashdotted line,
  black solid line,
  axislabels
  with
    page 0 0 500 400
    gridlines
    comment " "
 [...]]]></description>
			<content:encoded><![CDATA[<p> Here is a sampler of line styles supported by Entrance version 1.7.10:</p>
<p>
<img src="http://dbentrance.com/blog_images/style_default.png" alt="default" /></p>
<p><pre>
plot
  black dashed line,   -- default
  black dotted line,
  black dashdotted line,
  black solid line,
  axislabels
  with
    page 0 0 500 400
    gridlines
    comment " "
    comment left "Default Line Thickness"
select Jan, Jan + 30, Jan + 60, jan+90, year  from cpi_orig
  where year < 2007;
</pre>
<p>
<img src="http://dbentrance.com/blog_images/style_thin.png" alt="thin" /></p>
<p><pre>
plot
  black thin dashed line,
  black thin dotted line,
  black thin dashdotted line,
  black thin solid line,
  axislabels
  with
    page 0 0 500 400
    gridlines
    comment " "
    comment left "THIN Lines"
select Jan, Jan + 30, Jan + 60, jan+90, year  from cpi_orig
  where year < 2007;
</pre>
<p>
<img src="http://dbentrance.com/blog_images/style_thick.png" alt="thick" /></p>
<p><pre>
plot
  black thick dashed line,
  black thick dotted line,
  black thick dashdotted line,
  black thick solid line,
  axislabels
  with
    page 0 0 500 400
    gridlines
    comment " "
    comment left "THICK Lines"
select Jan, Jan + 30, Jan + 60, jan+90, year  from cpi_orig
  where year < 2007;
</pre>
<p>
<img src="http://dbentrance.com/blog_images/style_verythick.png" alt="verythick" /></p>
<p><pre>
plot
  black very thick dashed line,
  black very thick dotted line,
  black very thick dashdotted line,
  black very thick solid line,
  axislabels
  with
    page 0 0 500 400
    gridlines
    comment " "
    comment left "VERY THICK Lines"
select Jan, Jan + 30, Jan + 60, jan+90, year  from cpi_orig
  where year < 2007;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=403</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where is Deepwater Horizon?</title>
		<link>http://dbentrance.com/blog/?p=375</link>
		<comments>http://dbentrance.com/blog/?p=375#comments</comments>
		<pubDate>Wed, 09 Jun 2010 21:40:13 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=375</guid>
		<description><![CDATA[

&#160;  plot bitmapchart
&#160;  &#160;  &#160;      lat, lon, datalabels below
&#160;     with
&#160;  &#160;  &#160;      pagebitmap gulf_big.png
&#160;  &#160;  &#160;      foreground white
&#160;  &#160;  &#160;      background white
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/deep.png" alt="deep" /><br />
<code><br />
&nbsp;  plot bitmapchart<br />
&nbsp;  &nbsp;  &nbsp;      lat, lon, datalabels below<br />
&nbsp;     with<br />
&nbsp;  &nbsp;  &nbsp;      pagebitmap gulf_big.png</p>
<p>&nbsp;  &nbsp;  &nbsp;      foreground white<br />
&nbsp;  &nbsp;  &nbsp;      background white<br />
&nbsp;  &nbsp;  &nbsp;      marker medium  red circle</p>
<p>&nbsp;  &nbsp;  &nbsp;      scale x  -100 -75 10<br />
&nbsp;  &nbsp;  &nbsp;      scale y     15   32  10<br />
&nbsp;  &nbsp;  &nbsp;      frame insets 0 0 0 0</p>
<p>&nbsp;  &nbsp;  &nbsp;      no yaxis<br />
&nbsp;  &nbsp;  &nbsp;      no xaxis<br />
&nbsp;  &nbsp;  &nbsp;      no sides<br />
&nbsp;  select<br />
&nbsp;  &nbsp;  &nbsp;    28.72,  -88.36, 'Deepwater Horizon';<br />
</code><br />
This Entrance map plots the location of Deepwater Horizon  (latitude 28.72, longitude -88.36). The PNG file I used for the background is <a href="http://dbentrance.com/blog_images/gulf_big.png">here</a>.  Its left edge s longitude -100, right -75.  The top edge of the map is latitude 15, bottom 32. </p>
<p>
To make maps like this, you can use <a href="http://woodshole.er.usgs.gov/mapit/">the Wood Hole MapIt server</a>.    &nbsp; Use Entrance PAGEBITMAP to specify the background map and FRAME INSETS, SCALE X, and SCALE Y set it up its scale.  Using PAGEBITMAP you can overlay any of the Entrance charts on a background image this way.</p>
<p>
Use Entrance FRAME when you know the scale for part of \the background image.  Here&#8217;s a NOAA map of the disaster site with an Entrance plot layered on top:<br />
<img src="http://dbentrance.com/blog_images/noaa.png" alt="noaa" /><br />
<code><br />
&nbsp; plot bitmapchart<br />
&nbsp; &nbsp; &nbsp;   lat, lon, datalabels<br />
&nbsp; &nbsp;    with<br />
&nbsp; &nbsp; &nbsp;     pagebitmap noaa_gulf.png<br />
&nbsp; &nbsp; &nbsp;     foreground black<br />
&nbsp; &nbsp; &nbsp;     background white<br />
&nbsp; &nbsp; &nbsp;     fontsize 18</p>
<p>&nbsp; &nbsp; &nbsp;     marker unfilled large red circle<br />
&nbsp; &nbsp; &nbsp; --    framecolor rgba(0,0,255,100)<br />
&nbsp; &nbsp; &nbsp;     scale x  -91.00 -87.00  10<br />
&nbsp; &nbsp; &nbsp;     scale y  28.00 31.00 10</p>
<p>&nbsp; &nbsp; &nbsp;     frame 218 42 705 408</p>
<p>&nbsp; &nbsp; &nbsp;     no yaxis<br />
&nbsp; &nbsp; &nbsp;     no xaxis<br />
&nbsp; &nbsp; &nbsp;     no sides<br />
&nbsp; select<br />
&nbsp; &nbsp; &nbsp; 28.72,  -88.36, 'Deepwater Horizon';</p>
<p>
With the FRAMECOLOR line uncommented, you can see the FRAME used for scaling:</p>
<p>
<img src="http://dbentrance.com/blog_images/noaa_blue.png" alt="blue_noaa" /><br />
</code></p>
<p>
To figure out the FRAME coordinates, start by drawing a chart with the map as the PAGEBITMAP.  Then drag out a box somewhere where it will be easy to assign (lat, lon) coordnates (in this case, between reference lines).  When the Entrance popup appears select &#8220;Get Box Info&#8230;&#8221; and you can determine the pixel coordinates to use for the new FRAME.</p>
<p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=375</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining and Layering Charts</title>
		<link>http://dbentrance.com/blog/?p=356</link>
		<comments>http://dbentrance.com/blog/?p=356#comments</comments>
		<pubDate>Sat, 08 May 2010 00:04:22 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=356</guid>
		<description><![CDATA[


Entrance Version 1.7.4 is now available for download from the main site.    This version has an exciting new feature that lets you &#8220;layer&#8221; charts to build composite images like the one above.


Use SEND TO TEMPORARY to save a chart image to a temporary buffer, and use PAGEBITMAP TEMPORARY to use the buffer [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/combine.png" alt="combine" /></p>
<p>
<p>
Entrance Version 1.7.4 is now available for download from the <a href="http://dbentrance.com/">main site</a>.    This version has an exciting new feature that lets you &#8220;layer&#8221; charts to build composite images like the one above.</p>
<p>
<p>
Use SEND TO TEMPORARY to save a chart image to a temporary buffer, and use PAGEBITMAP TEMPORARY to use the buffer as a background image.  The complete script for the image above is <a href="http://dbentrance.com/demo/earthquake_counts.sql">here</a>.  In outline form, it looks like this: </p>
<pre>
  plot earthchart
      lat, lon
      with
        send to temporary
        ... more stuff ...

  plot rotatedbarchart
     axislabels, light red bar, datalabels right
    with
      pagebitmap temporary
      frame 105 275 220 425
      ... more stuff ...
</pre>
<p>
<p>
FRAME takes pixel coordinates.  (0,0) corresponds to the upper left hand corner of the chart page.</p>
<p>
Multiple charts can be chained in the same way.  Here is an example where six charts are drawn on a single image as a 2&#215;3 matrix.  Image size is determined by the first chart, which in this case is set to be 1000 by 500 pixels using the PAGE keyword:
<p>
<img src="http://dbentrance.com/blog_images/matrix.png" alt="matrix" /></p>
<p><pre>
plot
  red line
  page  0 0 1000 500
  frame 50 50 150 150
  send to temporary
  title "January CPI"
select
  jan
  from cpi;

plot
  red line
  page  0 0 1000 500
  frame 200 50 300 150
  pagebitmap temporary
  send to temporary
  title "February CPI"
select
  feb
  from cpi;

plot
  red line
  page  0 0 1000 500
  frame 350 50 450 150
  pagebitmap temporary
  send to temporary
  title "March CPI"
select
  mar
  from cpi;

plot
  red line
  frame 50 200 150 300
  pagebitmap temporary
  send to temporary
  title "April CPI"
select
  apr
  from cpi;

plot
  red line
  page  0 0 1000 500
  frame 200 200 300 300
  pagebitmap temporary
  send to temporary
  title "May CPI"
select
  may
  from cpi;

plot
  red line
  page  0 0 1000 500
  frame 350 200 450 300
  pagebitmap temporary
  title "June CPI"
select
  june
  from cpi;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=356</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>slide:ology Color Palettes</title>
		<link>http://dbentrance.com/blog/?p=332</link>
		<comments>http://dbentrance.com/blog/?p=332#comments</comments>
		<pubDate>Sat, 17 Apr 2010 16:47:40 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=332</guid>
		<description><![CDATA[
In this note I&#8217;ll show how to use the color palettes in &#8220;slide:ology&#8221; by Nancy Duarte (those of us who spoke at the MySQl Conference received it as a nice gift from O&#8217;Reilly).
Step 1 is to download Entrance Community edition from our web site: http://dbentrance.com/. You need JRE 1.6 or better and access to a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/earthy.png" alt="earthy" /><br />
In this note I&#8217;ll show how to use the color palettes in &#8220;slide:ology&#8221; by Nancy Duarte (those of us who spoke at the MySQl Conference received it as a nice gift from O&#8217;Reilly).</p>
<p>Step 1 is to download Entrance Community edition from our web site: http://dbentrance.com/. You need JRE 1.6 or better and access to a MySQL server to run it. Simply unzip the download and start the program with &#8220;java -jar entrance.jar&#8221;.</p>
<p>To make a chart, click &#8220;New&#8221; and enter a PLOT command:</p>
<pre>
   plot
       axislabels, red bar, blue bar, green bar
   select "label", 1, 2, 3;
</pre>
<p>The SELECT part of the command can be almost any MySQL SELECT statement. (e.g. unfortunately you can&#8217;t change delimiters yet).</p>
<p>Click &#8220;Run&#8221; and you have the chart. Now to replace those eye-scorching colors with something better from the book. Take a look at the section &#8220;Using the Power of Color&#8221; on pages 130-131 and you will find a collection of RGB values for color palettes. Any of these can be used in Entrance. For example, here is &#8220;Earthy&#8221;:</p>
<pre>
   -- Earthy palette from slide:ology
   plot
      axislabels, rgb(72,107,28) bar, rgb(101,141,43) bar,
            rgb(144,193,62) bar
   select "label", 1, 2, 3;
</pre>
<p>Once you have entered a palette you can copy and paste it as text to other scripts. Be careful not to put any spaces in the rgb() values or Entrance will complain, and be careful that the chart series you list in the &#8220;plot part&#8221; match up 1-to-1 with columns in the &#8220;select part&#8221;.</p>
<p>Now you can do things like adding titles, legends, gridlines and so on using the syntax described here: <a href="http://dbentrance.com/newdocs/plotsyntax.html">http://dbentrance.com/newdocs/plotsyntax.html</a>. You can also search this blog for examples, eg. try &#8220;bar chart&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=332</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make iPhone&#174; Charts Using the Entrance API</title>
		<link>http://dbentrance.com/blog/?p=191</link>
		<comments>http://dbentrance.com/blog/?p=191#comments</comments>
		<pubDate>Fri, 29 Jan 2010 00:45:57 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=191</guid>
		<description><![CDATA[

This is an Entrance chart on an iPhone.  It was generated by a Groovy script using the Entrance Java API to plot data from a RAWS weather station.  

The script takes advantage of certain Apple iPhone CSS extensions and Joe Hewitt&#8217;s iUI framework to make the page behave a lot like like a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/iphone14.png" alt="iphone7" /></p>
<p>
This is an Entrance chart on an iPhone.  It was generated by a <a href="http://dbentrance.com/demo/bndc1.txt">Groovy script</a> using the Entrance Java API to plot data from a RAWS weather station.  </p>
<p>
The script takes advantage of certain <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html">Apple iPhone CSS extensions</a> and Joe Hewitt&#8217;s <a href="http://code.google.com/p/iui/">iUI framework</a> to make the page behave a lot like like a native iPhone application.   If you have an iPhone, you can see the result here <a href="http://dbentrance.com/i3/">here</a></p>
<p>
<strong>Groovy and the Entrance API</strong><br />
<a href="http://groovy.codehaus.org/">Groovy</a> is a scripting language for the Java platform.  To use the Entrance Java API from Groovy scripts drop two jars,  &#8216;entrance.jar&#8217; and &#8216;cotta.jar&#8217;,  into the Groovy &#8216;lib&#8217; directory.   If you are running Groovy from the command line, put them in:<br />
 <code><br />
&nbsp; &nbsp; (your home dir)/.groovy/lib<br />
</code><br />
To use the Entrance API with the Groovy servlet, put them in:<br />
<code><br />
&nbsp; &nbsp; (your webapps)/groovy/WEB-INF/lib<br />
</code></p>
<p>
Scripts you write using the Entrance desktop application can also be run  from the Entrance API using EntrancePlot.  These two methods take the path to an Entrance script file as an argument:<br />
<code><br />
    public static String generatePNG( Connection con,<br />
&nbsp; &nbsp;            String pngFile, String scriptFile,<br />
&nbsp; &nbsp;            boolean deleteIfExists)</p>
<p>    public static String generateTempPNG(Connection con,<br />
&nbsp; &nbsp;           String scriptFile)<br />
</code><br />
and this method takes the script itself as a String argument:</p>
<p><code><br />
   public static String generatePNG(Connection con,<br />
&nbsp; &nbsp;       String pngFile,<br />
&nbsp; &nbsp;       String script);<br />
</code></p>
<p>Here&#8217;s the usual pattern for drawing Entrance charts with Groovy:<br />
<code><br />
  import com.dbentrance.entrance.EntrancePlot<br />
  import groovy.sql.Sql</p>
<p>  sql = Sql.newInstance(<br />
&nbsp; &nbsp;      "jdbc:mysql://localhost/test", (user),<br />
&nbsp; &nbsp;      (password), "com.mysql.jdbc.Driver")</p>
<p>  script = """<br />
&nbsp; &nbsp;        ... <a href="http://dbentrance.com/newdocs/plotscript.html">a PLOT script</a> ...<br />
   """</p>
<p>   EntrancePlot.generatePNG(sql.getConnection(),<br />
&nbsp; &nbsp;       "/usr/local/tomcat/webapps/groovy/bndc1_files/wind.png",<br />
&nbsp; &nbsp;      script);</p>
<p>   ... then refer to the PNG file in HTML output ...<br />
</code><br />
Note that this technique will work for any database with a JDBC driver.  The complete groovy script for the example above  is <a href="http://dbentrance.com/demo/bndc1.groovy">here</a>.</p>
<p><strong>Sizing the charts</strong><br />
Use PAGE and FRAME in an Entrance script to size charts for mobile devices like the iPhone:<br />
<code><br />
  PAGE  0 0 (width) (height)<br />
  FRAME (x0) (y0) (x1) (y1)<br />
</code><br />
Both take pixel coordinates.  In pixel coordinates the upper left hand corner of the display is (0,0),. Coordinates increase going down and to the right.</p>
<p>
Use PAGE to set the width and height of the output bitmap, and use FRAME to locate the chart on the page.<br />
The first two coordinates of FRAME specify the upper left hand corner of the chart.  The last two specify its lower right hand corner.  </p>
<p>
Once you have a PAGE and FRAME combination you like, you can copy and paste it into other scripts.  These sizes worked well to for fitting two charts at a time in iUI on an iPhone screen:<br />
<code><br />
&nbsp; &nbsp;    PAGE   0   0 275 150<br />
&nbsp; &nbsp;    FRAME 46 5 245 125<br />
</code><br />
To completely fill the iPhone display in landscape mode without iUI, you could use:<br />
<code><br />
&nbsp; &nbsp;    PAGE   0   0 320 356<br />
</code></p>
<p><strong><br />
Fonts</strong><br />
Generally, the default font sizes should work for both the screen and iPhone output.  If you find you need to tune font sizes, use FONT and TITLEFONT::<br />
<code><br />
    FONT (font family) (style) (size)<br />
    TITLEFONT (font family) (style) (size)<br />
</code><br />
Both take a font family, which can be one of the platform-independent names:  Serif, SansSerif, Monospaced, Dialog, and DialogInput, or another font family names supported by your platform.  &#8216;Style&#8217; can be PLAIN, BOLD, or ITALIC and the font &#8217;size&#8217; is set using point sizes.   Generally speaking a font size that is legible on the display screen will also be legible on the iPhone.  </p>
<p><strong>Black Backgrounds</strong><br />
Use BACKGROUND, FOREGROUND and GRIDLINES to change colors:<br />
<code><br />
&nbsp; &nbsp; BACKGROUND BLACK<br />
&nbsp; &nbsp; FOREGROUND GRAY<br />
&nbsp; &nbsp; GRIDLINES GRAY<br />
</code></p>
<p>
<strong>A Note About the iPad</strong><br />
You can also use Entrance API to generate charts for the iPad.  The iPad display is 1024 x 768 and 132 pixels per inch.  I haven&#8217;t tested it, but I think you will want to double Entrance font sizes that look good on the desktop display when sending them to iPad.  More to come on the iPad.</p>
<p>The latest version of Entrance can be downloaded from <a href="http://dbentrance.com/">the main page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=191</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Haiti Quake</title>
		<link>http://dbentrance.com/blog/?p=228</link>
		<comments>http://dbentrance.com/blog/?p=228#comments</comments>
		<pubDate>Thu, 14 Jan 2010 21:39:09 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=228</guid>
		<description><![CDATA[In an earlier post I showed how to import USGS earthquake data for the previous seven days into Entrance.  Do that today, and you will see the Mendocino and Haiti Quakes:



This script adds a  datetime column to the dataset::

ALTER TABLE earthquakes
&#160; &#160;  ADD COLUMN dt DATETIME;
UPDATE earthquakes
&#160;   SET dt =
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://dbentrance.com/blog/?p=47">an earlier post</a> I showed how to import USGS earthquake data for the previous seven days into <a href="http://dbentrane.com">Entrance</a>.  Do that today, and you will see the Mendocino and Haiti Quakes:
<p>
<a href="http://dbentrance.com/demo/earthquake7.sql"><img src="http://dbentrance.com/blog_images/haiti_quake.png" alt="haiti" /></a></p>
<p>
This script adds a  datetime column to the dataset::<br />
<code><br />
ALTER TABLE earthquakes<br />
&nbsp; &nbsp;  ADD COLUMN dt DATETIME;</p>
<p>UPDATE earthquakes<br />
&nbsp;   SET dt =<br />
&nbsp; &nbsp; STR_TO_DATE(datetime, "%W, %M %e, %Y %H:%i:%S UTC");<br />
</code><br />
and a Datetime-Y  chart shows the severity of the aftershocks:that followed the main Haiti quake:<br />
<a href="http://dbentrance.com/demo/aftershocks.sql"><img src="http://dbentrance.com/blog_images/aftershocks.png" alt="aft" /></a><br />
Click on the charts to see the scripts for making them.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=228</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Radar Charts</title>
		<link>http://dbentrance.com/blog/?p=132</link>
		<comments>http://dbentrance.com/blog/?p=132#comments</comments>
		<pubDate>Tue, 01 Dec 2009 20:44:42 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=132</guid>
		<description><![CDATA[

PLOT RADARCHART
&#160; &#160;&#160;   DIRECTION, RED TRIANGLE,
&#160;&#160;  &#160;  DIRECTION, BLUE VECTOR
&#160;&#160;  WITH
&#160;&#160;&#160;    NO LABELS Y
&#160;&#160;&#160;    FRAMECOLOR RGB(230,230,255)
&#160;&#160;&#160;    GRIDLINES
SELECT peak_wind_dir, peak_wind_speed, wind_dir,
&#160;&#160; wind_speed
&#160;&#160;&#160;  FROM raws_bl
&#160;&#160;&#160;  WHERE dt > DATE_SUB(NOW(), INTERVAL 24 hour);


Entrance IDE 1.5 is available for download now, with support [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dbentrance.com/blog_images/radar2.png" alt="radar2" /><br />
<code><br />
PLOT RADARCHART<br />
&nbsp; &nbsp;&nbsp;   DIRECTION, RED TRIANGLE,<br />
&nbsp;&nbsp;  &nbsp;  DIRECTION, BLUE VECTOR<br />
&nbsp;&nbsp;  WITH<br />
&nbsp;&nbsp;&nbsp;    NO LABELS Y<br />
&nbsp;&nbsp;&nbsp;    FRAMECOLOR RGB(230,230,255)<br />
&nbsp;&nbsp;&nbsp;    GRIDLINES<br />
SELECT peak_wind_dir, peak_wind_speed, wind_dir,<br />
&nbsp;&nbsp; wind_speed<br />
&nbsp;&nbsp;&nbsp;  FROM raws_bl<br />
&nbsp;&nbsp;&nbsp;  WHERE dt > DATE_SUB(NOW(), INTERVAL 24 hour);<br />
</code></p>
<p>
Entrance IDE 1.5 is available for download now, with support for drawing radar charts like the one above.  (Radar charts are not supported by the current community version)</p>
<p>
To plot data using a radar chart specify a DIRECTION column containing angles in degrees 0-360 and a data value column to use for plotting VECTOR, LINE, AREA or one of the marker types.      </p>
<p>
Radar charts use the settings for the y axis to determine distances from the center of the chart circle.  The y scale can be autoscaled or set manually using<br />
<code>SCALE Y (min) (max) (increment)<br />
</code>
<p>
Use the SCALE X to control the spacing between ticks and radial gridlines.  Use [NO] LABELS Y to determine whether to label the scaling circles and and use [NO] LABELS X  to determine whether to draw labels around the outer circle.. </p>
<p>
This example mixes an AREA type column with a LINE:</p>
<p>
<img src="http://dbentrance.com/blog_images/radar.png" alt="radar" /><br />
<code><br />
PLOT RADARCHART<br />
&nbsp; &nbsp;&nbsp;      DIRECTION, GREEN AREA<br />
&nbsp; &nbsp;&nbsp;      DIRECTION, BLUE LINE<br />
&nbsp; &nbsp;  WITH<br />
&nbsp; &nbsp;&nbsp;     NO LABELS Y<br />
&nbsp; &nbsp;&nbsp;    FRAMECOLOR rgb(230,230,255)<br />
 &nbsp; &nbsp;&nbsp;    GRIDLINES<br />
SELECT peak_wind_dir, peak_wind_speed, wind_dir,<br />
&nbsp; &nbsp; &nbsp; wind_speed<br />
&nbsp; &nbsp;&nbsp;    FROM raws_bl<br />
&nbsp; &nbsp;&nbsp;    WHERE dt > DATE_SUB(NOW(), INTERVAL 24 hour);<br />
</code><br />
COLOR and SIZE OVERRIDES, LEGENDs  and TITLES are supported, and RadarCharts support any of the line and marker types, TRIANGLE, BOX, and so on, as well as <a href="http://dbentrance.com/blog/?p=88">bubble effects</a>.</p>
<p>
Points in a radar chart can labelled using DATALABELs.  &nbsp;  (DATALABELs are drawn next to points specified by the previous DIRECTION, VECTOR series)  &nbsp; </p>
<p>
Use DATALABEL and VECTOR with radar charts to make gauges like these in a dashboard (click on a gauge to see the script that made it):</p>
<p>
<a href="http://dbentrance.com/demo/gauge1.sql"><img src="http://dbentrance.com/blog_images/gauge1.png" alt="gauge1" /></a><a href="http://dbentrance.com/demo/gauge5.sql"><img src="http://dbentrance.com/blog_images/gauge5.png" alt="gauge5" /></a><a href="http://dbentrance.com/demo/gauge4.sql"><img src="http://dbentrance.com/blog_images/gauge4.png" alt="gauge4" /></a><a href="http://dbentrance.com/demo/gauge3.sql"><img src="http://dbentrance.com/blog_images/gauge3.png" alt="gauge3.png" /></a></p>
<p><p>
Some details:  <br />
In a radar chart, DIRECTION 0 is always straight up, and increases clockwise:  e.g. 90 degrees is to the right, 270 degrees is to the left, and so on.  To make different scales like the meters you see above, you&#8217;ll need to cheat:  use NO LABELS X to turn off the auotmatic labels and make your own using a DATALABEL column. </p>
<p>
<strong>See also:</strong>  Entrance IDE 1.5 also supports DatetimeDirCharts, which plot direction changes on a datetime axis:  see  <a href="http://dbentrance.com/blog/?p=6">&#8220;Plotting Wind Direction and Speed&#8221;</a> for the details.  </p>
<p>
Entrance home page:  <a href="http://dbentrance.com/">http://dbentrance.com/</a><br />
Plot syntax:  <a href="http://dbentrance.com/">http://dbentrance.com/newdocs/plotsyntax.html</a></p>
<p>Copyright (c) 2009 dbEntranceSoftware, All Rights Reserved</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=132</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pareto Charts</title>
		<link>http://dbentrance.com/blog/?p=101</link>
		<comments>http://dbentrance.com/blog/?p=101#comments</comments>
		<pubDate>Thu, 05 Nov 2009 00:04:09 +0000</pubDate>
		<dc:creator>tod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dbentrance.com/blog/?p=101</guid>
		<description><![CDATA[
I&#8217;ve been reading Stephen Few&#8217;s excellent book, &#8220;Now You See It&#8221;.  Its a big book (300+) pages, packed with practical examples, and one that I think any Entrance user will find useful.  The Pareto Chart above is loosely based on one of his examples (p. 196).   
In a Pareto Chart, bars [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://dbentrance.com/demo/pareto.sql"><img alt="" src="http://dbentrance.com/blog_images/pareto.png" title="pareto" class="alignnone" /></a></p>
<p>I&#8217;ve been reading Stephen Few&#8217;s excellent book, &#8220;Now You See It&#8221;.  Its a big book (300+) pages, packed with practical examples, and one that I think any Entrance user will find useful.  The Pareto Chart above is loosely based on one of his examples (p. 196).   </p>
<p>In a Pareto Chart, bars are drawn with a line showing accumulated sums.  The bars are ordered for decreasing height, so the changes in the sums decrease as well.  This makes it possible to read off the largest contributors to the total.  In our example, you can see that the first three categories account for 88.9% of total sales.  </p>
<p>One way to accumulate sums is to use a MySQL variable, like this:<br />
<code><br />
&nbsp; &nbsp; SET @sum=0;<br />
&nbsp; &nbsp; SELECT @sum := @sum+sales FROM t;<br />
</code><br />
To re-express values in a table column as percentages, use a pattern like this:<br />
<code><br />
&nbsp; &nbsp; SET @total = (SELECT SUM(sales) FROM t);<br />
&nbsp; &nbsp; SELECT (sales / @total) * 100 FROM t;<br />
</code><br />
Putting the pieces together, adding PLOT, and filling in a few details we have the Pareto Chart shown above:<br />
<code><br />
&nbsp; &nbsp; -- DROP TABLE IF EXISTS t;<br />
&nbsp; &nbsp; -- DROP TABLE IF EXISTS t2;</p>
<p>-- the sample data<br />
&nbsp; &nbsp; CREATE TABLE t (what varchar(255), sales double);<br />
&nbsp; &nbsp; INSERT INTO t VALUES<br />
&nbsp; &nbsp; &nbsp;   ('bagels', 20), ('donuts', 10), ('coffee', 80), ('prune danish', '40'),<br />
&nbsp; &nbsp; &nbsp;    ('scones', 2.5), ('toast', 5);</p>
<p>-- accumulate totals<br />
&nbsp; &nbsp; SET @sum = 0.0;<br />
&nbsp; &nbsp; CREATE TABLE t2<br />
&nbsp; &nbsp; SELECT what, sales, @sum := sales+@sum AS accum<br />
&nbsp; &nbsp; &nbsp;   FROM t<br />
&nbsp; &nbsp; &nbsp;   ORDER BY  sales DESC<br />
&nbsp; &nbsp; &nbsp; ;</p>
<p>-- calculate percentages<br />
&nbsp; &nbsp; SET @total = (SELECT SUM(sales) FROM t2);<br />
&nbsp; &nbsp; ALTER TABLE t2 ADD COLUMN accum_pct DOUBLE AFTER accum;<br />
&nbsp; &nbsp; ALTER TABLE t2 ADD COLUMN sales_pct DOULBE AFTER accum;<br />
&nbsp; &nbsp; UPDATE t2<br />
&nbsp; &nbsp; &nbsp;   SETt accum_pct = (accum/@total) * 100.0,<br />
&nbsp; &nbsp; &nbsp;   sales_pct =     (sales/@total) * 100.0;</p>
<p>-- make the plot<br />
&nbsp; &nbsp; PLOT<br />
&nbsp; &nbsp; &nbsp;      AXISLABELS, LIGHT GRAY BAR,<br />
&nbsp; &nbsp; &nbsp;      RED LINE, BLACK FILLED CIRCLE, DATALABELS<br />
&nbsp; &nbsp;    WITH<br />
&nbsp; &nbsp; &nbsp;      SCALE Y 0 100 25<br />
 &nbsp; &nbsp; &nbsp;     FORMAT Y DECIMAL "#'%'"<br />
  &nbsp; &nbsp; &nbsp;    NO SIDES<br />
&nbsp; &nbsp; &nbsp;      TITLE " "<br />
&nbsp; &nbsp; &nbsp;      TITLE Y "Percentage of Sales"<br />
&nbsp; &nbsp; &nbsp;      TITLE X "Item"<br />
&nbsp; &nbsp; SELECT<br />
&nbsp; &nbsp; &nbsp;     what,   sales_pct,<br />
&nbsp; &nbsp; &nbsp;     accum_pct, accum_pct, CONCAT(FORMAT(accum_pct, 1), '%    ')<br />
&nbsp; &nbsp; &nbsp;  FROM t2<br />
&nbsp; &nbsp; &nbsp;   ORDER BY sales DESC<br />
&nbsp; &nbsp; &nbsp; ;<br />
</code></p>
<p>
<strong>Note</strong>:  You have to be careful about updating user defined variables in this way, as discussed in &#8220;High Performance SQL&#8221; by Schartz et al. and on <a href="http://rpbouman.blogspot.com/2009/09/mysql-another-ranking-trick.html">Roland Bouman&#8217;s blog</a>.   This script works because we haven&#8217;t made assumptions about the evaluation order of the columns.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbentrance.com/blog/?feed=rss2&amp;p=101</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
