Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daru::View::Plot can be usable as df.plot(..) #61

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Shekharrajak
Copy link
Member

e.g.

irb(main):001:0> idx = Daru::Index.new ['Year', 'Sales']
=> #<Daru::Index(2): {Year, Sales}>
irb(main):002:0> data_rows = [
irb(main):003:1*           ['2004',  1000],
irb(main):004:1*           ['2005',  1170],
irb(main):005:1*           ['2006',  660],
irb(main):006:1*           ['2007',  1030]
irb(main):007:1> ]
=> [["2004", 1000], ["2005", 1170], ["2006", 660], ["2007", 1030]]
irb(main):008:0> df_sale_exp = Daru::DataFrame.rows(data_rows)
=> #<Daru::DataFrame(4x2)>
         0    1
    0 2004 1000
    1 2005 1170
    2 2006  660
    3 2007 1030
irb(main):009:0> df_sale_exp.vectors = idx
=> #<Daru::Index(2): {Year, Sales}>
irb(main):010:0> df_sale_exp
=> #<Daru::DataFrame(4x2)>
        Year Sales
     0  2004  1000
     1  2005  1170
     2  2006   660
     3  2007  1030
irb(main):011:0> df_sale_exp.plot(adapter: :googlecharts)
=> #<Daru::View::Plot:0x007fa7c1940eb0 @data=#<Daru::DataFrame(4x2)>
        Year Sales
     0  2004  1000
     1  2005  1170
     2  2006   660
     3  2007  1030, @options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x007fa7c05b2060 @data_table=#<GoogleVisualr::DataTable:0x007fa7c08c2d90 @cols=[{:type=>"string", :label=>"Year"}, {:type=>"number", :label=>"Sales"}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x007fa7c05b3000 @v="2004", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa7c05b2f88 @v=1000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa7c05b2e70 @v="2005", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa7c05b2da8 @v=1170, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa7c05b2c40 @v="2006", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa7c05b2b78 @v=660, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa7c05b2880 @v="2007", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa7c05b2740 @v=1030, @type="number">]], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}>>

@Shekharrajak
Copy link
Member Author

Need some changes for nyaplot but as we know that we are shifting plotting system of daru to daru-view in near future this problem will be solved automatically.

@Shekharrajak
Copy link
Member Author

Anyone can cherry-pick this PR's commit and work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant