sort BbbStatus before plotting

This commit is contained in:
Daniel Langbein 2020-12-03 16:41:06 +01:00
parent 8a652852a9
commit aa62d31c29
2 changed files with 16 additions and 6 deletions

View File

@ -58,6 +58,17 @@ class BbbStatus(object):
and (TODO) it's CPU utilization and network usage.
"""
pointOfTime: datetime = None
@classmethod
def getKey(bbbStatus):
"""
Returns the date of this object as key for sorting.
:return: Key that can be used for sorting
"""
return bbbStatus.pointOfTime
def __init__(self, meetings: List[Meeting], pointOfTime: datetime = None):
"""
:param meetings: All current meetings

View File

@ -1,8 +1,6 @@
from pathlib import Path
from typing import List
import numpy
import matplotlib.pyplot as plt # TODO
from datetime import datetime
import matplotlib.pyplot as pyplot
from langfingaz import loadData
from langfingaz import parseMeetings
@ -22,6 +20,7 @@ def plotMeetings(dataDir: Path = fileUtil.getProjectBaseDir().joinpath("data")):
dataStr, t = loadData.loadData(file)
meetings: List[Meeting] = parseMeetings.parseMeetingsData(dataStr)
bbbStati.append(parseMeetings.BbbStatus(meetings, t))
sorted(bbbStati, key=BbbStatus.getKey)
image: Path = doPlotMeetings(bbbStati)
print("saved image at " + str(image))
@ -40,10 +39,10 @@ def doPlotMeetings(bbbStati: List[BbbStatus]) -> Path:
voices.append(bbbStatus.voiceParticipantCount)
# Note that even in the OO-style, we use `.pyplot.figure` to create the figure.
_a, _b = plt.subplots() # Create a figure and an axes.
fig: plt.Figure = _a
_a, _b = pyplot.subplots() # Create a figure and an axes.
fig: pyplot.Figure = _a
ax = _b # of type plt.axes.Axes ??
if not (issubclass(type(fig), plt.Figure)):
if not (issubclass(type(fig), pyplot.Figure)):
raise ValueError("expected Figure")
ax.plot(time, participants, label='participants') # Plot some data on the axes.