{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "true" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "require 'daru/view'" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/shekharrajak/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/daru-data_tables-af3460a049da/lib/daru/data_tables/version.rb:3: warning: already initialized constant Daru::View::VERSION\n", "/home/shekharrajak/Documents/githubRepos/sciruby/windows-daru-view/daru-view/lib/daru/view/version.rb:3: warning: previous definition of VERSION was here\n" ] }, { "data": { "text/plain": [ ":datatables" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Daru::View.table_library = :datatables" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ " Daru::DataFrame(5x3) \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " \n", "\n", "
abc
one11111
two21222
three31333
four41444
five51555
" ], "text/plain": [ "#\n", " a b c\n", " one 1 11 11\n", " two 2 12 22\n", " three 3 13 33\n", " four 4 14 44\n", " five 5 15 55" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = Daru::DataFrame.new({b: [11,12,13,14,15], a: [1,2,3,4,5],\n", " c: [11,22,33,44,55]},\n", " order: [:a, :b, :c],\n", " index: [:one, :two, :three, :four, :five])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "#\n", " a b c\n", " one 1 11 11\n", " two 2 12 22\n", " three 3 13 33\n", " four 4 14 44\n", " five 5 15 55, @options={:pageLength=>3, :data=>[[0, 1, 11, 11], [1, 2, 12, 22], [2, 3, 13, 33], [3, 4, 14, 44], [4, 5, 15, 55]]}, @user_options={}, @adapter=Daru::View::Adapter::DatatablesAdapter, @table=#{:class=>\"display\", :cellspacing=>\"0\", :width=>\"100%\"}}, @data=#\n", " a b c\n", " one 1 11 11\n", " two 2 12 22\n", " three 3 13 33\n", " four 4 14 44\n", " five 5 15 55, @options={:pageLength=>3, :data=>[[0, 1, 11, 11], [1, 2, 12, 22], [2, 3, 13, 33], [3, 4, 14, 44], [4, 5, 15, 55]]}>>" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dt_df = Daru::View::Table.new(df, pageLength: 3)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
abc
" ], "text/plain": [ "\"\\n\\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
abc
\"" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dt_df.show_in_iruby" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"\\n\\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
abc
\"" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ " table_opts = {\n", " class: \"display\",\n", " cellspacing: \"0\",\n", " width: \"50%\",\n", " table_html: \"\n", " \n", " \n", " Num1 \n", " Num2 \n", " Num3 \n", " \n", " \"\n", " }\n", " options = {\n", " table_options: table_opts\n", " }\n", "html_code_dt_df = dt_df.table.to_html(id='table_id4', options)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
abc
" ], "text/plain": [ "\"\\n\\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
abc
\"" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "IRuby.html html_code_dt_df" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Ruby 2.5.3", "language": "ruby", "name": "ruby" }, "language_info": { "file_extension": ".rb", "mimetype": "application/x-ruby", "name": "ruby", "version": "2.5.3" } }, "nbformat": 4, "nbformat_minor": 2 }