From aa62d31c2905536ad6f84a0570c1f1716265b712 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Thu, 3 Dec 2020 16:41:06 +0100 Subject: [PATCH] sort BbbStatus before plotting --- src/langfingaz/parseMeetings.py | 11 +++++++++++ src/langfingaz/plotMeetings.py | 11 +++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/langfingaz/parseMeetings.py b/src/langfingaz/parseMeetings.py index ba02eda..afe6278 100644 --- a/src/langfingaz/parseMeetings.py +++ b/src/langfingaz/parseMeetings.py @@ -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 diff --git a/src/langfingaz/plotMeetings.py b/src/langfingaz/plotMeetings.py index 9e91219..23ee3d0 100644 --- a/src/langfingaz/plotMeetings.py +++ b/src/langfingaz/plotMeetings.py @@ -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.