title: Convert array output from Tiny_TDS to Dashing.io Graph format
body: <p>I'm pretty new at Ruby and Dashing, but I've been able to muddle through so far up until this point.</p>
  
  <p>I am trying to get data from a MS SQL server using Tiny_TDS and into a format that Dashing can handle for it's Graph widget.</p>
  
  <p>I have been working on a basic ruby script to get the output correct before attempting to input into Dashing.</p>
  
  <pre><code>#!/usr/bin/ruby
  
  require 'tiny_tds'
  
  data = Array.new
  
  client = TinyTds::Client.new(:username =&gt; 'MYUN', :password =&gt; 'MYPW', :host =&gt; '192.168.X.X', :database =&gt; 'SQL2012', :port =&gt; '1433')
  
  rs = client.execute("SELECT Date, KPI_UserCount AS UserCountCurrent FROM     [SQL2012].[dbo].[DashTbl]")
  
  results = rs.each(:symbolize_keys =&gt; true, :as =&gt; :array, :cache_rows =&gt; true, :empty_sets =&gt; true) do |rowset| end
  
  for j in (0...rs.affected_rows)
    for i in (0...rs.fields.length)
      #data.push('"x" =&gt; ' + results[j].at(i).to_s, '"y" =&gt; ' + results[j].at(i).to_s)
    end
  end
  
  printf("%5s",results)
  
   #data = [ { "x" =&gt; 1980, "y" =&gt; 1323 }, { "x" =&gt; 1981, "y" =&gt; 53234 }, { "x" =&gt; 1982, "y" =&gt; 2344 } ]
   # this is what the output is supposed to look like
  
  client.close
  </code></pre>
  
  <p>Currently my output looks like this:</p>
  
  <pre><code>[[2015-08-22 20:00:00 -0600, 4913], [2015-08-23 20:00:00 -0600, 4915], [2015-08-24 20:00:00 -0600, 4918]]'
  </code></pre>
  
  <p>I have been experimenting with adding the required formatting into the data array with the for loops, to no avail.</p>
  
  <p>Can someone please point me in the right direction?</p>
  
  <p>UPDATE 1: Thanks to the help of engineersmnky, the hash seems to be created correctly.</p>
  
  <p>My updated portion of the script is this:</p>
  
  <pre><code>for j in (0...rs.affected_rows)
    for i in (0...rs.fields.length)
    end
    data &lt;&lt; {"x" =&gt; results[j].at(0).to_s, "y" =&gt; results[j].at(1).to_i}
  end
  </code></pre>
  
  <p>Now the issue is that Dashing just seems to show the last number of the y axis as the displayed number and doesn't seem to show any graphed points.</p>
  
  <p>UPDATE 2:</p>
  
  <p>This has been resolved. I ended up needing to recreate the array each time the job was run so that the historical data was pulled from SQL.</p>
  
  <pre><code>rs = client.execute("SELECT Date, KPI_UserCount AS UserCountCurrent FROM [TSQL2012].[dbo].[DashTbl]")
  results = rs.each(:symbolize_keys =&gt; true, :as =&gt; :array, :cache_rows =&gt; true, :empty_sets =&gt; true) do |rowset| end
  data_count = Array.new 
  for j in (0...rs.affected_rows)
    for i in (0...rs.fields.length)
    end
  data_count &lt;&lt; {"x" =&gt; results[j].at(0).to_time.to_i, "y" =&gt; results[j].at(1).to_i}
  end
  send_event('usergraph',points: data_count)
  </code></pre>
  
  <p>The Dashing code looked like this:</p>
  
  <pre><code>&lt;li data-row="1" data-col="1" data-sizex="2" data-sizey="1"&gt;
    &lt;div data-id="usergraph" data-view="Rickshawgraph" data-title="User Count Today" style="background-color:#336699" data-renderer="area" data-min="3000" data-max="6500"&gt;&lt;/div&gt;
  &lt;/li&gt;
  </code></pre>