예제 #1
0
def make_table_layout():
    filename = "../examples/datatables/project/static/data.json"
    df = get_data(filename)

    ui = UILayout("SimpleChart")
    ui.add_chart(create_datatable(df))
    return ui
예제 #2
0
def make_mg_layout():
    # load a dataframe
    filename = "../examples/metricsgraphics/project/fitbit_data.csv"
    df = pd.read_csv(filename)

    # Make a UI
    ui = UILayout("FilterChart")

    # Make a Button
    cols = [c for c in df.columns if c != "Date"]
    btn = SelectButton("Data", cols, "Data", "Steps")

    # add the button to the UI
    ui.add_filter(btn)

    # stack the dataframe
    _stack = df.set_index("Date").stack().reset_index()
    _stack = _stack.rename(columns={"level_1": "Data", 0: "value"})

    # Make a Figure, add some settings, make a line plot
    ui.add_chart(create_line_plot(_stack))
    ui.add_chart(create_histogram(_stack))
    ui.add_chart(create_scatterplot(df))

    return ui
예제 #3
0
파일: build_ui.py 프로젝트: ylwb/pyxley
def build_filter_props(buttons):
    """ build filter props

        return props for a list of buttons.

        Args:
            buttons (list): list of pyxley.Filter components.
    """
    ui = UILayout("PyxleyChart")

    for b in buttons:
        ui.add_filter(b)

    return ui.build_props()
예제 #4
0
파일: buildui.py 프로젝트: ylwb/pyxley
def make_nv_layout(filename):
    # load the data
    df = pd.read_csv(filename)

    ui = UILayout("FilterChart")

    # Make a button
    choices = ["Heart Rate", "Pace", "Distance"]
    btn = SelectButton("Data", choices, "Data", "Heart Rate")
    ui.add_filter(btn)

    # Add the chart
    ui.add_chart(two_axis_focus(df))
    ui.add_chart(pie_chart(df))
    return ui
예제 #5
0
파일: nvd3.py 프로젝트: ylwb/pyxley
def make_nv_layout():
    # load the data
    filename = "../examples/nvd3/project/static/formatted_run.csv"
    df = pd.read_csv(filename)

    ui = UILayout("FilterChart")

    # Make a button
    choices = ["Heart Rate", "Pace", "Distance"]
    btn = SelectButton("Data", choices, "Data", "Heart Rate")
    ui.add_filter(btn)

    # Add the chart
    ui.add_chart(two_axis_focus(df))
    ui.add_chart(pie_chart(df))
    return ui
예제 #6
0
파일: buildui.py 프로젝트: ylwb/pyxley
def make_datamaps_ui(filename):
    # Make a UI
    ui = UILayout("SimpleChart")

    df = pd.read_csv(filename)
    df.month = df.month.astype('str')

    sldr = SliderInput("Month", 1, 13, "month", "1")
    ui.add_filter(sldr)

    dm = DatamapUSA("/data_map/",
                    "mapid",
                    df,
                    "state",
                    "color1",
                    init_params={"month": "1"})
    ui.add_chart(dm)
    return ui
예제 #7
0
def make_datamaps_ui():
    # Make a UI
    ui = UILayout("PyxleyChart")

    datafile = "../examples/datamaps/project/Colorful_State.csv"
    df = pd.read_csv(datafile)
    df.month = df.month.astype('str')

    sldr = SliderInput("Month", 1, 13, "month", "1")
    ui.add_filter(sldr)

    dm = DatamapUSA("/data_map/",
                    "mapid",
                    df,
                    "state",
                    "color1",
                    init_params={"month": "1"})
    ui.add_chart(dm)
    return ui
예제 #8
0
파일: buildui.py 프로젝트: zzygithub/pyxley
def make_ui(datafile):
    # Make a UI
    ui = UILayout("FilterChart", "pyxley", "component_id", filter_style="''")

    df = pd.read_csv(datafile)

    # Read in the data and stack it, so that we can filter on columns
    sf = df.set_index("Date").stack().reset_index()
    sf = sf.rename(columns={"level_1": "Data", 0: "value"})

    # Make a Button
    cols = [c for c in df.columns if c != "Date"]
    btn = SelectButton("Data", cols, "Data", "Steps")

    # Make a FilterFrame and add the button to the UI
    ui.add_filter(btn)

    dm = PlotlyLines([["Date", "value"]], sf, init_params={"Data": "Steps"})
    ui.add_chart(dm)
    return ui
