diff options
| author | Fabien Pinckaers <fp@openerp.com> | 2012-05-07 23:06:43 +0200 |
|---|---|---|
| committer | Fabien Pinckaers <fp@openerp.com> | 2012-05-07 23:06:43 +0200 |
| commit | 99ca1bbbbb703a1b2b09adc04f9136af1be65c5e (patch) | |
| tree | 002cd4783b7a83bc1c5c9a534f3f474c7cb0cdad /addons/web_graph/controllers | |
| parent | 353f8ef8ee4965e7ec044e8302b1a34787b5a5cb (diff) | |
[IMP] fetching data, partially working
bzr revid: fp@openerp.com-20120507210643-s9244djxtnh0nazc
Diffstat (limited to 'addons/web_graph/controllers')
| -rw-r--r-- | addons/web_graph/controllers/graph.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/addons/web_graph/controllers/graph.py b/addons/web_graph/controllers/graph.py index 478941b58e7..7165e039fee 100644 --- a/addons/web_graph/controllers/graph.py +++ b/addons/web_graph/controllers/graph.py @@ -48,27 +48,29 @@ class GraphView(View): print "X", xaxis, "Y", yaxis # Convert a field's data into a displayable string + + ticks = {} def _convert(field, data): if fields[field]['type']=='many2one': - return data and data[1] or "" - return data or "" + data = data and data[1] + return ticks.setdefault(data, len(ticks)) + + def _orientation(x, y): + if not orientation: + return (x,y) + return (y,x) result = [] for x in xaxis: - res = obj.read_group(domain, yaxis+[x], [x], context=context) - print res result.append( { - 'data': map(lambda record: (_convert(x, record[x]), record[yaxis[0]]), res), + 'data': map(lambda record: _orientation(_convert(x, record[x]), record[yaxis[0]]), res), 'label': fields[x]['string'] }) print result - return result - [ - { - 'data': 3, - 'label': "Axis Name" - } - ] + return { + 'data': result, + 'ticks': map(lambda x: (x[1], x[0]), ticks.items()) + } |
