Skip to content

Commit 2f6b067

Browse files
committed
get_data() is the right place to change the format of data to something
usable by the renderer. get_data_json() purpose is only to jsonify the data.
1 parent 30d4352 commit 2f6b067

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

graphos/renderers/morris.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
from ..utils import JSONEncoderForHTML
55

66
class BaseMorrisChart(BaseChart):
7-
def get_data_json(self):
7+
8+
def get_data(self):
89
header = self.header
9-
data_only = self.get_data()[1:]
10+
data = super(BaseMorrisChart, self).get_data()
11+
data_only = data[1:]
1012
rows = []
1113
for row in data_only:
1214
rows.append(dict(zip(header, row)))
13-
14-
return json.dumps(rows, cls=JSONEncoderForHTML)
15+
return rows
1516

1617
def get_category_key(self):
1718
return self.header[0]
@@ -40,10 +41,10 @@ def chart_type(self):
4041

4142

4243
class DonutChart(BaseMorrisChart):
43-
def get_data_json(self):
44-
data_only = self.get_data()[1:]
45-
46-
return json.dumps([{"label": el[0], "value": el[1]} for el in data_only], cls=JSONEncoderForHTML)
44+
def get_data(self):
45+
data = super(BaseMorrisChart, self).get_data()
46+
data_only = data[1:]
47+
return [{"label": el[0], "value": el[1]} for el in data_only]
4748

4849
def chart_type(self):
4950
return "Donut"

0 commit comments

Comments
 (0)