A Python program which parses the data in the coblob database and transforms into a format which the co-data project can use. One of the main goals of this project is to reduce the load on the CPU in the co-data project.
https://www.craigoates.net/Software/project/17
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.4 KiB
73 lines
2.4 KiB
from bokeh.plotting import figure, output_file, show |
|
from bokeh.embed import components |
|
from bokeh.io import show, output_file |
|
from bokeh.models import ColumnDataSource |
|
from bokeh.palettes import Blues256, Category20c |
|
from bokeh.plotting import figure |
|
from bokeh.transform import factor_cmap, cumsum |
|
|
|
def build_creation_date_chart(data, title): |
|
units = list(data.keys()) |
|
totals = list(data.values()) |
|
|
|
if title == "By Year": |
|
units.reverse() |
|
totals.reverse() |
|
|
|
source = ColumnDataSource(data=dict(units=units, totals=totals)) |
|
|
|
chart = figure(x_range=units, plot_height=350, plot_width=800, |
|
toolbar_location=None, title=title) |
|
|
|
chart.vbar(x='units', top='totals', width=0.9, source=source, |
|
legend_field="units",line_color='white', |
|
fill_color=factor_cmap('units', palette=Blues256, factors=units)) |
|
|
|
chart.title.text_font_size = '18pt' |
|
chart.title.text_font = "intended, sans-serif" |
|
chart.title.text_color = "#424242" |
|
chart.outline_line_color = "#424242" |
|
chart.xgrid.grid_line_color = None |
|
chart.ygrid.grid_line_color = "#424242" |
|
chart.y_range.start = 0 |
|
chart.y_range.end = (max(totals) + 10) |
|
chart.background_fill_color = "#f5f5f6" |
|
chart.border_fill_color = "#f5f5f6" |
|
chart.legend.visible = False |
|
|
|
script, div = components(chart) |
|
|
|
return [script, div] |
|
|
|
def build_sorted_chart(data, title): |
|
d = sorted(data.items()) |
|
totals = list() |
|
units = list() |
|
for i in d: |
|
units.append(i[0]) |
|
totals.append(i[1]) |
|
|
|
source = ColumnDataSource(data=dict(units=units, totals=totals)) |
|
|
|
chart = figure(x_range=units, plot_height=350, plot_width=800, |
|
toolbar_location=None, title=title) |
|
|
|
chart.vbar(x='units', top='totals', width=0.9, source=source, |
|
legend_field="units",line_color='white', |
|
fill_color=factor_cmap('units', palette=Blues256, factors=units)) |
|
|
|
chart.title.text_font_size = '18pt' |
|
chart.title.text_font = "intended, sans-serif" |
|
chart.title.text_color = "#424242" |
|
chart.outline_line_color = "#424242" |
|
chart.xgrid.grid_line_color = None |
|
chart.ygrid.grid_line_color = "#424242" |
|
chart.y_range.start = 0 |
|
chart.y_range.end = (max(totals) + 10) |
|
chart.background_fill_color = "#f5f5f6" |
|
chart.border_fill_color = "#f5f5f6" |
|
chart.legend.visible = False |
|
|
|
script, div = components(chart) |
|
|
|
return [script, div]
|
|
|