예제 #9
0
파일: plotly.py 프로젝트: ylwb/pyxley
def make_plotly_ui():
    filename = "../examples/metricsgraphics/project/fitbit_data.csv"
    df = pd.read_csv(filename)

    # Make a UI
    ui = UILayout("PyxleyChart")

    # Read in the data and stack it, so that we can filter on columns
    _stack = df.set_index("Date").stack().reset_index()
    _stack = _stack.rename(columns={"level_1": "Data", 0: "value"})

    # Make a Button
    cols = [c for c in df.columns if c != "Date"]
    btn = SelectButton("Data", cols, "Data", "Steps")

    # add the button to the UI
    ui.add_filter(btn)

    init_params = {"Data": "Steps"}
    def get_data():
        args = {}
        for c in init_params:
            if request.args.get(c):
                args[c] = request.args[c]
            else:
                args[c] = init_params[c]
        return jsonify(
            PlotlyAPI.line_plot(
                PlotlyAPI.apply_filters(_stack, args),
                [("Date", "value")],
                "lines+markers",
                {}
            ))
    _plot = PlotlyAPI(
        "plotly_chart",
        "/api/plotly_line_plot/",
        get_data,
        init_params=init_params
    )
    ui.add_chart(_plot)
    return ui
예제 #10
0
    def build_ui(self, save):
        self.ui = UILayout("FilterChart", "./jsx/SimpleChart", "component_id")

        sldr = SliderInput("play_index", 1,
                           int(self.on_field["play_index"].max()),
                           "play_index", "1")
        self.ui.add_filter(sldr)

        # Add a plotly chart
        self.ui.add_chart(add_plotly_chart(self.locations, self.init_params))

        # Add the image panel
        self.ui.add_chart(
            add_image_panel(self.on_field, self.off_field, self.init_params))

        if save:
            self.ui.render_layout(self.mod,
                                  self.static_ + "/layout.js",
                                  alias="Main")
        else:
            self.ui.assign_routes(self.mod)
예제 #11
0
def make_mg_layout(filename):
    # load a dataframe
    df = pd.read_csv(filename)
    # Make a UI
    ui = UILayout("FilterChart")
    # Make a Button
    cols = [c for c in df.columns if c != "Year"]
    btn = SelectButton("Abschlussprüfungsleistungen", cols, "Data",
                       "Abschlussprüfungsleistungen")

    # add the button to the UI
    ui.add_filter(btn)

    # stack the dataframe
    _stack = df.set_index("Year").stack().reset_index()
    _stack = _stack.rename(columns={"level_1": "Data", 0: "value"})

    # Make a Figure, add some settings, make a line plot
    ui.add_chart(
        create_line_plot(_stack,
                         i=0,
                         name="Abschlussprüfungsleistungen",
                         n=3,
                         titel="KPMG Umsätze"))

    here = path.abspath(path.dirname(__file__))

    df1 = pd.read_csv(here + "/file")
    # Make a Button
    cols1 = [c for c in df1.columns if c != "Year"]
    btn1 = SelectButton("Professionals", cols1, "Data", "Professionals")

    # add the button to the UI
    ui.add_filter(btn1)
    _stack1 = df1.set_index("Year").stack().reset_index()
    _stack1 = _stack1.rename(columns={"level_1": "Data", 0: "value"})

    # Make a Figure, add some settings, make a line plot
    ui.add_chart(
        create_line_plot(
            _stack1,
            i=1,
            name="Professionals",
            n=8,
            titel="Employees of KPMG worldwide by position 2010-2017"))

    # stack the dataframe
    df2 = pd.read_csv(here + "/file1")
    cols2 = [c for c in df2.columns if c != "Year"]
    btn2 = SelectButton("Revenue in billion $", cols2, "Data",
                        "Revenue in billion $")
    btn2.__setattr__("margin", 50)
    ui.add_filter(btn2)
    # Make a Button
    _stack2 = df2.set_index("Year").stack().reset_index()
    _stack2 = _stack2.rename(columns={"level_1": "Data", 0: "value"})

    # Make a Figure, add some settings, make a line plot
    ui.add_chart(
        create_line_plot(
            _stack2,
            i=2,
            name="Revenue in billion U.S. dollars",
            n=6,
            titel="Big data and business analytics revenue worldwide 2015-2020"
        ))

    return ui
