Draw Line chart

Discussion in 'Ruby' started by Fan Jin, Jan 9, 2011.

  1. Fan Jin

    Fan Jin Guest

    Hi:
    I have built up table in MS Access, and there were data stored in that
    table. Now I want to output those data from MS Access to draw a Line
    chart. I have install the gem "Gruff", "RMagick", and "ImageMagick" for
    drawing. Does anybody know how to do this? Please give some idea.

    Thanks
    -Jin Fan

    --
    Posted via http://www.ruby-forum.com/.
    Fan Jin, Jan 9, 2011
    #1
    1. Advertising

  2. Hi,

    the simplest is if you can export your columns of datas into CSV
    format. Then you can just read it with the 'csv' libary. See
    http://ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html for some usage.
    Then it's just a matter of opening the CSV, get the values you want
    out of it, and feed them to Gruff.

    I'm sure it's also possible to connect to the Access database using
    ADO under windows, but it's going to be a bit harder I think. If it's
    only a tool for you, I would keep the CSV version, otherwise invest
    some time in the ADO version once the first-one is working.
    Jonas Pfenniger (zimbatm), Jan 9, 2011
    #2
    1. Advertising

  3. Fan Jin

    Fan Jin Guest

    zimbatm ... wrote in post #973434:
    > Hi,
    >
    > the simplest is if you can export your columns of datas into CSV
    > format. Then you can just read it with the 'csv' libary. See
    > http://ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html for some usage.
    > Then it's just a matter of opening the CSV, get the values you want
    > out of it, and feed them to Gruff.
    >
    > I'm sure it's also possible to connect to the Access database using
    > ADO under windows, but it's going to be a bit harder I think. If it's
    > only a tool for you, I would keep the CSV version, otherwise invest
    > some time in the ADO version once the first-one is working.



    What tools that I need to use to convert data into CSV format, please?
    It seems that I need to install some tools to do this.

    -Jin Fan

    --
    Posted via http://www.ruby-forum.com/.
    Fan Jin, Jan 10, 2011
    #3
  4. Fan Jin

    Ralf Mueller Guest

    On 01/10/2011 08:03 AM, Fan Jin wrote:
    > zimbatm ... wrote in post #973434:
    >> Hi,
    >>
    >> the simplest is if you can export your columns of datas into CSV
    >> format. Then you can just read it with the 'csv' libary. See
    >> http://ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html for some usage.
    >> Then it's just a matter of opening the CSV, get the values you want
    >> out of it, and feed them to Gruff.
    >>
    >> I'm sure it's also possible to connect to the Access database using
    >> ADO under windows, but it's going to be a bit harder I think. If it's
    >> only a tool for you, I would keep the CSV version, otherwise invest
    >> some time in the ADO version once the first-one is working.

    >
    > What tools that I need to use to convert data into CSV format, please?
    > It seems that I need to install some tools to do this.
    >

    Not sure, but MSAccess should have a "Save As"" exporter to CSV. MSExcel definitelyhas one.
    Ralf Mueller, Jan 10, 2011
    #4
  5. Mike Stephens, Jan 10, 2011
    #5
  6. [Note: parts of this message were removed to make it a legal post.]

    Is it a one-time task, or does it need to be done many times?
    On 10 Jan 2011 07:03, "Fan Jin" <> wrote:
    >
    > zimbatm ... wrote in post #973434:
    > > Hi,
    > >
    > > the simplest is if you can export your columns of datas into CSV
    > > format. Then you can just read it with the 'csv' libary. See
    > > http://ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html for some usage.
    > > Then it's just a matter of opening the CSV, get the values you want
    > > out of it, and feed them to Gruff.
    > >
    > > I'm sure it's also possible to connect to the Access database using
    > > ADO under windows, but it's going to be a bit harder I think. If it's
    > > only a tool for you, I would keep the CSV version, otherwise invest
    > > some time in the ADO version once the first-one is working.

    >
    >
    > What tools that I need to use to convert data into CSV format, please?
    > It seems that I need to install some tools to do this.
    >
    > -Jin Fan
    >
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    Jonas Pfenniger (zimbatm), Jan 10, 2011
    #6
  7. Fan Jin

    Fan Jin Guest

    Mike Stephens wrote in post #973636:
    > I know I'll get hate mail as soon as I press Submit but don't ignore the
    > best gem in the Ruby World.
    >
    > It's most likely already installed on your computer and it's called
    > Excel, and it's dead easy to create charts. As a matter of
    > interest it is equally dead easy to script Access (ie Jet) to get the
    > data out.
    >
    > See eg
    > http://rubyonwindows.blogspot.com/2008/06/automating-excel-creating-charts.html


    Thanks a lot. But I still have some problems with get the Range from the
    table which imported from the MS Access, cos I do not want to set the
    range every time with new table imported. Please give me more hints with
    how to do this, thanks.

    --
    Posted via http://www.ruby-forum.com/.
    Fan Jin, Jan 11, 2011
    #7
  8. Fan Jin wrote in post #973892:
    > I still have some problems with get the Range from the
    > table which imported from the MS Access, cos I do not want to set the
    > range every time with new table imported. Please give me more hints with
    > how to do this, thanks.


    Excel does have concepts of the currently active range etc without you
    necessarily telling it the details but I would be inclined to use Ruby
    to read the Access table into an array and then plonk the data into a
    range (rather than getting Excel to import it). It's just a simple
    assignment. Since you can find the number of rows retrieved, you can
    easily get Ruby to calculate the range. I guess that will be easier when
    you then get Ruby to request the Chart. Look at the Ruby on Windows blog
    to see how to access Access (Jet) - it's only a few lines of code.

    --
    Posted via http://www.ruby-forum.com/.
    Mike Stephens, Jan 11, 2011
    #8
  9. Fan Jin

    Fan Jin Guest

    Mike Stephens wrote in post #973911:
    > Fan Jin wrote in post #973892:
    >> I still have some problems with get the Range from the
    >> table which imported from the MS Access, cos I do not want to set the
    >> range every time with new table imported. Please give me more hints with
    >> how to do this, thanks.

    >
    > Excel does have concepts of the currently active range etc without you
    > necessarily telling it the details but I would be inclined to use Ruby
    > to read the Access table into an array and then plonk the data into a
    > range (rather than getting Excel to import it). It's just a simple
    > assignment. Since you can find the number of rows retrieved, you can
    > easily get Ruby to calculate the range. I guess that will be easier when
    > you then get Ruby to request the Chart. Look at the Ruby on Windows blog
    > to see how to access Access (Jet) - it's only a few lines of code.


    Thanks, that's very great! But after the data has been stored in an
    Array,which gem can be used to draw a dynamic chart, please?

    --
    Posted via http://www.ruby-forum.com/.
    Fan Jin, Jan 11, 2011
    #9
  10. Fan Jin

    timr Guest

    You could definitely do it with the ruby-processing gem, which can
    watch a script and update the graph live, so any data changes the
    graph is automatically updated. But you would have to build up the
    chart from scratch as nobody has built a framework for graphing (as
    far as I know). I haven't seen any graphing tools in pure ruby, and
    most people doing such scientific graphic end up just using python
    which has the numpy and scipy modules.

    Alternatively you can get your data into CSV format and import that
    into R, gnuplot, or excel and graph it easily. My favorite is R with
    the ggplot2 module. You can write an R/ggplot script and R to execute
    it from ruby using backtics as quotes (`R <myRscript`).

    Science/graphing is ruby's achilles heel.

    Tim



    On Jan 11, 5:21 am, Fan Jin <> wrote:
    > Mike Stephens wrote in post #973911:
    >
    > > Fan Jin wrote in post #973892:
    > >> I still have some problems with get the Range from the
    > >> table which imported from the MS Access, cos I do not want to set the
    > >> range every time with new table imported. Please give me more hints with
    > >> how to do this, thanks.

    >
    > > Excel does have concepts of the currently active range etc without you
    > > necessarily telling it the details but I would be inclined to use Ruby
    > > to read the Access table into an array and then plonk the data into a
    > > range (rather than getting Excel to import it). It's just a simple
    > > assignment. Since you can find the number of rows retrieved, you can
    > > easily get Ruby to calculate the range. I guess that will be easier when
    > > you then get Ruby to request the Chart. Look at the Ruby on Windows blog
    > > to see how to access Access (Jet) - it's only a few lines of code.

    >
    > Thanks, that's very great! But after the data has been stored in an
    > Array,which gem can be used to draw a dynamic chart, please?
    >
    > --
    > Posted viahttp://www.ruby-forum.com/.
    timr, Jan 11, 2011
    #10
  11. Fan Jin

    Fan Jin Guest

    Mike Stephens wrote in post #973911:
    > Fan Jin wrote in post #973892:
    >> I still have some problems with get the Range from the
    >> table which imported from the MS Access, cos I do not want to set the
    >> range every time with new table imported. Please give me more hints with
    >> how to do this, thanks.

    >
    > Excel does have concepts of the currently active range etc without you
    > necessarily telling it the details but I would be inclined to use Ruby
    > to read the Access table into an array and then plonk the data into a
    > range (rather than getting Excel to import it). It's just a simple
    > assignment. Since you can find the number of rows retrieved, you can
    > easily get Ruby to calculate the range. I guess that will be easier when
    > you then get Ruby to request the Chart. Look at the Ruby on Windows blog
    > to see how to access Access (Jet) - it's only a few lines of code.


    Hi:
    I have successfully read data into arrays a[] and b[], but I do not know
    how to plonk the data into range format for drawing chart in excel.
    Could you show me more details,please? Thanks.
    -Jin Fan

    --
    Posted via http://www.ruby-forum.com/.
    Fan Jin, Jan 12, 2011
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kamal anand

    Draw Text on OWC Chart Control

    kamal anand, Apr 13, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,388
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jan 12, 2006
  2. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    0
    Views:
    348
    =?Utf-8?B?ZGF2aWQ=?=
    Feb 16, 2006
  3. Andrew
    Replies:
    1
    Views:
    408
    Gregory Vaughan
    Nov 3, 2003
  4. Grand Paradis
    Replies:
    0
    Views:
    4,544
    Grand Paradis
    Apr 11, 2005
  5. gnewsgroup
    Replies:
    4
    Views:
    2,999
    Kevin Spencer
    Feb 6, 2008
Loading...

Share This Page