2020-11-28 21:11:21 +01:00
|
|
|
from pathlib import Path
|
|
|
|
from typing import List
|
2020-12-03 16:41:06 +01:00
|
|
|
import matplotlib.pyplot as pyplot
|
2020-11-28 21:11:21 +01:00
|
|
|
|
|
|
|
from langfingaz import loadData
|
|
|
|
from langfingaz import parseMeetings
|
|
|
|
from langfingaz.parseMeetings import BbbStatus, Meeting
|
|
|
|
from langfingaz.util import fileUtil
|
|
|
|
|
|
|
|
|
2020-11-29 15:39:11 +01:00
|
|
|
def getDefaultPlotFolder() -> Path:
|
|
|
|
return fileUtil.getProjectBaseDir().joinpath("plot")
|
|
|
|
|
|
|
|
|
|
|
|
def plotMeetings(dataDir: Path = fileUtil.getProjectBaseDir().joinpath("data")):
|
2020-11-28 21:11:21 +01:00
|
|
|
bbbStati: List[BbbStatus] = []
|
|
|
|
|
2020-11-29 15:39:11 +01:00
|
|
|
for file in dataDir.iterdir():
|
2020-11-28 21:11:21 +01:00
|
|
|
if file.name.endswith(".xml"):
|
|
|
|
dataStr, t = loadData.loadData(file)
|
|
|
|
meetings: List[Meeting] = parseMeetings.parseMeetingsData(dataStr)
|
|
|
|
bbbStati.append(parseMeetings.BbbStatus(meetings, t))
|
2020-12-03 16:41:06 +01:00
|
|
|
sorted(bbbStati, key=BbbStatus.getKey)
|
2020-11-28 21:11:21 +01:00
|
|
|
|
2020-11-29 15:39:11 +01:00
|
|
|
image: Path = doPlotMeetings(bbbStati)
|
|
|
|
print("saved image at " + str(image))
|
2020-11-28 21:11:21 +01:00
|
|
|
|
|
|
|
|
2020-11-29 15:39:11 +01:00
|
|
|
def doPlotMeetings(bbbStati: List[BbbStatus]) -> Path:
|
|
|
|
time = [] # x-axis: time
|
|
|
|
participants = [] # yAxis (1)
|
|
|
|
videos = [] # yAxis (2)
|
|
|
|
voices = [] # yAxis (3)
|
2020-11-28 21:11:21 +01:00
|
|
|
|
|
|
|
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.
|
2020-12-03 16:41:06 +01:00
|
|
|
_a, _b = pyplot.subplots() # Create a figure and an axes.
|
|
|
|
fig: pyplot.Figure = _a
|
2020-12-03 16:30:29 +01:00
|
|
|
ax = _b # of type plt.axes.Axes ??
|
2020-12-03 16:41:06 +01:00
|
|
|
if not (issubclass(type(fig), pyplot.Figure)):
|
2020-12-03 16:30:29 +01:00
|
|
|
raise ValueError("expected Figure")
|
|
|
|
|
2020-11-28 21:11:21 +01:00
|
|
|
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.
|
|
|
|
|
2020-11-29 15:39:11 +01:00
|
|
|
image: Path = getDefaultPlotFolder().joinpath(
|
|
|
|
"{}_until_{}".format(fileUtil.asString(time[0]), fileUtil.asString(time[-1]))
|
|
|
|
)
|
|
|
|
fig.savefig(image)
|
|
|
|
# plt.show()
|
|
|
|
|
|
|
|
return image
|
2020-11-28 21:11:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-11-29 15:39:11 +01:00
|
|
|
plotMeetings()
|