[MERGE] Remove the embedded pychart library, and use the online version
[odoo/odoo.git] /
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
4
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9 #
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # for more details.
14 #
15 import coord
16 import math
17 import pychart_util
18
19 class T(coord.T):
20     def get_canvas_pos(self, size, val, min, max2):
21         return size * (val - min) / max(float(max2 - min),0.01)
22
23     def get_tics(self, min, max, interval):
24         v = []
25         x = min
26         while x <= max:
27             v.append(x)
28             x += interval
29         return v
30     def get_min_max(self, dmin, dmax, interval):
31         if not interval:
32             if dmax == dmin:
33                 interval = 10
34             else:
35                 interval = 10 ** (float(int(math.log(dmax-dmin)/math.log(10))))
36         dmin = min(dmin, pychart_util.round_down(dmin, interval))
37         dmax = max(dmax, pychart_util.round_up(dmax, interval) + interval/2.0)
38         return dmin, dmax, interval