Browse Source

remove the charting code.

unstable
Craig Oates 4 years ago
parent
commit
5f805a9841
  1. 38
      app/coordinators/art_coordinator.py
  2. 1
      app/main.py
  3. 73
      app/services/charting_services.py

38
app/coordinators/art_coordinator.py

@ -45,41 +45,3 @@ def update_data(arguments):
except Exception:
print("ERROR: [art_coordinator] Unable to update Art data.")
def update_charts(arguments):
directory = arguments.target
v_setting = arguments.verbose
v_out = logging_services.log # Partial function -- for brevity.
ld = data_services.load_json # (load data)
v_out(v_setting, "Beginning to make chart files for Art data.")
try:
creation_dates = ld(f"{directory}/art_creation_dates.json")
year_chart = charting_services.build_creation_date_chart(
creation_dates[0], "By Year")
data_services.store_txt(year_chart[0],
f"{directory}/art_year_script.txt")
data_services.store_txt(year_chart[1],
f"{directory}/art_year_div.txt")
v_out(v_setting, "Created Art By Year charts.")
month_chart = charting_services.build_creation_date_chart(
creation_dates[1], "By Month")
data_services.store_txt(month_chart[0],
f"{directory}/art_month_script.txt")
data_services.store_txt(month_chart[1],
f"{directory}/art_month_div.txt")
v_out(v_setting, "Created Art By Month charts.")
day_chart = charting_services.build_creation_date_chart(
creation_dates[2], "By Day")
data_services.store_txt(day_chart[0],
f"{directory}/art_day_script.txt")
data_services.store_txt(day_chart[1],
f"{directory}art_day_div.txt")
v_out(v_setting, "Created Art By Day charts.")
except Exception as args:
print(f"ERROR: [art_coordinator] {args}")

1
app/main.py

@ -4,7 +4,6 @@ from coordinators import art_coordinator
def main():
args = parser_services.create_args()
art_coordinator.update_data(args)
art_coordinator.update_charts(args)
# update_software_data(args) # Future update.
# update_article_data(args) # Future update.

73
app/services/charting_services.py

@ -1,73 +0,0 @@
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]