NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import plotly.graph_objects as go
from plotly.subplots import make_subplots
from core.logger import logger


def make_pie_chart(data):
text_values = [f"({str(value)})" for value in data['values']]
logger.info(f"text_values {text_values}")
trace = go.Pie(
labels=data['labels'],
values=data['values'],
textinfo='percent+value',
# Display only the values (counts) on the chart # Display only the label on the chart
text=text_values, # Display custom text for each slice
)

fig = make_subplots(rows=1, cols=1)

fig.add_trace(trace)

fig.update_layout(
title=dict(
text="PPE Infractions",
font=dict(size=12, color='black'), # Increase font size, set color to black, and make it bold
x=0.5, # Center the title horizontally
y=0.87 # Adjust the y-coordinate to position the title vertically
),
showlegend=True,
legend=dict(font=dict(size=14), orientation='h', x=0.32, y=-0.1),
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)'
)

fig.update_layout(
autosize=True,
)

fig.write_image("templates/pie.png")


def make_line_chart(data):
x_data = []
y1 = []
# y2 = []
# y3 = []
# y4 = []
sorted_data = dict(sorted(data.items(), key=lambda x: x[0]))
logger.info(f"Sorted Data is {sorted_data}")
for key, value in sorted_data.items():
x_data.append(key)
y1.append(value['total_people_detected'])
# y2.append(value['ppe_infractions'])
# y3.append(value['MISSING HELMET'])
# y4.append(value['MISSING VEST'])

fig = go.Figure()

# Line 1
fig.add_trace(go.Scatter(
x=x_data,
y=y1,
mode='lines+markers',
name='Total People Detected', # This names the line, and will appear in the legend
marker=dict(size=10),
line=dict(width=2)
))
# Update layout for aesthetics
fig.update_layout(
xaxis_title='Days of the Week',
yaxis_title='Quantity',
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)',
width=1200,
xaxis=dict(
title='Days of the Week',
rangemode='tozero', # Set x-axis to start from 0
),
yaxis=dict(
title='Quantity',
rangemode='tozero', # Set y-axis to start from 0
),
)
fig.write_image("templates/line.png")
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.