예제 #12
0
파일: app.py 프로젝트: zofuthan/pyxley
    "./bower_components/react/react.js",
    "./bower_components/react-bootstrap/react-bootstrap.min.js",
    "./bower_components/pyxley/build/pyxley.js",
]

css = [
    "./bower_components/bootstrap/dist/css/bootstrap.min.css",
    "./bower_components/metrics-graphics/dist/metricsgraphics.css",
    "./bower_components/datatables/media/css/jquery.dataTables.min.css",
    "./css/main.css"
]

# Make a UI
ui = UILayout(
    "FilterChart",
    "./static/bower_components/pyxley/build/pyxley.js",
    "component_id",
    filter_style="''")

# Read in the data and stack it, so that we can filter on columns
df = pd.read_csv("fitbit_data.csv")
sf = df.set_index("Date").stack().reset_index()
sf = sf.rename(columns={"level_1": "Data", 0: "value"})

# Make a Button
cols = [c for c in df.columns if c != "Date"]
btn = SelectButton("Data", cols, "Data", "Steps")

# Make a FilterFrame and add the button to the UI
ui.add_filter(btn)
예제 #13
0
파일: app.py 프로젝트: zzygithub/pyxley
from pyxley.charts.mg import LineChart, Figure, ScatterPlot, Histogram
from pyxley.charts.datatables import DataTable
from collections import OrderedDict

parser = argparse.ArgumentParser(description="Flask Template")
parser.add_argument("--env", help="production or local", default="local")
args = parser.parse_args()

TITLE = "Pyxley"

scripts = []

css = ["./css/main.css"]

# Make a UI
ui = UILayout("FilterChart", "pyxley", "component_id", filter_style="''")

# Read in the data and stack it, so that we can filter on columns
df = pd.read_csv("project/fitbit_data.csv")
sf = df.set_index("Date").stack().reset_index()
sf = sf.rename(columns={"level_1": "Data", 0: "value"})

# Make a Button
cols = [c for c in df.columns if c != "Date"]
btn = SelectButton("Data", cols, "Data", "Steps")

# Make a FilterFrame and add the button to the UI
ui.add_filter(btn)

# Make a Figure, add some settings, make a line plot
fig = Figure("/mgchart/", "mychart")
예제 #14
0
파일: app.py 프로젝트: xuanhan863/pyxley
]

css = [
    "./bower_components/bootstrap/dist/css/bootstrap.min.css",
    "./bower_components/nvd3/build/nv.d3.min.css", "./css/main.css"
]

transformer = jsx.JSXTransformer()
jsx_input = "static/jsx/"
jsx_output = "static/js/"

for f in glob.glob(jsx_input + "*.js"):
    transformer.transform(f, js_path=jsx_output + f.split('/')[-1])

# Make a UI
ui = UILayout("RunLayout", "./static/js/custom.js", "component_id")

# Read in the data and stack it, so that we can filter on columns
df = pd.read_csv("./static/formatted_run.csv")

# Make a Button
choices = ["Heart Rate", "Pace", "Distance"]
btn = SelectButton("Data", choices, "Data", "Heart Rate")
ui.add_filter(btn)

