@@ -37,12 +37,13 @@ namespace o2::quality_control_modules::common
3737QualityTask::QualityTrendGraph::QualityTrendGraph (std::string name, std::string title) : TCanvas(name.c_str(), title.c_str())
3838{
3939 SetGridy (1 );
40- mGraphHist = std::make_unique<TGraph>(0 );
4140
4241 mGraph = std::make_unique<TGraph>(0 );
42+ mGraph ->SetTitle (title.c_str ());
4343 mGraph ->SetMarkerStyle (kCircle );
44- mGraph ->SetTitle (fmt::format (" {};time;quality " , title).c_str ());
44+ mGraph ->SetTitle (fmt::format (" {};time;" , title).c_str ());
4545
46+ // add labels in the middle of the vertical axis bins
4647 mLabels [0 ] = std::make_unique<TText>(0.09 , 0.1 + 0.8 / 8.0 , " Null" );
4748 mLabels [1 ] = std::make_unique<TText>(0.09 , 0.1 + 3.0 * 0.8 / 8.0 , " Bad" );
4849 mLabels [2 ] = std::make_unique<TText>(0.09 , 0.1 + 5.0 * 0.8 / 8.0 , " Medium" );
@@ -59,6 +60,10 @@ QualityTask::QualityTrendGraph::QualityTrendGraph(std::string name, std::string
5960
6061void QualityTask::QualityTrendGraph::update (uint64_t time, Quality q)
6162{
63+ Clear ();
64+ cd ();
65+
66+ // set the position of the point based on the value of the quality flag
6267 float val = 0.5 ;
6368 if (q == Quality::Bad) {
6469 val = 1.5 ;
@@ -69,33 +74,21 @@ void QualityTask::QualityTrendGraph::update(uint64_t time, Quality q)
6974 if (q == Quality::Good) {
7075 val = 3.5 ;
7176 }
72- // add new point both the the main graph and to the dummy one used for the axis
73- mGraph ->AddPoint (time, val);
74- mGraphHist ->AddPoint (time, 0 );
7577
76- Clear ();
77- cd ( );
78+ // add a new point to the graph
79+ mGraph -> AddPoint (time, val );
7880
79- // draw axis
80- mGraphHist ->Draw (" A" );
81-
82- // configure and beautify axis
83- auto hAxis = mGraphHist ->GetHistogram ();
84- hAxis->SetTitle (GetTitle ());
85- hAxis->GetXaxis ()->SetTimeDisplay (1 );
86- hAxis->GetXaxis ()->SetNdivisions (505 );
87- hAxis->GetXaxis ()->SetTimeOffset (0.0 );
88- hAxis->GetXaxis ()->SetTimeFormat (" %Y-%m-%d %H:%M" );
89- hAxis->GetYaxis ()->SetTitle (" " );
90- hAxis->GetYaxis ()->SetTickLength (0.0 );
91- hAxis->GetYaxis ()->SetLabelSize (0.0 );
92- hAxis->GetYaxis ()->SetNdivisions (3 , kFALSE );
93- hAxis->SetMinimum (0 );
94- hAxis->SetMaximum (4 );
95- hAxis->Draw (" AXIS" );
96-
97- // draw main graph
98- mGraph ->Draw (" PL,SAME" );
81+ // draw the graph and format the axes
82+ mGraph ->Draw (" APL" );
83+ mGraph ->GetXaxis ()->SetTimeDisplay (1 );
84+ mGraph ->GetXaxis ()->SetNdivisions (505 );
85+ mGraph ->GetXaxis ()->SetTimeOffset (0.0 );
86+ mGraph ->GetXaxis ()->SetTimeFormat (" %Y-%m-%d %H:%M" );
87+ mGraph ->GetYaxis ()->SetTickLength (0.0 );
88+ mGraph ->GetYaxis ()->SetLabelSize (0.0 );
89+ mGraph ->GetYaxis ()->SetNdivisions (3 , kFALSE );
90+ mGraph ->SetMinimum (0 );
91+ mGraph ->SetMaximum (4 );
9992
10093 // draw labels for vertical axis
10194 for (auto & l : mLabels ) {
0 commit comments