{% extends base.html %} {% block title %}{{ title }}{% end %} {% block content %} {% if handler.request.path == '/chart' %} {% if handler.application.db %}

POST /chart/name, 其中name是chart的名字

body为json格式字符串,为一个list,每个成员都是一张图表

支持3种格式的图表,分别为折线图(line)、直方图(column)、饼图(pie)

curl -XDELETE http://{{ handler.request.host }}/chart/test

curl -XPOST http://{{ handler.request.host }}/chart/test -d '[
    {
        "type": "line",
        "title": "line chart",
        "xAxis": ["一月", "二月", "三月", "四月", "五月", "六月"],
        "series": [
            {
                "name": "东京",
                "visible": true,
                "data": [7.0, 6.9, 9.5, 14.5, 18.2, 21.5]
            },
            {
                "name": "纽约",
                "visible": false,
                "data": [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0]
            }
        ]
    },
    {
        "type": "column",
        "title": "column chart",
        "xAxis": ["一月", "二月", "三月", "四月", "五月", "六月"],
        "series": [
            {
                "name": "东京",
                "visible": true,
                "data": [7.0, 6.9, 9.5, 14.5, 18.2, 21.5]
            },
            {
                "name": "纽约",
                "visible": false,
                "data": [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0]
            }
        ]
    },
    {
        "type": "pie",
        "title": "pie chart",
        "series": [
            {
                "name": "day money",
                "data": [
                    ["one", 1.0],
                    ["two", 2.0],
                    ["three", 3.0]
                ]
            }
        ]
    }
]'

{% else %}
请先安装mongodb用于数据存储,使用参数--db=mongodb://localhost:27017/kk
{% end %} {% end %} {% end %} {% block js %} {% end %}