# Add our new chart
colors = ["#847c77", "#ff5c61"]
nc = NewChart("Seconds",
              "value",
              "Altitude",
              df,
예제 #15
0
parser.add_argument("--env", help="production or local", default="local")
args = parser.parse_args()

TITLE = "Pyxley"

scripts = [
    "./chartfunc.js"
]

css = [
    "./css/main.css"
]

# Make a UI
ui = UILayout(
    "RunLayout",
    "./jsx/custom",
    "component_id")

# Read in the data and stack it, so that we can filter on columns
df = pd.read_csv("./project/static/formatted_run.csv")

# Make a Button
choices = ["Heart Rate", "Pace", "Distance"]
btn = SelectButton("Data", choices, "Data", "Heart Rate")
ui.add_filter(btn)

# Add our new chart
colors = ["#847c77", "#ff5c61"];
nc = NewChart("Seconds", "value", "Altitude", df,
    init_params={"Data": "Heart Rate"}, colors=colors)
ui.add_chart(nc)
예제 #16
0
파일: buildui.py 프로젝트: snowind/pyxley
def make_table_layout(filename):
    df = get_data(filename)

    ui = UILayout("SimpleChart")
    ui.add_chart(create_datatable(df))
    return ui
예제 #17
0
def uploaded_file(filename):
    extension = get_extension(filename)
    path = os.path.join(app.config['UPLOAD_FOLDER'], extension, filename)
    txt_path = os.path.join(app.config['UPLOAD_FOLDER'], 'txt', filename)
    if extension == "pdf":
        txt_path += '.txt'
        if not os.path.isfile(txt_path):
            #Layout preservation crucial to preserve clues about tabular data
            cmd = "pdftotext -layout %s %s" % (path, txt_path)
            os.system(cmd)

    min_columns = request.args.get('min_columns')
    tables = return_tables(txt_path)

    #Construct histogram
    lines_per_page = 80
    nr_data_rows = []
    for b, t in tables.iteritems():
        e = t['end_line']
        #print b, e
        for l in range(b, e):
            page = l / lines_per_page
            if len(nr_data_rows) <= page:
                nr_data_rows += ([0] * (page - len(nr_data_rows) + 1))
            nr_data_rows[page] += 1
    dr = pd.DataFrame()
    dr['value'] = nr_data_rows
    dr['page'] = range(0, len(dr))

    js_layout = filename + ".js"

    ui_show = UILayout("FilterChart",
                       "../static/bower_components/pyxley/build/pyxley.js",
                       "component_id",
                       filter_style="''")

    if filename in all_charts:
        print "old/update ui", filename
        path_to_fig = '/show/line/' + filename
        #del all_charts[filename]
        #hFig = Figure(path_to_fig, "line")
        #bc = LineChart(dr, hFig, "page", ["page"], "Rows containing Data per Page")
    elif True:
        print "new ui", filename

        # Make a Button
        cols = ["page"]
        btn = SelectButton("Data", cols, "Data", "Data Rows per Page")

        # Make a FilterFrame and add the button to the UI
        ui_show.add_filter(btn)

        # Now make a FilterFrame for the histogram
        path_to_fig = '/show/line/' + filename
        hFig = Figure(path_to_fig, "line")
        hFig.layout.set_size(width=1000, height=300)
        hFig.layout.set_margin(left=80, right=80)
        #hFig.graphics.animate_on_load()

        bc = LineChart(dr, hFig, "page", ["value"],
                       "Rows containing Data per Page")
        ui_show.add_chart(bc)
        all_charts[filename] = bc

        sb = ui_show.render_layout(app, "./static/ug/" + js_layout)

    _scripts = ["ug/" + js_layout]
    notices = ['Extraction Results for ' + filename, 'Ordered by lines']

    dfs = (table_to_df(table).to_html() for table in tables.values())
    headers = []
    for t in tables.values():
        if 'header' in t:
            headers.append(t['header'])
        else:
            headers.append('-')

    line_nrs = [('line %i-%i' % (t['begin_line'], t['end_line']))
                for t in tables.values()]
    #headers = ['aslkdfjas', ' alsdkfjasoedf']

    return render_template('index.html',
                           title=TITLE + ' - ' + filename,
                           base_scripts=scripts,
                           page_scripts=_scripts,
                           css=css,
                           notices=notices,
                           tables=dfs,
                           headers=headers,
                           line_nrs=line_nrs)