Fixrd gragh
This commit is contained in:
parent
5a0a5585f7
commit
f76fb13d8a
@ -27,7 +27,7 @@ def update_data():
|
|||||||
temp = table.getNumber("Temperature", -1)
|
temp = table.getNumber("Temperature", -1)
|
||||||
mem = table.getNumber("Memory", -1)
|
mem = table.getNumber("Memory", -1)
|
||||||
|
|
||||||
status_label.config(text=f"CPU: {cpu}%, Temp: {temp}C Mem: {mem} MB")
|
status_label.config(text=f"CPU: {cpu}%, Temp: {temp}°C Mem: {mem} MB")
|
||||||
root.after(1000, update_data)
|
root.after(1000, update_data)
|
||||||
|
|
||||||
update_data()
|
update_data()
|
||||||
@ -67,28 +67,27 @@ def add_data():
|
|||||||
ax2.clear()
|
ax2.clear()
|
||||||
ax3.clear()
|
ax3.clear()
|
||||||
|
|
||||||
# Plot CPU
|
# Only show last 10 points
|
||||||
ax1.plot(x_data, cpu_data, marker='o', linestyle='-')
|
x = x_data[-25:]
|
||||||
|
cpu = cpu_data[-25:]
|
||||||
|
temp = temp_data[-25:]
|
||||||
|
mem = mem_data[-25:]
|
||||||
|
|
||||||
|
ax1.plot(x, cpu, marker='o', linestyle='-')
|
||||||
ax1.set_title("CPU Usage (%)")
|
ax1.set_title("CPU Usage (%)")
|
||||||
ax1.tick_params(axis='x', rotation=45)
|
ax1.tick_params(axis='x', rotation=45)
|
||||||
|
|
||||||
# Plot Temperature
|
ax2.plot(x, temp, marker='o', linestyle='-', color='orange')
|
||||||
ax2.plot(x_data, temp_data, marker='o', linestyle='-', color='orange')
|
|
||||||
ax2.set_title("Temperature (°C)")
|
ax2.set_title("Temperature (°C)")
|
||||||
ax2.tick_params(axis='x', rotation=45)
|
ax2.tick_params(axis='x', rotation=45)
|
||||||
|
|
||||||
# Plot Memory
|
ax3.plot(x, mem, marker='o', linestyle='-', color='green')
|
||||||
ax3.plot(x_data, mem_data, marker='o', linestyle='-', color='green')
|
|
||||||
ax3.set_title("Memory Usage (MB)")
|
ax3.set_title("Memory Usage (MB)")
|
||||||
ax3.set_xlabel("Time")
|
ax3.set_xlabel("Time")
|
||||||
ax3.tick_params(axis='x', rotation=45)
|
ax3.tick_params(axis='x', rotation=45)
|
||||||
|
|
||||||
# Redraw canvas
|
|
||||||
canvas.draw()
|
canvas.draw()
|
||||||
|
|
||||||
# Schedule next update
|
|
||||||
graph_window.after(2000, add_data)
|
graph_window.after(2000, add_data)
|
||||||
|
|
||||||
add_data()
|
add_data() # Start graph updating loop
|
||||||
|
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
Loading…
Reference in New Issue
Block a user