Google charts & Plomino DB

Help
Anonymous
2010-10-18
2013-04-25
  • Anonymous - 2010-10-18

    Hello All,

    We want to make charts with Google Charts from some fields of our Plomino DB.
    We use this tutorial (http://code.google.com/intl/fr/apis/chart/) to build our project.
    We have an issue, we don't manage to have the charts with Plomino (fields of Plomino DB)  (the charts works fine with fixed numbers).

    We make this formula http://pastie.org/1230330 to retrieve figures from Plomino DB, where do make an error?

    Thanks+
    Best regards
    Nicolas

     
  • Eric Brehault

    Eric Brehault - 2010-10-19

    Hello Nicolas,

    your original formula:
    db = plominoDocument.getParentDatabase()
    docs =
    n=0
    m=0
      for doc in docs
        if doc.TypePB == "Informatique"
          n = n + 1
        if doc.TypePB == "Autre"
          m = m + 1
    return {'chd': 't:'+str(m)+','+str(n), 'chs': '250x100', 'cht':'p3', 'chl': 'Cost|Margin'}

    has the following errors:
    - getindex is getIndex and is a method, so it should be getIndex()
    - 'Form Workflow' is probably not the id of your form (as it contains a blank it is probably its title, the id is something like that: form-workflow, check that in your design)
    - in Python, you need ':' after if statement
    - in Python, indenting is very important, it delimits the blocks, so you cannot indent just the way you want, in your case, the 'for' line shouldn't be indented
    - if TypePB is not set on one of the doc, doc.TypePB will produce an error, so use doc.getItem('TypePB') (which returns '' is the item is not existing in the doc)

    so your formula will be probably:
    db = plominoDocument.getParentDatabase()
    docs =
    n=0
    m=0
    for doc in docs
      if doc.getItem('TypePB') == "Informatique":
        n = n + 1
      if doc.getItem('TypePB') == "Autre":
        m = m + 1
    return {'chd': 't:'+str(m)+','+str(n), 'chs': '250x100', 'cht':'p3', 'chl': 'Cost|Margin'}

    note: to debug your Plomino formula, you can install Clouseau on your Plone site, then open the Python prompt into your plomno doc page, enter this:
    plominDocument = context
    and then copy paste line by line your formula to see if you get any error message

    Eric

     
  • Anonymous - 2010-10-28

    Hello, as we don't manage to make Clouseau (or else to debug Plomino)

    We have an issue with this formula:

    db = plominoDocument.getParentDatabase()
    docs =
    n=0
    m=0
    for doc in docs
      m = m + 1
    return {'chd': 't:'+str(m)+','+str(n), 'chs': '250x100', 'cht':'p3', 'chl':'Cost|Margin'}

    We don't suceed to make the charts
    Thanks a lot
    Nicolas

     
  • Eric Brehault

    Eric Brehault - 2010-10-29

    Hello,

    You have just forgotten ':' at the end of your for line:
    for doc in docs:

    Once fixed, your formula works just fine (I tried it)

    Note: I will try to fix clouseau on Plone 4 (I am not the official maintainer, butr I will give it a try)

     
  • Robert

    Robert - 2011-05-26

    Hi everyone,

    I need to track the history of a document to see the date of updates and who made them, for this I used this formula in the onSave event but I don't know how to catch it or why I don't see the item.

    Heres is the formula: http://pastie.org/1976607

    Thanks.

     
  • Eric Brehault

    Eric Brehault - 2011-05-26

    Hello,

    Basically your onSave event will store an item name 'history' in the document.
    You can see its value by clicking on the Document Properties tab, which lists all the current items of the document.
    If you want to display it, you need to add a field in the form.
    Best option is to add a new computed for display text (or richtext) field in your form, named display_history for instance, and which formula would be:
    context.getItem('history')

    Note: I am not sure you are allowed to use DateTime() in a formula, to get the current date, you can just use Now()

    Eric

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks