Store min, max values in plot.

This commit is contained in:
Bartosz Taudul 2017-10-13 15:32:59 +02:00
parent 5deb1c51dd
commit 591fbdf75a
2 changed files with 7 additions and 1 deletions

View File

@ -854,12 +854,16 @@ void View::InsertPlot( PlotData* plot, int64_t time, double val )
{
if( plot->data.empty() || plot->data.back().time < time )
{
plot->min = val;
plot->max = val;
plot->data.emplace_back( PlotItem { time, val } );
}
else
{
if( plot->min > val ) plot->min = val;
else if( plot->max < val ) plot->max = val;
auto it = std::lower_bound( plot->data.begin(), plot->data.end(), time, [] ( const auto& lhs, const auto& rhs ) { return lhs.time < rhs; } );
it = plot->data.insert( it, PlotItem { time, val } );
plot->data.insert( it, PlotItem { time, val } );
}
}

View File

@ -71,6 +71,8 @@ private:
struct PlotData
{
uint64_t name;
double min;
double max;
std::vector<PlotItem> data;
};