|
|
@ -22,15 +22,15 @@ from pygal.util import cut |
|
|
|
from datetime import datetime |
|
|
|
from datetime import datetime |
|
|
|
from pygal.i18n import COUNTRIES |
|
|
|
from pygal.i18n import COUNTRIES |
|
|
|
from pygal.graph.frenchmap import DEPARTMENTS, REGIONS |
|
|
|
from pygal.graph.frenchmap import DEPARTMENTS, REGIONS |
|
|
|
|
|
|
|
from decimal import Decimal |
|
|
|
|
|
|
|
|
|
|
|
def get_data(i): |
|
|
|
def get_data(i): |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
[(-1, 1), (2, 0), (0, 4)], |
|
|
|
[(-1, 1), (2, 0), (0, 4)], |
|
|
|
[(0, 1), (None, 2), (3, 2)], |
|
|
|
[(0, 1), (None, 2), (3, 2)], |
|
|
|
[(-3, 3), (1, 3), (1, 1)], |
|
|
|
[(-3, 3), (1, 3), (1, 1)], |
|
|
|
[(1, 1), (1, 1), (1, 1)], |
|
|
|
[(1, 1), (Decimal('1.'), 1), (1, 1)], |
|
|
|
[(3, 2), (2, 1), (1, 1)]][i] |
|
|
|
[(3, 2), (2, 1), (1., 1)]][i] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def adapt(chart, data): |
|
|
|
def adapt(chart, data): |
|
|
@ -46,13 +46,22 @@ def adapt(chart, data): |
|
|
|
|
|
|
|
|
|
|
|
data = cut(data) |
|
|
|
data = cut(data) |
|
|
|
if isinstance(chart, pygal.Worldmap): |
|
|
|
if isinstance(chart, pygal.Worldmap): |
|
|
|
return list(map(lambda x: list(COUNTRIES.keys())[x % len(COUNTRIES)] |
|
|
|
return list( |
|
|
|
|
|
|
|
map(lambda x: list( |
|
|
|
|
|
|
|
COUNTRIES.keys())[ |
|
|
|
|
|
|
|
int(x) % len(COUNTRIES)] |
|
|
|
if x is not None else None, data)) |
|
|
|
if x is not None else None, data)) |
|
|
|
elif isinstance(chart, pygal.FrenchMap_Regions): |
|
|
|
elif isinstance(chart, pygal.FrenchMap_Regions): |
|
|
|
return list(map(lambda x: list(REGIONS.keys())[x % len(REGIONS)] |
|
|
|
return list( |
|
|
|
|
|
|
|
map(lambda x: list( |
|
|
|
|
|
|
|
REGIONS.keys())[ |
|
|
|
|
|
|
|
int(x) % len(REGIONS)] |
|
|
|
if x is not None else None, data)) |
|
|
|
if x is not None else None, data)) |
|
|
|
elif isinstance(chart, pygal.FrenchMap_Departments): |
|
|
|
elif isinstance(chart, pygal.FrenchMap_Departments): |
|
|
|
return list(map(lambda x: list(DEPARTMENTS.keys())[x % len(DEPARTMENTS)] |
|
|
|
return list( |
|
|
|
|
|
|
|
map(lambda x: list( |
|
|
|
|
|
|
|
DEPARTMENTS.keys())[ |
|
|
|
|
|
|
|
int(x) % len(DEPARTMENTS)] |
|
|
|
if x is not None else None, data)) |
|
|
|
if x is not None else None, data)) |
|
|
|
return data |
|
|
|
return data |
|
|
|
|
|
|
|
|
|
|
|