{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\n", "Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.\n", "\n", "Install the mechanize gem version ~>2.7.5 for using mechanize functions.\n" ] }, { "data": { "text/plain": [ "true" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "require 'daru/view'" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "\n", " /* BEGIN google_visualr.js */\n", "\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 = 'http://www.google.com/uds';\n", "google.loader.GoogleApisBase = 'http://ajax.googleapis.com/ajax';\n", "google.loader.ApiKey = 'notsupplied';\n", "google.loader.KeyVerified = true;\n", "google.loader.LoadFailure = false;\n", "google.loader.Secure = false;\n", "google.loader.GoogleLocale = 'www.google.com';\n", "google.loader.ClientLocation = null;\n", "google.loader.AdditionalParams = '';\n", "(function() {var g=this,l=function(a,b,c){a=a.split(\".\");c=c||g;a[0]in c||\"undefined\"==typeof c.execScript||c.execScript(\"var \"+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c=c[d]&&c[d]!==Object.prototype[d]?c[d]:c[d]={}:c[d]=b},m=function(a,b,c){a[b]=c};var w=function(a,b){if(b)a=a.replace(n,\"&\").replace(p,\"<\").replace(q,\">\").replace(r,\""\").replace(t,\"'\").replace(u,\"�\");else{if(!v.test(a))return a;-1!=a.indexOf(\"&\")&&(a=a.replace(n,\"&\"));-1!=a.indexOf(\"<\")&&(a=a.replace(p,\"<\"));-1!=a.indexOf(\">\")&&(a=a.replace(q,\">\"));-1!=a.indexOf('\"')&&(a=a.replace(r,\""\"));-1!=a.indexOf(\"'\")&&(a=a.replace(t,\"'\"));-1!=a.indexOf(\"\\x00\")&&(a=a.replace(u,\"�\"))}return a},n=/&/g,p=//g,r=/\"/g,t=/'/g,u=/\\x00/g,v=/[\\x00&<>\"']/;var x=/^[\\w+/_-]+[=]{0,2}$/;function y(a){return a in z?z[a]:z[a]=-1!=navigator.userAgent.toLowerCase().indexOf(a)}var z={};function A(a,b){var c=function(){};c.prototype=b.prototype;a.da=b.prototype;a.prototype=new c}function C(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 D(a){a=Error(a);a.toString=function(){return this.message};return a}\n", "function E(a,b){a=a.split(/\\./);for(var c=window,d=0;d\\x3c/script>\"):(y(\"safari\")||y(\"konqueror\"))&&window.setTimeout(L,10)),I.push(a)):J(window,\"load\",a)};l(\"google.setOnLoadCallback\",google.ca);\n", "function J(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?M([c,d]):c}}function M(a){return function(){for(var b=0;b\\x3c/script>\")):\"css\"==a&&(e='\"))};l(\"google.loader.writeLoadTag\",google.loader.f);google.loader.$=function(a){H=a};l(\"google.loader.rfm\",google.loader.$);google.loader.ba=function(a){for(var b in a)\"string\"==typeof b&&b&&\":\"==b.charAt(0)&&!G[b]&&(G[b]=new O(b.substring(1),a[b]))};\n", "l(\"google.loader.rpl\",google.loader.ba);google.loader.aa=function(a){if((a=a.specs)&&a.length)for(var b=0;b\\x3c/script>')},K.Ki=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.Tl=function(b,c){if(K.qg()){var d=K.global.document;if(!K.De&&d.readyState==t){if(/\\bdeps.js$/.test(b))return!1;throw Error('Cannot write \"'+b+'\" after document load');}void 0===c?K.di?(K.$g=!0,c=\" onreadystatechange='goog.onScriptLoad_(this, \"+ ++K.Pg+\")' \",d.write(n+b+'\"'+c+\">\\x3c/script>\")):K.De?K.Ki(b):K.Sl(b):d.write('\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "options = {\n", " type: :pie,\n", " title:'How Much Pizza Sarah Ate Last Night',\n", " width:400,\n", " height:300}\n", "pizza_sarah = Daru::View::Plot.new(df_sarah, options)\n", "pizza_sarah.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ " Daru::DataFrame(5x2) \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "\n", "
ToppingSlices
0Mushrooms2
1Onions2
2Olives2
3Zucchini0
4Pepperoni3
" ], "text/plain": [ "#\n", " Topping Slices\n", " 0 Mushrooms 2\n", " 1 Onions 2\n", " 2 Olives 2\n", " 3 Zucchini 0\n", " 4 Pepperoni 3" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "idx = Daru::Index.new ['Topping', 'Slices']\n", "data_rows = [\n", " ['Mushrooms', 2],\n", " ['Onions', 2],\n", " ['Olives', 2],\n", " ['Zucchini', 0],\n", " ['Pepperoni', 3]\n", "]\n", "df_anthony = Daru::DataFrame.rows(data_rows)\n", "df_anthony.vectors = idx\n", "df_anthony" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n" ], "text/plain": [ "\"
\\n\\n\"" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "options = {\n", " type: :pie,\n", " title:'How Much Pizza Anthony Ate Last Night',\n", " width:400,\n", " height:300}\n", "pizza_anthony = Daru::View::Plot.new(df_anthony, options)\n", "pizza_anthony.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "\n" ], "text/plain": [ "\"\\n \\n \\n \\n \\n \\n \\n \\n
\\n\\n\"" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "combined_pizza = Daru::View::PlotList.new([pizza_sarah, pizza_anthony])\n", "combined_pizza.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "\n" ], "text/plain": [ "\"\\n \\n \\n \\n \\n \\n \\n \\n
\\n\\n\"" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pizza_sarah_table = Daru::View::Table.new(df_sarah)\n", "combined = Daru::View::PlotList.new([pizza_sarah_table, pizza_sarah])\n", "combined.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "\n" ], "text/plain": [ "\"\\n \\n \\n \\n \\n \\n \\n \\n
\\n\\n\"" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pizza_anthony_table = Daru::View::Table.new(df_anthony)\n", "combined = Daru::View::PlotList.new([pizza_anthony_table, pizza_anthony])\n", "combined.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "\n" ], "text/plain": [ "\"\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
\\n\\n\"" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pizza_sarah_table = Daru::View::Table.new(df_sarah)\n", "pizza_anthony_table = Daru::View::Table.new(df_anthony)\n", "combined_table = Daru::View::PlotList.new([pizza_sarah_table, pizza_sarah, pizza_anthony_table, pizza_anthony])\n", "combined_table.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "\n" ], "text/plain": [ "\"\\n \\n \\n \\n \\n \\n \\n \\n
\\n\\n\"" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "options = {\n", " type: :bar,\n", " title:'How Much Pizza Sarah Ate Last Night',\n", " width:400,\n", " height:300}\n", "pizza_sarah_bar = Daru::View::Plot.new(df_sarah, options)\n", "combined = Daru::View::PlotList.new([pizza_sarah, pizza_sarah_bar])\n", "combined.show_in_iruby" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Ruby 2.4.1", "language": "ruby", "name": "ruby" }, "language_info": { "file_extension": ".rb", "mimetype": "application/x-ruby", "name": "ruby", "version": "2.4.1" } }, "nbformat": 4, "nbformat_minor": 2 }