MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / graph_a_ping

Function graph_a_ping

DemoPrograms/Demo_Matplotlib_Ping_Graph_Large.py:40–62  ·  view source on GitHub ↗
(ping_time)

Source from the content-addressed store, hash-verified

38
39
40def graph_a_ping(ping_time):
41 # graphs are global so that can be retained across multiple calls to this callback
42 global g_my_globals
43
44 #===================== Do the ping =====================#
45 # Insert your code to run a ping
46 # ping_time = random.randint(0, 100)
47 #===================== Store current ping in historical array =====================#
48 g_my_globals.ping_x_array.append(len(g_my_globals.ping_x_array))
49 g_my_globals.ping_y_array.append(ping_time)
50 # ===================== Only graph last 100 items =====================#
51 if len(g_my_globals.ping_x_array) > 100:
52 x_array = g_my_globals.ping_x_array[-100:]
53 y_array = g_my_globals.ping_y_array[-100:]
54 else:
55 x_array = g_my_globals.ping_x_array
56 y_array = g_my_globals.ping_y_array
57
58 # ===================== Call graphinc functions =====================#
59 # clear before graphing
60 g_my_globals.axis_ping.clear()
61 # graph the ping values
62 g_my_globals.axis_ping.plot(x_array, y_array)
63
64# ================================================================================
65# Function: Set graph titles and Axis labels

Callers 1

mainFunction · 0.85

Calls 1

plotMethod · 0.45

Tested by

no test coverage detected