Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistics: add avg interval #979

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion plotjuggler_app/statistics_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void StatisticsDialog::update(PJ::Range range)
for (const auto& info : _parent->curveList())
{
Statistics stat;
double start_time;
double end_time;
const auto ts = info.curve->data();

bool first = true;
Expand All @@ -64,17 +66,22 @@ void StatisticsDialog::update(PJ::Range range)
stat.count++;
if (first)
{
start_time = p.x();
end_time = p.x();
stat.min = p.y();
stat.max = p.y();
first = false;
}
else
{
start_time = std::min(start_time, p.x());
end_time = std::max(end_time, p.x());
stat.min = std::min(stat.min, p.y());
stat.max = std::max(stat.max, p.y());
}
stat.mean_tot += p.y();
}
stat.mean_interval = (end_time - start_time) / double(stat.count);
statistics[info.curve->title().text()] = stat;
}

Expand All @@ -84,13 +91,14 @@ void StatisticsDialog::update(PJ::Range range)
{
const auto& stat = it.second;

std::array<QString, 5> row_values;
std::array<QString, 6> row_values;
row_values[0] = it.first;
row_values[1] = QString::number(stat.count);
row_values[2] = QString::number(stat.min, 'f');
row_values[3] = QString::number(stat.max, 'f');
double mean = stat.mean_tot / double(stat.count);
row_values[4] = QString::number(mean, 'f');
row_values[5] = QString::number(stat.mean_interval, 'f');

for (size_t col = 0; col < row_values.size(); col++)
{
Expand Down
1 change: 1 addition & 0 deletions plotjuggler_app/statistics_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Statistics
double min = 0;
double max = 0;
double mean_tot = 0;
double mean_interval = 0;
};

class StatisticsDialog : public QDialog
Expand Down
5 changes: 5 additions & 0 deletions plotjuggler_app/statistics_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<string>Average</string>
</property>
</column>
<column>
<property name="text">
<string>Avg Interval</string>
</property>
</column>
</widget>
</item>
<item>
Expand Down