update readme
This commit is contained in:
370
src/ui/graph.py
370
src/ui/graph.py
@@ -3,7 +3,7 @@ from PyQt6 import QtWidgets
|
||||
|
||||
|
||||
class Graph:
|
||||
def __init__(self, data: dict | list):
|
||||
def __init__(self, data: list):
|
||||
self.xlist = []
|
||||
if isinstance(data, dict):
|
||||
self.xlist += data[list(data.keys())[0]]["x"]
|
||||
@@ -21,7 +21,7 @@ class Graph:
|
||||
stringaxis_x.setTicks([xdict.items()])
|
||||
self.graph = pg.PlotWidget(axisItems={"bottom": stringaxis_x})
|
||||
# self.graph.("Zeitschriftennutzung")
|
||||
self.graph.setLabel("left", "Anzahl der potentiellen Nutzungen")
|
||||
self.graph.setLabel("left", "Anzahl der Aktivierungen")
|
||||
self.graph.setLabel("bottom", "Datum")
|
||||
|
||||
self.graph.addLegend()
|
||||
@@ -30,12 +30,8 @@ class Graph:
|
||||
self.plot_lines(data)
|
||||
else:
|
||||
self.plot_line(data)
|
||||
# remove duplicate x values
|
||||
|
||||
self.graph.showGrid(x=True, y=True)
|
||||
# set max and min values for x and y axis
|
||||
|
||||
# self.graph.resize(800, 600)
|
||||
|
||||
def plot_line(self, data, color="r"):
|
||||
line_label = list(data.keys())[0]
|
||||
@@ -43,9 +39,6 @@ class Graph:
|
||||
self.xlist += x_data
|
||||
x_data = [date.split("2024-")[1] for date in x_data]
|
||||
xdict = dict(enumerate(x_data))
|
||||
# stringaxis_x = pg.AxisItem(orientation="bottom")
|
||||
# stringaxis_x.setTicks([xdict.items()])
|
||||
# self.graph.getAxis("bottom").setTicks([xdict.items()])
|
||||
global_xdict = self.xdict
|
||||
|
||||
# remove all x values that are not in the xdict
|
||||
@@ -75,362 +68,3 @@ def launch(data):
|
||||
graph.graph.show()
|
||||
app.exec()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
data = [
|
||||
{
|
||||
"t^1": {
|
||||
"x": [
|
||||
"2024-04-04",
|
||||
"2024-04-05",
|
||||
"2024-04-06",
|
||||
"2024-04-07",
|
||||
"2024-04-08",
|
||||
"2024-04-09",
|
||||
"2024-04-10",
|
||||
"2024-04-11",
|
||||
"2024-04-12",
|
||||
"2024-04-13",
|
||||
"2024-04-14",
|
||||
"2024-04-15",
|
||||
"2024-04-16",
|
||||
"2024-04-17",
|
||||
"2024-04-18",
|
||||
"2024-04-19",
|
||||
"2024-04-20",
|
||||
"2024-04-21",
|
||||
"2024-04-22",
|
||||
"2024-04-23",
|
||||
"2024-04-24",
|
||||
"2024-04-25",
|
||||
"2024-04-26",
|
||||
"2024-04-27",
|
||||
"2024-04-28",
|
||||
"2024-04-29",
|
||||
"2024-04-30",
|
||||
"2024-05-01",
|
||||
"2024-05-02",
|
||||
"2024-05-03",
|
||||
"2024-05-04",
|
||||
"2024-05-05",
|
||||
"2024-05-06",
|
||||
"2024-05-07",
|
||||
"2024-05-08",
|
||||
"2024-05-09",
|
||||
"2024-05-10",
|
||||
"2024-05-11",
|
||||
"2024-05-12",
|
||||
"2024-05-13",
|
||||
"2024-05-14",
|
||||
"2024-05-15",
|
||||
"2024-05-16",
|
||||
"2024-05-17",
|
||||
"2024-05-18",
|
||||
"2024-05-19",
|
||||
"2024-05-20",
|
||||
"2024-05-21",
|
||||
"2024-05-22",
|
||||
"2024-05-23",
|
||||
"2024-05-24",
|
||||
"2024-05-25",
|
||||
"2024-05-26",
|
||||
"2024-05-27",
|
||||
"2024-05-28",
|
||||
],
|
||||
"y": [
|
||||
0,
|
||||
9.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
3.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"t^2": {
|
||||
"x": [
|
||||
"2024-04-04",
|
||||
"2024-04-05",
|
||||
"2024-04-06",
|
||||
"2024-04-07",
|
||||
"2024-04-08",
|
||||
"2024-04-09",
|
||||
"2024-04-10",
|
||||
"2024-04-11",
|
||||
"2024-04-12",
|
||||
"2024-04-13",
|
||||
"2024-04-14",
|
||||
"2024-04-15",
|
||||
"2024-04-16",
|
||||
"2024-04-17",
|
||||
"2024-04-18",
|
||||
"2024-04-19",
|
||||
"2024-04-20",
|
||||
"2024-04-21",
|
||||
"2024-04-22",
|
||||
"2024-04-23",
|
||||
"2024-04-24",
|
||||
"2024-04-25",
|
||||
"2024-04-26",
|
||||
"2024-04-27",
|
||||
"2024-04-28",
|
||||
"2024-04-29",
|
||||
"2024-04-30",
|
||||
"2024-05-01",
|
||||
"2024-05-02",
|
||||
"2024-05-03",
|
||||
"2024-05-04",
|
||||
"2024-05-05",
|
||||
"2024-05-06",
|
||||
"2024-05-07",
|
||||
"2024-05-08",
|
||||
"2024-05-09",
|
||||
"2024-05-10",
|
||||
"2024-05-11",
|
||||
"2024-05-12",
|
||||
"2024-05-13",
|
||||
"2024-05-14",
|
||||
"2024-05-15",
|
||||
"2024-05-16",
|
||||
"2024-05-17",
|
||||
"2024-05-18",
|
||||
"2024-05-19",
|
||||
"2024-05-20",
|
||||
"2024-05-21",
|
||||
"2024-05-22",
|
||||
"2024-05-23",
|
||||
"2024-05-24",
|
||||
"2024-05-25",
|
||||
"2024-05-26",
|
||||
"2024-05-27",
|
||||
"2024-05-28",
|
||||
],
|
||||
"y": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4.0,
|
||||
0,
|
||||
0,
|
||||
6.0,
|
||||
0,
|
||||
2.0,
|
||||
2.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2.0,
|
||||
2.0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"t^3": {
|
||||
"x": [
|
||||
"2024-04-04",
|
||||
"2024-04-05",
|
||||
"2024-04-06",
|
||||
"2024-04-07",
|
||||
"2024-04-08",
|
||||
"2024-04-09",
|
||||
"2024-04-10",
|
||||
"2024-04-11",
|
||||
"2024-04-12",
|
||||
"2024-04-13",
|
||||
"2024-04-14",
|
||||
"2024-04-15",
|
||||
"2024-04-16",
|
||||
"2024-04-17",
|
||||
"2024-04-18",
|
||||
"2024-04-19",
|
||||
"2024-04-20",
|
||||
"2024-04-21",
|
||||
"2024-04-22",
|
||||
"2024-04-23",
|
||||
"2024-04-24",
|
||||
"2024-04-25",
|
||||
"2024-04-26",
|
||||
"2024-04-27",
|
||||
"2024-04-28",
|
||||
"2024-04-29",
|
||||
"2024-04-30",
|
||||
"2024-05-01",
|
||||
"2024-05-02",
|
||||
"2024-05-03",
|
||||
"2024-05-04",
|
||||
"2024-05-05",
|
||||
"2024-05-06",
|
||||
"2024-05-07",
|
||||
"2024-05-08",
|
||||
"2024-05-09",
|
||||
"2024-05-10",
|
||||
"2024-05-11",
|
||||
"2024-05-12",
|
||||
"2024-05-13",
|
||||
"2024-05-14",
|
||||
"2024-05-15",
|
||||
"2024-05-16",
|
||||
"2024-05-17",
|
||||
"2024-05-18",
|
||||
"2024-05-19",
|
||||
"2024-05-20",
|
||||
"2024-05-21",
|
||||
"2024-05-22",
|
||||
"2024-05-23",
|
||||
"2024-05-24",
|
||||
"2024-05-25",
|
||||
"2024-05-26",
|
||||
"2024-05-27",
|
||||
"2024-05-28",
|
||||
],
|
||||
"y": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
}
|
||||
},
|
||||
]
|
||||
launch(data)
|
||||
|
||||
Reference in New Issue
Block a user