Пример #1
0
def create_datatable(df, tablename="mytable"):
    cols = OrderedDict([("position", {
        "label": "Position"
    }), ("office", {
        "label": "Office"
    }), ("start_date", {
        "label": "Start Date"
    }),
                        ("salary_lower", {
                            "label": "Salary Range",
                            "confidence": {
                                "lower": "salary_lower",
                                "upper": "salary_upper"
                            }
                        })])

    addfunc = ("""
        confidence_interval(this.api().column(3,
            {{"page":"current"}}).data(), "{tablename}");
    """.format(tablename=tablename))

    drawfunc = ("""
        confidence_interval(this.api().column(3,
            {{"page":"current"}}).data(), "{tablename}");
    """.format(tablename=tablename))

    _table = DataTable(tablename,
                       "/api/{}/".format(tablename),
                       df,
                       columns=cols,
                       paging=True,
                       pageLength=9,
                       scrollX=True,
                       columnDefs=[{
                           "render":
                           """<svg width="156" height="20"><g></g></svg>""",
                           "orderable": False,
                           "targets": 3
                       }],
                       sDom='<"top">rt<"bottom"lp><"clear">',
                       deferRender=True,
                       initComplete=addfunc,
                       drawCallback=drawfunc)

    return _table
Пример #2
0
});
confidence_interval(this.api().column(3, {"page":"current"}).data(), "mytable");
"""

drawfunc = """
confidence_interval(this.api().column(3, {"page":"current"}).data(), "mytable");
"""


tb = DataTable(
    "mytable",
    "/mytable/",
    df,
    columns=cols,
    paging=True,
    pageLength=9,
    scrollX=True,
    columnDefs=[{"render": """<svg width="156" height="20"><g></g></svg>""", "orderable": False, "targets": 3}],
    sDom='<"top">rt<"bottom"lp><"clear">',
    deferRender=True,
    initComplete=addfunc,
    drawCallback=drawfunc,
)


app = Flask(__name__)
tb.register_route(app)

ui = SimpleComponent("Table", "./static/bower_components/pyxley/build/pyxley.js", "component_id", tb.params)

sb2 = SelectButton("SelectButton", ["Item1", "Item2"], "slide2", tb.params)
ui2 = SimpleComponent("SelectButton", "./static/bower_components/pyxley/build/pyxley.js", "slide2", sb2.params)
Пример #3
0
f = lambda x: '_'.join(x) if (len(x[1]) > 0) and x[1] != 'sum' else x[0]
gf.columns = [f(c) for c in gf.columns]
gf = gf.sort_index(by="week", ascending=False)
gf["Date_amin"] = gf["Date_amin"].apply(lambda x: x.strftime("%Y-%m-%d"))
gf["Date_amax"] = gf["Date_amax"].apply(lambda x: x.strftime("%Y-%m-%d"))

cols = OrderedDict([
    ("week", {"label": "Week"}),
    ("Date_amin", {"label": "Start Date"}),
    ("Date_amax", {"label": "End Date"}),
    ("Calories Burned", {"label": "Calories Burned"}),
    ("Steps", {"label": "Steps"}),
    ("Distance", {"label": "Distance (mi)", "format": "%5.2f"})
])

tb = DataTable("mytable", "/mytable/", gf, columns=cols, paging=True, pageLength=5)
ui.add_chart(tb)

app = Flask(__name__)
sb = ui.render_layout(app, "./static/layout.js")


@app.route('/', methods=["GET"])
@app.route('/index', methods=["GET"])
def index():
    _scripts = ["./layout.js"]
    return render_template('index.html',
        title=TITLE,
        base_scripts=scripts,
        page_scripts=_scripts,
        css=css)
Пример #4
0
});
confidence_interval(this.api().column(3, {"page":"current"}).data(), "mytable");
"""

drawfunc = """
confidence_interval(this.api().column(3, {"page":"current"}).data(), "mytable");
"""

tb = DataTable("mytable",
               "/mytable/",
               df,
               columns=cols,
               paging=True,
               pageLength=9,
               scrollX=True,
               columnDefs=[{
                   "render": """<svg width="156" height="20"><g></g></svg>""",
                   "orderable": False,
                   "targets": 3
               }],
               sDom='<"top">rt<"bottom"lp><"clear">',
               deferRender=True,
               initComplete=addfunc,
               drawCallback=drawfunc)

app = Flask(__name__)
tb.register_route(app)

ui = SimpleComponent("Table",
                     "./static/bower_components/pyxley/build/pyxley.js",
                     "component_id", tb.params)