from app.config import Config from app import db import matplotlib matplotlib.use("Agg") from app.routes.dashboard import plot_to_base64 import matplotlib.pyplot as plt import io import base64 from app.utils.plot_utils import plot_to_base64 # Subcontractor models import from app.models.trench_excavation_model import TrenchExcavation # Client models import # from app.models.tr_ex_client_model import TrenchExcavationClient class DashboardService: # bar chart def bar_chart_of_tr_ex(): categories = ["Soft Murum", "Hard Murum", "Soft Rock", "Hard Rock"] values = [120, 80, 150, 60] tr = TrenchExcavation() record = TrenchExcavation.query.first() print(" RA_Bill_No::",record["RA_Bill_No"]) totals = tr.excavation_category_sums() # print(totals["Soft_Murum_Total"]) # print(totals["Hard_Rock_Total"]) plt.figure() plt.bar(categories, values) plt.title("Trench Excavation Work Category Report") plt.xlabel("Excavation category") plt.ylabel("Quantity") return plot_to_base64(plt) def subcontractor_dash(): return True