{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "true" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "require 'google_visualr'" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/javascript": [ "\n", "\n", " /* BEGIN GoogleVisualr.js */\n", "if(!window['googleLT_']){window['googleLT_']=(new Date()).getTime();}if (!window['google']) {\n", "window['google'] = {};\n", "}\n", "if (!window['google']['loader']) {\n", "window['google']['loader'] = {};\n", "google.loader.ServiceBase = 'https://www.google.com/uds';\n", "google.loader.GoogleApisBase = 'https://ajax.googleapis.com/ajax';\n", "google.loader.ApiKey = 'notsupplied';\n", "google.loader.KeyVerified = true;\n", "google.loader.LoadFailure = false;\n", "google.loader.Secure = true;\n", "google.loader.GoogleLocale = 'www.google.com';\n", "google.loader.ClientLocation = null;\n", "google.loader.AdditionalParams = '';\n", "(function() {function g(a){return a in l?l[a]:l[a]=-1!=navigator.userAgent.toLowerCase().indexOf(a)}var l={};function m(a,b){var c=function(){};c.prototype=b.prototype;a.ca=b.prototype;a.prototype=new c}function n(a,b,c){var d=Array.prototype.slice.call(arguments,2)||[];return function(){return a.apply(b,d.concat(Array.prototype.slice.call(arguments)))}}function p(a){a=Error(a);a.toString=function(){return this.message};return a}\n", "function q(a,b){a=a.split(/\\./);for(var c=window,d=0;d\\x3c/script>\"):(g(\"safari\")||g(\"konqueror\"))&&window.setTimeout(B,10)),x.push(a)):y(window,\"load\",a)};t(\"google.setOnLoadCallback\",google.ba);\n", "function y(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent(\"on\"+b,c);else{var d=a[\"on\"+b];a[\"on\"+b]=null!=d?C([c,d]):c}}function C(a){return function(){for(var b=0;b\\x3c/script>'):\"css\"==a&&document.write('')};\n", "t(\"google.loader.writeLoadTag\",google.loader.f);google.loader.Z=function(a){w=a};t(\"google.loader.rfm\",google.loader.Z);google.loader.aa=function(a){for(var b in a)\"string\"==typeof b&&b&&\":\"==b.charAt(0)&&!v[b]&&(v[b]=new E(b.substring(1),a[b]))};t(\"google.loader.rpl\",google.loader.aa);google.loader.$=function(a){if((a=a.specs)&&a.length)for(var b=0;b\\x3c/script>')},K.Hi=function(b){var c=K.global.document,d=c.createElement(\"script\");d.type=C;d.src=b;d.defer=!1;d.async=!1;c.head.appendChild(d)},\n", "K.Ql=function(b,c){if(K.og()){var d=K.global.document;if(!K.Fe&&d.readyState==t){if(/\\bdeps.js$/.test(b))return!1;throw Error('Cannot write \"'+b+'\" after document load');}void 0===c?K.$h?(K.Zg=!0,c=\" onreadystatechange='goog.onScriptLoad_(this, \"+ ++K.Ng+\")' \",d.write(n+b+'\"'+c+\">\\x3c/script>\")):K.Fe?K.Hi(b):K.Pl(b):d.write('\\n\"" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "timeline.show_in_html" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "timeline.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :title=>\"Company Performance\", :legend=>\"bottom\"}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Year')\n", " data_table.new_column('number', 'Sales')\n", " data_table.new_column('number', 'Expenses')\n", " data_table.add_rows(4)\n", " data_table.set_cell(0, 0, '2004')\n", " data_table.set_cell(0, 1, 1000)\n", " data_table.set_cell(0, 2, 400)\n", " data_table.set_cell(1, 0, '2005')\n", " data_table.set_cell(1, 1, 1170)\n", " data_table.set_cell(1, 2, 460)\n", " data_table.set_cell(2, 0, '2006')\n", " data_table.set_cell(2, 1, 860)\n", " data_table.set_cell(2, 2, 580)\n", " data_table.set_cell(3, 0, '2007')\n", " data_table.set_cell(3, 1, 1030)\n", " data_table.set_cell(3, 2, 540)\n", "\n", " opts = { :width => 400, :height => 240, :title => 'Company Performance', :legend => 'bottom' }" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Year\"}, {:type=>\"number\", :label=>\"Sales\"}, {:type=>\"number\", :label=>\"Expenses\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"title\"=>\"Company Performance\", \"legend\"=>\"bottom\"}>" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "line_chart = GoogleVisualr::Interactive::LineChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "line_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:displayAnnotations=>true}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('date', 'Date')\n", " data_table.new_column('number', 'Kepler-22b mission')\n", " data_table.new_column('string', 'Kepler title')\n", " data_table.new_column('string', 'Kepler text')\n", " data_table.new_column('number', 'Gliese 163 mission')\n", " data_table.new_column('string', 'Gliese title')\n", " data_table.new_column('string', 'Gliese text')\n", " data_table.add_rows(\n", " [\n", " [Date.parse(\"2314-2-15\"), 12400, nil, nil, 10645, nil, nil],\n", " [Date.parse(\"2314-2-16\"), 24045, 'Lalibertines', 'First encounter', 12374, nil, nil],\n", " [Date.parse(\"2314-2-17\"), 35022, 'Lalibertines', 'They are very tall', 15766, 'Gallantors', 'First Encounter'],\n", " [Date.parse(\"2314-2-18\"), 12284, 'Lalibertines', 'Attack on our crew!', 34334, 'Gallantors', 'Statement of shared principles'],\n", " [Date.parse(\"2314-2-19\"), 8476, 'Lalibertines', 'Heavy casualties', 66467, 'Gallantors', 'Mysteries revealed'],\n", " [Date.parse(\"2314-2-20\"), 0, 'Lalibertines', 'All crew lost', 79463, 'Gallantors', 'Omniscience achieved']\n", " ]\n", " )\n", "\n", " opts = { :displayAnnotations => true }" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"date\", :label=>\"Date\"}, {:type=>\"number\", :label=>\"Kepler-22b mission\"}, {:type=>\"string\", :label=>\"Kepler title\"}, {:type=>\"string\", :label=>\"Kepler text\"}, {:type=>\"number\", :label=>\"Gliese 163 mission\"}, {:type=>\"string\", :label=>\"Gliese title\"}, {:type=>\"string\", :label=>\"Gliese text\"}], @rows=[[#, @type=\"date\">, #, #, #, #, #, #], [#, @type=\"date\">, #, #, #, #, #, #], [#, @type=\"date\">, #, #, #, #, #, #], [#, @type=\"date\">, #, #, #, #, #, #], [#, @type=\"date\">, #, #, #, #, #, #], [#, @type=\"date\">, #, #, #, #, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"displayAnnotations\"=>true}>" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Annotation_chart = GoogleVisualr::Interactive::AnnotationChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Annotation_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[[\"2004\", 1000, 400], [\"2005\", 1170, 460], [\"2006\", 660, 1120], [\"2007\", 1030, 540]]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Year')\n", " data_table.new_column('number', 'Sales')\n", " data_table.new_column('number', 'Expenses')\n", " data_table.add_rows(\n", " [\n", " ['2004', 1000, 400],\n", " ['2005', 1170, 460],\n", " ['2006', 660, 1120],\n", " ['2007', 1030, 540]\n", " ]\n", " )" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :title=>\"Company Performance\", :hAxis=>{:title=>\"Year\", :titleTextStyle=>{:color=>\"#FF0000\"}}}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "opts = { width: 400, height: 240, title: 'Company Performance', hAxis: { title: 'Year', titleTextStyle: { color: '#FF0000' } } }" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Year\"}, {:type=>\"number\", :label=>\"Sales\"}, {:type=>\"number\", :label=>\"Expenses\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"title\"=>\"Company Performance\", \"hAxis\"=>{:title=>\"Year\", :titleTextStyle=>{:color=>\"#FF0000\"}}}>" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Area_chart = GoogleVisualr::Interactive::AreaChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Area_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :title=>\"Company Performance\", :vAxis=>{:title=>\"Year\", :titleTextStyle=>{:color=>\"red\"}}}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Year')\n", " data_table.new_column('number', 'Sales')\n", " data_table.new_column('number', 'Expenses')\n", " data_table.add_rows(4)\n", " data_table.set_cell(0, 0, '2004')\n", " data_table.set_cell(0, 1, 1000)\n", " data_table.set_cell(0, 2, 400)\n", " data_table.set_cell(1, 0, '2005')\n", " data_table.set_cell(1, 1, 1170)\n", " data_table.set_cell(1, 2, 460)\n", " data_table.set_cell(2, 0, '2006')\n", " data_table.set_cell(2, 1, 660)\n", " data_table.set_cell(2, 2, 1120)\n", " data_table.set_cell(3, 0, '2007')\n", " data_table.set_cell(3, 1, 1030)\n", " data_table.set_cell(3, 2, 540)\n", "\n", " opts = { :width => 400, :height => 240, :title => 'Company Performance', vAxis: { title: 'Year', titleTextStyle: { color: 'red' } } }\n", " " ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Year\"}, {:type=>\"number\", :label=>\"Sales\"}, {:type=>\"number\", :label=>\"Expenses\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"title\"=>\"Company Performance\", \"vAxis\"=>{:title=>\"Year\", :titleTextStyle=>{:color=>\"red\"}}}>" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bar_chart = GoogleVisualr::Interactive::BarChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bar_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>800, :height=>500, :title=>\"Correlation between life expectancy, fertility rate and population of some world countries (2010)\", :hAxis=>{:title=>\"Life Expectancy\"}, :vAxis=>{:title=>\"Fertility Rate\"}, :bubble=>{:textStyle=>{:fontSize=>11}}}" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'ID')\n", " data_table.new_column('number', 'Life Expectancy')\n", " data_table.new_column('number', 'Fertility Rate')\n", " data_table.new_column('string', 'Region')\n", " data_table.new_column('number', 'Population')\n", " data_table.add_rows(\n", " [\n", " ['CAN', 80.66, 1.67, 'North America', 33739900],\n", " ['DEU', 79.84, 1.36, 'Europe', 81902307],\n", " ['DNK', 78.6, 1.84, 'Europe', 5523095],\n", " ['EGY', 72.73, 2.78, 'Middle East', 79716203],\n", " ['GBR', 80.05, 2, 'Europe', 61801570],\n", " ['IRN', 72.49, 1.7, 'Middle East', 73137148],\n", " ['IRQ', 68.09, 4.77, 'Middle East', 31090763],\n", " ['ISR', 81.55, 2.96, 'Middle East', 7485600],\n", " ['RUS', 68.6, 1.54, 'Europe', 141850000],\n", " ['USA', 78.09, 2.05, 'North America', 307007000]\n", " ]\n", " )\n", "\n", " opts = {\n", " :width => 800, :height => 500,\n", " :title => 'Correlation between life expectancy, fertility rate and population of some world countries (2010)',\n", " :hAxis => { :title => 'Life Expectancy' },\n", " :vAxis => { :title => 'Fertility Rate' },\n", " :bubble => { :textStyle => { :fontSize => 11 } }\n", " }" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"ID\"}, {:type=>\"number\", :label=>\"Life Expectancy\"}, {:type=>\"number\", :label=>\"Fertility Rate\"}, {:type=>\"string\", :label=>\"Region\"}, {:type=>\"number\", :label=>\"Population\"}], @rows=[[#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>800, \"height\"=>500, \"title\"=>\"Correlation between life expectancy, fertility rate and population of some world countries (2010)\", \"hAxis\"=>{:title=>\"Life Expectancy\"}, \"vAxis\"=>{:title=>\"Fertility Rate\"}, \"bubble\"=>{:textStyle=>{:fontSize=>11}}}>" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bubble_chart = GoogleVisualr::Interactive::BubbleChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bubble_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[[#, 37032], [#, 38024], [#, 38024], [#, 38108], [#, 38229], [#, 38177], [#, 38705], [#, 38210], [#, 38029], [#, 38823], [#, 38345], [#, 38436], [#, 38447]]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('date' , 'Date')\n", " data_table.new_column('number', 'Won/Loss')\n", " data_table.add_rows(\n", " [\n", " [Date.parse(\"2012-3-13\"), 37032],\n", " [Date.parse(\"2012-3-14\"), 38024],\n", " [Date.parse(\"2012-3-15\"), 38024],\n", " [Date.parse(\"2012-3-16\"), 38108],\n", " [Date.parse(\"2012-3-17\"), 38229],\n", " [Date.parse(\"2013-9-4\") , 38177],\n", " [Date.parse(\"2013-9-5\") , 38705],\n", " [Date.parse(\"2013-9-12\"), 38210],\n", " [Date.parse(\"2013-9-13\"), 38029],\n", " [Date.parse(\"2013-9-19\"), 38823],\n", " [Date.parse(\"2013-9-23\"), 38345],\n", " [Date.parse(\"2013-9-24\"), 38436],\n", " [Date.parse(\"2013-9-30\"), 38447]\n", " ]\n", " )\n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:title=>\"Red Sox Attendance\", :width=>800, :height=>300, :calendar=>{:cellSize=>13.5}}" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "opts = { :title => \"Red Sox Attendance\", :width => 800, :height => 300, calendar: { cellSize: 13.5 } }\n", " " ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"date\", :label=>\"Date\"}, {:type=>\"number\", :label=>\"Won/Loss\"}], @rows=[[#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #], [#, @type=\"date\">, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"title\"=>\"Red Sox Attendance\", \"width\"=>800, \"height\"=>300, \"calendar\"=>{:cellSize=>13.5}}>" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "calender = GoogleVisualr::Interactive::Calendar.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "calender.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :legend=>\"none\"}" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'day')\n", " data_table.new_column('number', 'min')\n", " data_table.new_column('number', 'opening')\n", " data_table.new_column('number', 'closing')\n", " data_table.new_column('number', 'max')\n", " data_table.add_rows(\n", " [\n", " ['Mon',20,28,38,45],\n", " ['Tue',31,38,55,66],\n", " ['Wed',50,55,77,80],\n", " ['Thu',50,77,66,77],\n", " ['Fri',15,66,22,68]\n", " ]\n", " )\n", "\n", " opts = { :width => 400, :height => 240, :legend => 'none' }" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"day\"}, {:type=>\"number\", :label=>\"min\"}, {:type=>\"number\", :label=>\"opening\"}, {:type=>\"number\", :label=>\"closing\"}, {:type=>\"number\", :label=>\"max\"}], @rows=[[#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #], [#, #, #, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"legend\"=>\"none\"}>" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "candlestick_chart = GoogleVisualr::Interactive::CandlestickChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "candlestick_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :title=>\"Company Performance\", :hAxis=>{:title=>\"Year\", :titleTextStyle=>{:color=>\"red\"}}}" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Year')\n", " data_table.new_column('number', 'Sales')\n", " data_table.new_column('number', 'Expenses')\n", " data_table.add_rows(4)\n", " data_table.set_cell(0, 0, '2004')\n", " data_table.set_cell(0, 1, 1000)\n", " data_table.set_cell(0, 2, 400)\n", " data_table.set_cell(1, 0, '2005')\n", " data_table.set_cell(1, 1, 1170)\n", " data_table.set_cell(1, 2, 460)\n", " data_table.set_cell(2, 0, '2006')\n", " data_table.set_cell(2, 1, 660)\n", " data_table.set_cell(2, 2, 1120)\n", " data_table.set_cell(3, 0, '2007')\n", " data_table.set_cell(3, 1, 1030)\n", " data_table.set_cell(3, 2, 540)\n", "\n", " opts = { :width => 400, :height => 240, :title => 'Company Performance', :hAxis => { :title => 'Year', :titleTextStyle => { :color => 'red' } } }\n", " " ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Year\"}, {:type=>\"number\", :label=>\"Sales\"}, {:type=>\"number\", :label=>\"Expenses\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"title\"=>\"Company Performance\", \"hAxis\"=>{:title=>\"Year\", :titleTextStyle=>{:color=>\"red\"}}}>" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "col_chart = GoogleVisualr::Interactive::ColumnChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "col_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>700, :height=>400, :title=>\"Monthly Coffee Production by Country\", :vAxis=>{:title=>\"Cups\"}, :hAxis=>{:title=>\"Month\"}, :seriesType=>\"bars\", :series=>{\"5\"=>{:type=>\"line\"}}}" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'month' )\n", " data_table.new_column('number', 'Bolivia' )\n", " data_table.new_column('number', 'Ecuador' )\n", " data_table.new_column('number', 'Madagascar' )\n", " data_table.new_column('number', 'Papua Guinea')\n", " data_table.new_column('number', 'Rwanda' )\n", " data_table.new_column('number', 'Avarage' )\n", " data_table.add_rows(\n", " [\n", " ['2004/05', 165, 938 , 522, 998 , 450, 614.6],\n", " ['2005/06', 135, 1120 , 599, 1268 , 288, 682 ],\n", " ['2006/07', 157, 1167 , 587, 807 , 397, 623 ],\n", " ['2007/08', 139, 1110 , 615, 968 , 215, 609.4],\n", " ['2008/09', 136, 691 , 629, 1026 , 366, 569.6]\n", " ]\n", " )\n", "\n", " opts = { :width => 700, :height => 400, :title => 'Monthly Coffee Production by Country', :vAxis => { :title => 'Cups' }, :hAxis => { :title => 'Month' }, :seriesType => 'bars', :series => { '5' => { :type => 'line' } } }\n", " " ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"month\"}, {:type=>\"number\", :label=>\"Bolivia\"}, {:type=>\"number\", :label=>\"Ecuador\"}, {:type=>\"number\", :label=>\"Madagascar\"}, {:type=>\"number\", :label=>\"Papua Guinea\"}, {:type=>\"number\", :label=>\"Rwanda\"}, {:type=>\"number\", :label=>\"Avarage\"}], @rows=[[#, #, #, #, #, #, #], [#, #, #, #, #, #, #], [#, #, #, #, #, #, #], [#, #, #, #, #, #, #], [#, #, #, #, #, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>700, \"height\"=>400, \"title\"=>\"Monthly Coffee Production by Country\", \"vAxis\"=>{:title=>\"Cups\"}, \"hAxis\"=>{:title=>\"Month\"}, \"seriesType\"=>\"bars\", \"series\"=>{\"5\"=>{:type=>\"line\"}}}>" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "combo_chart = GoogleVisualr::Interactive::ComboChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "combo_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:version=>\"1.1\", :height=>275}" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def days_to_milli(days)\n", " days * 24 * 60 * 60 * 1000;\n", " end\n", "\n", " data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Task ID')\n", " data_table.new_column('string', 'Task Name')\n", " data_table.new_column('string', 'Resource')\n", " data_table.new_column('date' , 'Start Date')\n", " data_table.new_column('date' , 'End Date')\n", " data_table.new_column('number', 'Duration')\n", " data_table.new_column('number', 'Percent Complete')\n", " data_table.new_column('string', 'Dependencies')\n", " data_table.add_rows(\n", " [\n", " ['Research' , 'Find sources' , nil , Date.parse(\"2015-1-1\"), Date.parse(\"2015-1-5\") , nil , 100 , nil],\n", " ['Write' , 'Write paper' , 'write' , nil , Date.parse(\"2015-1-9\") , days_to_milli(3) , 25 , 'Research, Outline'],\n", " ['Cite' , 'Create bibliography' , 'write' , nil , Date.parse(\"2015-1-7\") , days_to_milli(1) , 20 , 'Research'],\n", " ['Complete' , 'Hand in paper' , 'complete', nil , Date.parse(\"2015-1-10\") , days_to_milli(1) , 0 , 'Cite, Write'],\n", " ['Outline' , 'Outline paper' , 'write' , nil , Date.parse(\"2015-1-6\") , days_to_milli(1) , 100 , 'Research']\n", " ]\n", " )\n", "\n", " opts = { version: \"1.1\", height: 275 }" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Task ID\"}, {:type=>\"string\", :label=>\"Task Name\"}, {:type=>\"string\", :label=>\"Resource\"}, {:type=>\"date\", :label=>\"Start Date\"}, {:type=>\"date\", :label=>\"End Date\"}, {:type=>\"number\", :label=>\"Duration\"}, {:type=>\"number\", :label=>\"Percent Complete\"}, {:type=>\"string\", :label=>\"Dependencies\"}], @rows=[[#, #, #, #, @type=\"date\">, #, @type=\"date\">, #, #, #], [#, #, #, #, #, @type=\"date\">, #, #, #], [#, #, #, #, #, @type=\"date\">, #, #, #], [#, #, #, #, #, @type=\"date\">, #, #, #], [#, #, #, #, #, @type=\"date\">, #, #, #]]>, @listeners=[], @version=\"1.1\", @language=nil, @material=false, @options={\"height\"=>275}>" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gantt_chart = GoogleVisualr::Interactive::GanttChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gantt_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>120, :redFrom=>90, :redTo=>100, :yellowFrom=>75, :yellowTo=>90, :minorTicks=>5}" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string' , 'Label')\n", " data_table.new_column('number' , 'Value')\n", " data_table.add_rows(3)\n", " data_table.set_cell(0, 0, 'Memory' )\n", " data_table.set_cell(0, 1, 80)\n", " data_table.set_cell(1, 0, 'CPU' )\n", " data_table.set_cell(1, 1, 55)\n", " data_table.set_cell(2, 0, 'Network')\n", " data_table.set_cell(2, 1, 68)\n", "\n", " opts = { :width => 400, :height => 120, :redFrom => 90, :redTo => 100, :yellowFrom => 75, :yellowTo => 90, :minorTicks => 5 }\n", " " ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Label\"}, {:type=>\"number\", :label=>\"Value\"}], @rows=[[#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>120, \"redFrom\"=>90, \"redTo\"=>100, \"yellowFrom\"=>75, \"yellowTo\"=>90, \"minorTicks\"=>5}>" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gauge = GoogleVisualr::Interactive::Gauge.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gauge.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>500, :height=>300}" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Country')\n", " data_table.new_column('number', 'Popularity')\n", " data_table.add_rows(6)\n", " data_table.set_cell(0, 0, 'Germany' )\n", " data_table.set_cell(0, 1, 200)\n", " data_table.set_cell(1, 0, 'United States')\n", " data_table.set_cell(1, 1, 300)\n", " data_table.set_cell(2, 0, 'Brazil' )\n", " data_table.set_cell(2, 1, 400)\n", " data_table.set_cell(3, 0, 'Canada' )\n", " data_table.set_cell(3, 1, 500)\n", " data_table.set_cell(4, 0, 'France' )\n", " data_table.set_cell(4, 1, 600)\n", " data_table.set_cell(5, 0, 'RU' )\n", " data_table.set_cell(5, 1, 700)\n", "\n", " opts = { :width => 500, :height => 300 }" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Country\"}, {:type=>\"number\", :label=>\"Popularity\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>500, \"height\"=>300}>" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "geo_chart = GoogleVisualr::Interactive::GeoChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "geo_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Country\"}, {:type=>\"number\", :label=>\"Popularity\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"dataMode\"=>\"regions\"}>" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Regions Example\n", " data_table_regions = GoogleVisualr::DataTable.new\n", " data_table_regions.new_column('string' , 'Country' )\n", " data_table_regions.new_column('number' , 'Popularity')\n", " data_table_regions.add_rows(6)\n", " data_table_regions.set_cell(0, 0, 'Germany' )\n", " data_table_regions.set_cell(0, 1, 200)\n", " data_table_regions.set_cell(1, 0, 'United States')\n", " data_table_regions.set_cell(1, 1, 300)\n", " data_table_regions.set_cell(2, 0, 'Brazil' )\n", " data_table_regions.set_cell(2, 1, 400)\n", " data_table_regions.set_cell(3, 0, 'Canada' )\n", " data_table_regions.set_cell(3, 1, 500)\n", " data_table_regions.set_cell(4, 0, 'France' )\n", " data_table_regions.set_cell(4, 1, 600)\n", " data_table_regions.set_cell(5, 0, 'RU' )\n", " data_table_regions.set_cell(5, 1, 700)\n", "\n", " opts = { :dataMode => 'regions' }\n", " chart_regions = GoogleVisualr::Interactive::GeoMap.new(data_table_regions, opts)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "chart_regions.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Country\"}, {:type=>\"number\", :label=>\"Popularity\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"dataMode\"=>\"markers\", \"region\"=>\"US\", \"colors\"=>[\"0xFF8747\", \"0xFFB581\", \"0xc06000\"]}>" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Markers Example\n", " data_table_markers = GoogleVisualr::DataTable.new\n", " data_table_markers.new_column('string' , 'Country' )\n", " data_table_markers.new_column('number' , 'Popularity')\n", " data_table_markers.add_rows(6)\n", " data_table_markers.set_cell(0, 0, 'New York' )\n", " data_table_markers.set_cell(0, 1, 200)\n", " data_table_markers.set_cell(1, 0, 'Boston' )\n", " data_table_markers.set_cell(1, 1, 300)\n", " data_table_markers.set_cell(2, 0, 'Miami' )\n", " data_table_markers.set_cell(2, 1, 400)\n", " data_table_markers.set_cell(3, 0, 'Chicago' )\n", " data_table_markers.set_cell(3, 1, 500)\n", " data_table_markers.set_cell(4, 0, 'Los Angeles' )\n", " data_table_markers.set_cell(4, 1, 600)\n", " data_table_markers.set_cell(5, 0, 'Houston' )\n", " data_table_markers.set_cell(5, 1, 700)\n", "\n", " opts = { :dataMode => 'markers', :region => 'US', :colors => ['0xFF8747', '0xFFB581', '0xc06000'] }\n", " chart_markers = GoogleVisualr::Interactive::GeoMap.new(data_table_markers, opts)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "chart_markers.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>700, :height=>400, :title=>\"Lengths of dinosaurs, in meters\", :legend=>{:position=>\"none\"}}" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string' , 'Dinosaur')\n", " data_table.new_column('number' , 'Length')\n", " data_table.add_rows(\n", " [\n", " ['Acrocanthosaurus (top-spined lizard)' , 12.2],\n", " ['Albertosaurus (Alberta lizard)' , 9.1],\n", " ['Allosaurus (other lizard)' , 12.2],\n", " ['Apatosaurus (deceptive lizard)' , 22.9],\n", " ['Archaeopteryx (ancient wing)' , 0.9],\n", " ['Argentinosaurus (Argentina lizard)' , 36.6],\n", " ['Baryonyx (heavy claws)' , 9.1],\n", " ['Brachiosaurus (arm lizard)' , 30.5],\n", " ['Ceratosaurus (horned lizard)' , 6.1],\n", " ['Coelophysis (hollow form)' , 2.7],\n", " ['Compsognathus (elegant jaw)' , 0.9],\n", " ['Deinonychus (terrible claw)' , 2.7],\n", " ['Diplodocus (double beam)' , 27.1],\n", " ['Dromicelomimus (emu mimic)' , 3.4],\n", " ['Gallimimus (fowl mimic)' , 5.5],\n", " ['Mamenchisaurus (Mamenchi lizard)' , 21.0],\n", " ['Megalosaurus (big lizard)' , 7.9],\n", " ['Microvenator (small hunter)' , 1.2],\n", " ['Ornithomimus (bird mimic)' , 4.6],\n", " ['Oviraptor (egg robber)' , 1.5],\n", " ['Plateosaurus (flat lizard)' , 7.9],\n", " ['Sauronithoides (narrow-clawed lizard)', 2.0],\n", " ['Seismosaurus (tremor lizard)' , 45.7],\n", " ['Spinosaurus (spiny lizard)' , 12.2],\n", " ['Supersaurus (super lizard)' , 30.5],\n", " ['Tyrannosaurus (tyrant lizard)' , 15.2],\n", " ['Ultrasaurus (ultra lizard)' , 30.5],\n", " ['Velociraptor (swift robber)' , 1.8]\n", " ]\n", " )\n", "\n", " opts = { :width => 700, :height => 400, :title => 'Lengths of dinosaurs, in meters', :legend => { position: 'none' } }\n", " " ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Dinosaur\"}, {:type=>\"number\", :label=>\"Length\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>700, \"height\"=>400, \"title\"=>\"Lengths of dinosaurs, in meters\", \"legend\"=>{:position=>\"none\"}}>" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hist_chart = GoogleVisualr::Interactive::Histogram.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hist_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{}" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', '', 'Country')\n", " data_table.new_column('number', 'Population (mil)', 'a')\n", " data_table.new_column('number', 'Area (km2)' , 'b')\n", " data_table.add_rows(5)\n", " data_table.set_cell(0, 0, 'CN')\n", " data_table.set_cell(0, 1, 1324)\n", " data_table.set_cell(0, 2, 9640821)\n", " data_table.set_cell(1, 0, 'IN')\n", " data_table.set_cell(1, 1, 1133)\n", " data_table.set_cell(1, 2, 3287263)\n", " data_table.set_cell(2, 0, 'US')\n", " data_table.set_cell(2, 1, 304 )\n", " data_table.set_cell(2, 2, 9629091)\n", " data_table.set_cell(3, 0, 'ID')\n", " data_table.set_cell(3, 1, 232 )\n", " data_table.set_cell(3, 2, 1904569)\n", " data_table.set_cell(4, 0, 'BR')\n", " data_table.set_cell(4, 1, 187 )\n", " data_table.set_cell(4, 2, 8514877)\n", "\n", " opts = {}" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"\", :id=>\"Country\"}, {:type=>\"number\", :label=>\"Population (mil)\", :id=>\"a\"}, {:type=>\"number\", :label=>\"Area (km2)\", :id=>\"b\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={}>" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "intensity_map = GoogleVisualr::Interactive::IntensityMap.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "intensity_map.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:showTip=>true}" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('number', 'Lat' )\n", " data_table.new_column('number', 'Lon' )\n", " data_table.new_column('string', 'Name')\n", " data_table.add_rows(4)\n", " data_table.set_cell(0, 0, 37.4232 )\n", " data_table.set_cell(0, 1, -122.0853 )\n", " data_table.set_cell(0, 2, 'Work' )\n", " data_table.set_cell(1, 0, 37.4289 )\n", " data_table.set_cell(1, 1, -122.1697 )\n", " data_table.set_cell(1, 2, 'University')\n", " data_table.set_cell(2, 0, 37.6153 )\n", " data_table.set_cell(2, 1, -122.3900 )\n", " data_table.set_cell(2, 2, 'Airport' )\n", " data_table.set_cell(3, 0, 37.4422 )\n", " data_table.set_cell(3, 1, -122.1731 )\n", " data_table.set_cell(3, 2, 'Shopping' )\n", "\n", " opts = { :showTip => true }" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"number\", :label=>\"Lat\"}, {:type=>\"number\", :label=>\"Lon\"}, {:type=>\"string\", :label=>\"Name\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"showTip\"=>true}>" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "map_chart = GoogleVisualr::Interactive::Map.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 57, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "map_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>600, :height=>300}" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Fruit' )\n", " data_table.new_column('date' , 'Date' )\n", " data_table.new_column('number', 'Sales' )\n", " data_table.new_column('number', 'Expenses')\n", " data_table.new_column('string', 'Location')\n", " data_table.add_rows(\n", " [\n", " ['Apples' ,Date.parse(\"1988-01-01\"),1000,300,'East'],\n", " ['Oranges',Date.parse(\"1988-01-01\"),1150,200,'West'],\n", " ['Bananas',Date.parse(\"1988-01-01\"),300 ,250,'West'],\n", " ['Apples' ,Date.parse(\"1989-07-01\"),1200,400,'East'],\n", " ['Oranges',Date.parse(\"1989-07-01\"),750 ,150,'West'],\n", " ['Bananas',Date.parse(\"1989-07-01\"),788 ,617,'West']\n", " ]\n", " )\n", "\n", " opts = { :width => 600, :height => 300 }" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Fruit\"}, {:type=>\"date\", :label=>\"Date\"}, {:type=>\"number\", :label=>\"Sales\"}, {:type=>\"number\", :label=>\"Expenses\"}, {:type=>\"string\", :label=>\"Location\"}], @rows=[[#, #, @type=\"date\">, #, #, #], [#, #, @type=\"date\">, #, #, #], [#, #, @type=\"date\">, #, #, #], [#, #, @type=\"date\">, #, #, #], [#, #, @type=\"date\">, #, #, #], [#, #, @type=\"date\">, #, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>600, \"height\"=>300}>" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "motion_chart = GoogleVisualr::Interactive::MotionChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "motion_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 61, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:allowHtml=>true}" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Name' )\n", " data_table.new_column('string', 'Manager')\n", " data_table.new_column('string', 'ToolTip')\n", " data_table.add_rows(\n", " [\n", " [ {:v => 'Mike', :f => 'Mike
President
' }, '' , 'The President' ],\n", " [ {:v => 'Jim' , :f => 'Jim
Vice President
'}, 'Mike', 'VP' ],\n", " [ 'Alice' , 'Mike', '' ],\n", " [ 'Bob' , 'Jim' , 'Bob Sponge' ],\n", " [ 'Carol' , 'Bob' , '' ]\n", " ]\n", " )\n", "\n", " opts = { :allowHtml => true }" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Name\"}, {:type=>\"string\", :label=>\"Manager\"}, {:type=>\"string\", :label=>\"ToolTip\"}], @rows=[[#President
\", @p=nil>, #, #], [#Vice President
\", @p=nil>, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"allowHtml\"=>true}>" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "org_chart = GoogleVisualr::Interactive::OrgChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "org_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :title=>\"My Daily Activities\", :is3D=>true}" ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Task')\n", " data_table.new_column('number', 'Hours per Day')\n", " data_table.add_rows(5)\n", " data_table.set_cell(0, 0, 'Work' )\n", " data_table.set_cell(0, 1, 11 )\n", " data_table.set_cell(1, 0, 'Eat' )\n", " data_table.set_cell(1, 1, 2 )\n", " data_table.set_cell(2, 0, 'Commute' )\n", " data_table.set_cell(2, 1, 2 )\n", " data_table.set_cell(3, 0, 'Watch TV' )\n", " data_table.set_cell(3, 1, 2 )\n", " data_table.set_cell(4, 0, 'Sleep' )\n", " data_table.set_cell(4, 1, 7 )\n", "\n", " opts = { :width => 400, :height => 240, :title => 'My Daily Activities', :is3D => true }" ] }, { "cell_type": "code", "execution_count": 65, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Task\"}, {:type=>\"number\", :label=>\"Hours per Day\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"title\"=>\"My Daily Activities\", \"is3D\"=>true}>" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart = GoogleVisualr::Interactive::PieChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 66, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>600}" ] }, "execution_count": 67, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'From')\n", " data_table.new_column('string', 'To')\n", " data_table.new_column('number', 'Weight')\n", " data_table.add_rows(\n", " [\n", " ['A', 'X', 5],\n", " ['A', 'Y', 7],\n", " ['A', 'Z', 6],\n", " ['B', 'X', 2],\n", " ['B', 'Y', 9],\n", " ['B', 'Z', 4]\n", " ]\n", " )\n", "\n", " opts = { width: 600 }" ] }, { "cell_type": "code", "execution_count": 68, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"From\"}, {:type=>\"string\", :label=>\"To\"}, {:type=>\"number\", :label=>\"Weight\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>600}>" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sanky_chart = GoogleVisualr::Interactive::Sankey.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 69, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 69, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sanky_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 70, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>400, :height=>240, :title=>\"Age vs. Weight comparison\", :hAxis=>{:title=>\"Age\", :minValue=>0, :maxValue=>15}, :vAxis=>{:title=>\"Weight\", :minValue=>0, :maxValue=>15}, :legend=>\"none\"}" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('number', 'Age')\n", " data_table.new_column('number', 'Weight')\n", " data_table.add_rows(6)\n", " data_table.set_cell( 0, 0, 8 )\n", " data_table.set_cell( 0, 1, 12 )\n", " data_table.set_cell( 1, 0, 4 )\n", " data_table.set_cell( 1, 1, 5.5)\n", " data_table.set_cell( 2, 0, 11 )\n", " data_table.set_cell( 2, 1, 14 )\n", " data_table.set_cell( 3, 0, 4 )\n", " data_table.set_cell( 3, 1, 4.5)\n", " data_table.set_cell( 4, 0, 3 )\n", " data_table.set_cell( 4, 1, 3.5)\n", " data_table.set_cell( 5, 0, 6.5)\n", " data_table.set_cell( 5, 1, 7 )\n", "\n", " opts = {\n", " :width => 400, :height => 240, :title => 'Age vs. Weight comparison',\n", " :hAxis => { :title => 'Age', :minValue => 0, :maxValue => 15 },\n", " :vAxis => { :title => 'Weight', :minValue => 0, :maxValue => 15 },\n", " :legend => 'none'\n", " }" ] }, { "cell_type": "code", "execution_count": 71, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"number\", :label=>\"Age\"}, {:type=>\"number\", :label=>\"Weight\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>400, \"height\"=>240, \"title\"=>\"Age vs. Weight comparison\", \"hAxis\"=>{:title=>\"Age\", :minValue=>0, :maxValue=>15}, \"vAxis\"=>{:title=>\"Weight\", :minValue=>0, :maxValue=>15}, \"legend\"=>\"none\"}>" ] }, "execution_count": 71, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scatter_chart = GoogleVisualr::Interactive::ScatterChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 72, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 72, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scatter_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>800, :height=>500, :title=>\"The decline of 'The 39 Steps'\", :vAxis=>{:title=>\"Accumulated Rating\"}, :isStacked=>true}" ] }, "execution_count": 73, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string' , 'Director (Year)')\n", " data_table.new_column('number' , 'Rotten Tomatoes')\n", " data_table.new_column('number' , 'IMDB')\n", " data_table.add_rows(\n", " [\n", " ['Alfred Hitchcock (1935)', 8.4, 7.9],\n", " ['Ralph Thomas (1959)', 6.9, 6.5],\n", " ['Don Sharp (1978)', 6.5, 6.4],\n", " ['James Hawes (2008)', 4.4, 6.2]\n", " ]\n", " )\n", "\n", " opts = { :width => 800, :height => 500, :title => \"The decline of 'The 39 Steps'\", :vAxis => { :title => 'Accumulated Rating' }, :isStacked => true }\n", " " ] }, { "cell_type": "code", "execution_count": 74, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Director (Year)\"}, {:type=>\"number\", :label=>\"Rotten Tomatoes\"}, {:type=>\"number\", :label=>\"IMDB\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>800, \"height\"=>500, \"title\"=>\"The decline of 'The 39 Steps'\", \"vAxis\"=>{:title=>\"Accumulated Rating\"}, \"isStacked\"=>true}>" ] }, "execution_count": 74, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stepped_area_chart = GoogleVisualr::Interactive::SteppedAreaChart.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 75, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stepped_area_chart.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 76, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>600, :showRowNumber=>true}" ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string' , 'Name')\n", " data_table.new_column('number' , 'Salary')\n", " data_table.new_column('boolean' , 'Full Time Employee')\n", " data_table.add_rows(4)\n", " data_table.set_cell(0, 0, 'Mike' )\n", " data_table.set_cell(0, 1, {:v => 10000, :f => '$10,000'})\n", " data_table.set_cell(0, 2, true )\n", " data_table.set_cell(1, 0, 'Jim' )\n", " data_table.set_cell(1, 1, {:v => 8000 , :f => '$8,000' })\n", " data_table.set_cell(1, 2, false )\n", " data_table.set_cell(2, 0, 'Alice' )\n", " data_table.set_cell(2, 1, {:v => 12500, :f => '$12,500'})\n", " data_table.set_cell(2, 2, true )\n", " data_table.set_cell(3, 0, 'Bob' )\n", " data_table.set_cell(3, 1, {:v => 7000 , :f => '$7,000' })\n", " data_table.set_cell(3, 2, true )\n", "\n", " opts = { :width => 600, :showRowNumber => true }" ] }, { "cell_type": "code", "execution_count": 77, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Name\"}, {:type=>\"number\", :label=>\"Salary\"}, {:type=>\"boolean\", :label=>\"Full Time Employee\"}], @rows=[[#, #, #], [#, #, #], [#, #, #], [#, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>600, \"showRowNumber\"=>true}>" ] }, "execution_count": 77, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table = GoogleVisualr::Interactive::Table.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 78, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 78, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 79, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>600, :height=>600, :minColor=>\"#f00\", :midColor=>\"#ddd\", :maxColor=>\"#0d0\", :headerHeight=>15, :fontColor=>\"black\", :showScale=>true}" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column('string', 'Region')\n", " data_table.new_column('string', 'Parent')\n", " data_table.new_column('number', 'Market trade volume (size)')\n", " data_table.new_column('number', 'Market increase/decrease (color)')\n", " data_table.add_rows(\n", " [\n", " [\"Global\" , nil , 0 , 0 ],\n", " [\"America\" , \"Global\" , 0 , 0 ],\n", " [\"Europe\" , \"Global\" , 0 , 0 ],\n", " [\"Asia\" , \"Global\" , 0 , 0 ],\n", " [\"Australia\", \"Global\" , 0 , 0 ],\n", " [\"Africa\" , \"Global\" , 0 , 0 ],\n", " [\"Brazil\" , \"America\" , 11, 10 ],\n", " [\"USA\" , \"America\" , 52, 31 ],\n", " [\"Mexico\" , \"America\" , 24, 12 ],\n", " [\"Canada\" , \"America\" , 16, -23 ],\n", " [\"France\" , \"Europe\" , 42, -11 ],\n", " [\"Germany\" , \"Europe\" , 31, -2 ],\n", " [\"Sweden\" , \"Europe\" , 22, -13 ],\n", " [\"Italy\" , \"Europe\" , 17, 4 ],\n", " [\"UK\" , \"Europe\" , 21, -5 ],\n", " [\"China\" , \"Asia\" , 36, 4 ],\n", " [\"Japan\" , \"Asia\" , 20, -12 ],\n", " [\"India\" , \"Asia\" , 40, 63 ],\n", " [\"Laos\" , \"Asia\" , 4 , 34 ],\n", " [\"Mongolia\" , \"Asia\" , 1 , -5 ],\n", " [\"Israel\" , \"Asia\" , 12, 24 ],\n", " [\"Iran\" , \"Asia\" , 18, 13 ],\n", " [\"Pakistan\" , \"Asia\" , 11, -52 ],\n", " [\"Egypt\" , \"Africa\" , 21, 0 ],\n", " [\"S. Africa\", \"Africa\" , 30, 43 ],\n", " [\"Sudan\" , \"Africa\" , 12, 2 ],\n", " [\"Congo\" , \"Africa\" , 10, 12 ],\n", " [\"Zair\" , \"Africa\" , 8 , 10 ]\n", " ]\n", " )\n", "\n", " opts = { :width => 600, :height => 600, :minColor => '#f00', :midColor => '#ddd', :maxColor => '#0d0', :headerHeight => 15, :fontColor => 'black', :showScale => true }\n", " " ] }, { "cell_type": "code", "execution_count": 80, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Region\"}, {:type=>\"string\", :label=>\"Parent\"}, {:type=>\"number\", :label=>\"Market trade volume (size)\"}, {:type=>\"number\", :label=>\"Market increase/decrease (color)\"}], @rows=[[#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #], [#, #, #, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>600, \"height\"=>600, \"minColor\"=>\"#f00\", \"midColor\"=>\"#ddd\", \"maxColor\"=>\"#0d0\", \"headerHeight\"=>15, \"fontColor\"=>\"black\", \"showScale\"=>true}>" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tree_map = GoogleVisualr::Interactive::TreeMap.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 81, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tree_map.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 82, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:wordtree=>{:format=>\"implicit\", :word=>\"cats\"}}" ] }, "execution_count": 82, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column(\"string\", \"Phrases\")\n", " data_table.add_rows(\n", " [\n", " ['cats are better than dogs'],\n", " ['cats eat kibble'],\n", " ['cats are better than hamsters'],\n", " ['cats are awesome'],\n", " ['cats are people too'],\n", " ['cats eat mice'],\n", " ['cats meowing'],\n", " ['cats in the cradle'],\n", " ['cats eat mice'],\n", " ['cats in the cradle lyrics'],\n", " ['cats eat kibble'],\n", " ['cats for adoption'],\n", " ['cats are family'],\n", " ['cats eat mice'],\n", " ['cats are better than kittens'],\n", " ['cats are evil'],\n", " ['cats are weird'],\n", " ['cats eat mice']\n", " ]\n", " )\n", "\n", " opts = { wordtree: { format: 'implicit', word: 'cats' } }" ] }, { "cell_type": "code", "execution_count": 83, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"string\", :label=>\"Phrases\"}], @rows=[[#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#], [#]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"wordtree\"=>{:format=>\"implicit\", :word=>\"cats\"}}>" ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "word_tree = GoogleVisualr::Interactive::WordTree.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 84, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 84, "metadata": {}, "output_type": "execute_result" } ], "source": [ "word_tree.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 85, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{:width=>120, :height=>40, :showAxisLines=>false, :showValueLabels=>false, :labelPosition=>\"left\"}" ] }, "execution_count": 85, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_table = GoogleVisualr::DataTable.new\n", " data_table.new_column(\"number\", \"Revenue\" )\n", " data_table.new_column(\"number\", \"Licenses\")\n", "\n", " data_table.add_rows(10)\n", "\n", " data_table.set_cell(0,0,435)\n", " data_table.set_cell(1,0,438)\n", " data_table.set_cell(2,0,512)\n", " data_table.set_cell(3,0,460)\n", " data_table.set_cell(4,0,491)\n", " data_table.set_cell(5,0,487)\n", " data_table.set_cell(6,0,552)\n", " data_table.set_cell(7,0,511)\n", " data_table.set_cell(8,0,505)\n", " data_table.set_cell(9,0,509)\n", "\n", " data_table.set_cell(0,1,132)\n", " data_table.set_cell(1,1,131)\n", " data_table.set_cell(2,1,137)\n", " data_table.set_cell(3,1,142)\n", " data_table.set_cell(4,1,140)\n", " data_table.set_cell(5,1,139)\n", " data_table.set_cell(6,1,147)\n", " data_table.set_cell(7,1,146)\n", " data_table.set_cell(8,1,151)\n", " data_table.set_cell(9,1,149)\n", "\n", " opts = { :width => 120, :height => 40, :showAxisLines => false, :showValueLabels => false, :labelPosition => 'left' }\n", " " ] }, { "cell_type": "code", "execution_count": 86, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "#\"number\", :label=>\"Revenue\"}, {:type=>\"number\", :label=>\"Licenses\"}], @rows=[[#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #], [#, #]]>, @listeners=[], @version=\"1.0\", @language=nil, @material=false, @options={\"width\"=>120, \"height\"=>40, \"showAxisLines\"=>false, \"showValueLabels\"=>false, \"labelPosition\"=>\"left\"}>" ] }, "execution_count": 86, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Spark_line = GoogleVisualr::Image::SparkLine.new(data_table, opts)" ] }, { "cell_type": "code", "execution_count": 87, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 87, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Spark_line.show_in_iruby" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Ruby 2.3.1", "language": "ruby", "name": "ruby" }, "language_info": { "file_extension": ".rb", "mimetype": "application/x-ruby", "name": "ruby", "version": "2.3.1" } }, "nbformat": 4, "nbformat_minor": 2 }