diff --git a/src/shared/Modules/Graph/Graph.cpp b/src/shared/Modules/Graph/Graph.cpp index 2fbb9ce7629c3871d1807f37faec98d1cff5fc29..3b10efda519f64554bf88e4fde6cc680db1f0ba0 100644 --- a/src/shared/Modules/Graph/Graph.cpp +++ b/src/shared/Modules/Graph/Graph.cpp @@ -137,7 +137,7 @@ void Graph::onFilterAdded(const Filter& filter) // Create the graph QCPGraph* graph = plot->addGraph(); graph->setPen( - QPen(QColor(rand() % 255, rand() % 255, rand() % 255), 2)); + QPen(QColor(rand() % 200, rand() % 200, rand() % 200), 2)); graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, 2)); graph->setSelectable(QCP::stNone); graph->setName(field); @@ -171,6 +171,9 @@ void Graph::onFilterAdded(const Filter& filter) message.getField("timestamp").getUnsignedInteger() / 1e6; double y = message.getField(field).getDouble(); + lines[filter].first[field].graph->setName(field + ": " + + QString::number(y)); + // Check if the timestamp resets if (lastTimestamp - 1 > x) onClearClicked(); @@ -257,6 +260,13 @@ void Graph::setupUi() setLayout(outerLayout); + QFont pfont = QApplication::font(); + plot->legend->setIconSize(32, 2 * legendFontSize - 2); + pfont.setPointSize(legendFontSize); + plot->legend->setFont(pfont); + + plot->axisRect()->insetLayout()->setInsetAlignment( + 0, Qt::AlignTop | Qt::AlignLeft); plot->legend->setVisible(true); // Allow user to drag axis ranges with mouse, zoom with mouse wheel and diff --git a/src/shared/Modules/Graph/Graph.h b/src/shared/Modules/Graph/Graph.h index cdc7ceb75260680e1682b98984e9e062c1e30bd2..2b1c64e0d0e1cee08dadf8c451970aac14a1595b 100644 --- a/src/shared/Modules/Graph/Graph.h +++ b/src/shared/Modules/Graph/Graph.h @@ -73,4 +73,6 @@ private: bool stopped = false; bool following = true; + + int legendFontSize = 15; };