|
|
@ -16,13 +16,14 @@ |
|
|
|
# |
|
|
|
# |
|
|
|
# You should have received a copy of the GNU Lesser General Public License |
|
|
|
# You should have received a copy of the GNU Lesser General Public License |
|
|
|
# along with pygal. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# along with pygal. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
from flask import Flask, render_template, request |
|
|
|
from flask import Flask, render_template, request, jsonify |
|
|
|
from pygal import CHARTS_BY_NAME |
|
|
|
from pygal import CHARTS_BY_NAME |
|
|
|
from pygal.graph import CHARTS_NAMES |
|
|
|
from pygal.graph import CHARTS_NAMES |
|
|
|
from pygal.config import CONFIG_ITEMS |
|
|
|
from pygal.config import CONFIG_ITEMS |
|
|
|
from pygal.interpolate import KINDS |
|
|
|
from pygal.interpolate import KINDS |
|
|
|
from pygal.style import styles |
|
|
|
from pygal.style import styles |
|
|
|
from json import loads |
|
|
|
from json import loads |
|
|
|
|
|
|
|
from time import time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_app(): |
|
|
|
def create_app(): |
|
|
@ -50,6 +51,9 @@ def create_app(): |
|
|
|
chart = CHARTS_BY_NAME[values['type']](**config) |
|
|
|
chart = CHARTS_BY_NAME[values['type']](**config) |
|
|
|
for serie in loads(values['vals'])['vals']: |
|
|
|
for serie in loads(values['vals'])['vals']: |
|
|
|
chart.add(serie[0], serie[1]) |
|
|
|
chart.add(serie[0], serie[1]) |
|
|
|
return chart.render_response() |
|
|
|
t = time() |
|
|
|
|
|
|
|
svg = chart.render() |
|
|
|
|
|
|
|
tt = int((time() - t) * 1000) |
|
|
|
|
|
|
|
return jsonify(svg=svg, time=tt) |
|
|
|
|
|
|
|
|
|
|
|
return app |
|
|
|
return app |
|
|
|