예제 #1
0
def callback_input_barchart(topic_selection, element_selection):
    # format bar labels
    inputs = ['live_load', 'environment', 'maintenance_and_preservation']
    formatted_inputs = [
        inp.title().replace("_", " ").replace("And", "&") for inp in inputs
    ]
    labels = [
        "<br>".join(textwrap.wrap(label, width=15))
        for label in formatted_inputs
    ]
    # get project counts and doc_ids
    counts, ids = [], []
    for i in inputs:
        count, id = aggregate.project_count_by_topic(
            topic=i,
            element=element_selection,
            topic_selection=topic_selection)
        counts.append(count)
        ids.append(id)
    # get request parameters
    params = [
        f"type=click_bar&query={i}&index=projects&topic={topic_selection}&element={element_selection}"
        for i in inputs
    ]
    # generate figure
    figure = fig.bar_chart(labels=labels,
                           counts=counts,
                           ids=ids,
                           params=params)
    return figure
예제 #2
0
def callback_performance_barchart(topic_selection, element_selection):
    # format bar labels
    performance = [
        'structural_integrity', 'structural_condition', 'functionality', 'cost'
    ]
    formatted_performance = [
        perf.title().replace("_", " ").replace("And", "&")
        for perf in performance
    ]
    labels = [
        "<br>".join(textwrap.wrap(label, width=15))
        for label in formatted_performance
    ]
    # get project counts and doc_ids
    counts, ids = [], []
    for p in performance:
        count, id = aggregate.project_count_by_topic(
            topic=p,
            element=element_selection,
            topic_selection=topic_selection)
        counts.append(count)
        ids.append(id)
    # get request parameters
    params = [
        f"type=click_bar&query={perf}&index=projects&topic={topic_selection}&element={element_selection}"
        for perf in performance
    ]
    # generate figure
    figure = fig.bar_chart(labels=labels,
                           counts=counts,
                           ids=ids,
                           params=params)
    return figure
예제 #3
0
def callback_attribute_barchart(topic_selection, element_selection):
    # format bar labels
    attributes = [
        'construction_quality', 'design_and_details', 'material_specifications'
    ]
    formatted_attributes = [
        attr.title().replace("_", " ").replace("And", "&")
        for attr in attributes
    ]
    labels = [
        "<br>".join(textwrap.wrap(label, width=15))
        for label in formatted_attributes
    ]
    # get project counts and doc_ids
    counts, ids = [], []
    for attr in attributes:
        count, id = aggregate.project_count_by_topic(
            topic=attr,
            element=element_selection,
            topic_selection=topic_selection)
        counts.append(count)
        ids.append(id)
    # get request parameters
    params = [
        f"type=click_bar&query={attr}&index=projects&topic={topic_selection}&element={element_selection}"
        for attr in attributes
    ]
    # generate figure
    figure = fig.bar_chart(labels=labels,
                           counts=counts,
                           ids=ids,
                           params=params)
    return figure