mirror of
https://codeberg.org/langfingaz/bbb-status
synced 2025-01-27 04:25:45 +01:00
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
|
from pathlib import Path
|
||
|
from typing import List
|
||
|
import matplotlib.pyplot as plt # TODO
|
||
|
from datetime import datetime
|
||
|
|
||
|
from langfingaz import loadData
|
||
|
from langfingaz import parseMeetings
|
||
|
from langfingaz.parseMeetings import BbbStatus, Meeting
|
||
|
from langfingaz.util import fileUtil
|
||
|
|
||
|
|
||
|
def plotMeetings(folder: Path):
|
||
|
bbbStati: List[BbbStatus] = []
|
||
|
|
||
|
for file in folder.iterdir():
|
||
|
if file.name.endswith(".xml"):
|
||
|
dataStr, t = loadData.loadData(file)
|
||
|
meetings: List[Meeting] = parseMeetings.parseMeetingsData(dataStr)
|
||
|
bbbStati.append(parseMeetings.BbbStatus(meetings, t))
|
||
|
|
||
|
doPlotMeetings(bbbStati)
|
||
|
|
||
|
|
||
|
def doPlotMeetings(bbbStati: List[BbbStatus]):
|
||
|
time = [] # x-axis: time
|
||
|
participants = [] # yAxis (1)
|
||
|
videos = [] # yAxis (2)
|
||
|
voices = [] # yAxis (3)
|
||
|
|
||
|
for bbbStatus in bbbStati:
|
||
|
time.append(bbbStatus.pointOfTime)
|
||
|
participants.append(bbbStatus.participantCount)
|
||
|
videos.append(bbbStatus.videoCount)
|
||
|
voices.append(bbbStatus.voiceParticipantCount)
|
||
|
|
||
|
|
||
|
# Note that even in the OO-style, we use `.pyplot.figure` to create the figure.
|
||
|
fig, ax = plt.subplots() # Create a figure and an axes.
|
||
|
ax.plot(time, participants, label='participants') # Plot some data on the axes.
|
||
|
ax.plot(time, videos, label='video') # Plot more data on the axes...
|
||
|
ax.plot(time, voices, label='voice') # ... and some more.
|
||
|
ax.set_xlabel('time') # Add an x-label to the axes.
|
||
|
ax.set_ylabel('numbers') # Add a y-label to the axes.
|
||
|
ax.set_title("BigBlueButton Statistics") # Add a title to the axes.
|
||
|
ax.legend() # Add a legend.
|
||
|
|
||
|
fig.savefig(fileUtil.setDatetimePrefix(fileUtil.getProjectBaseDir().joinpath("plot"), datetime.now()))
|
||
|
plt.show()
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
plotMeetings(fileUtil.getProjectBaseDir().joinpath("data"))
|