diff options
Diffstat (limited to '')
-rw-r--r-- | src/hist_source.cc | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/hist_source.cc b/src/hist_source.cc index f48ccc1..9881916 100644 --- a/src/hist_source.cc +++ b/src/hist_source.cc @@ -67,9 +67,13 @@ hist_source2::text_value_for_line(textview_curses& tc, std::string& value_out, text_sub_source::line_flags_t flags) { - bucket_t& bucket = this->find_bucket(row); + auto& bucket = this->find_bucket(row); struct tm bucket_tm; + if (this->hs_needs_flush) { + this->end_of_row(); + } + value_out.clear(); if (gmtime_r(&bucket.b_time, &bucket_tm) != nullptr) { fmt::format_to(std::back_inserter(value_out), @@ -92,16 +96,24 @@ hist_source2::text_attrs_for_line(textview_curses& tc, int row, string_attrs_t& value_out) { - bucket_t& bucket = this->find_bucket(row); + auto& bucket = this->find_bucket(row); + auto dim = tc.get_dimensions(); + auto width = dim.second; int left = 0; for (int lpc = 0; lpc < HT__MAX; lpc++) { this->hs_chart.chart_attrs_for_value(tc, left, + width, (const hist_type_t) lpc, bucket.b_values[lpc].hv_value, value_out); } + auto alt_row_index = row % 4; + if (alt_row_index == 2 || alt_row_index == 3) { + value_out.emplace_back(line_range{0, -1}, + VC_ROLE.value(role_t::VCR_ALT_ROW)); + } } void @@ -109,11 +121,7 @@ hist_source2::add_value(time_t row, hist_source2::hist_type_t htype, double value) { - if (row < this->hs_last_row) { - log_error("time mismatch %ld %ld", row, this->hs_last_row); - } - - require(row >= this->hs_last_row); + require_ge(row, this->hs_last_row); row = rounddown(row, this->hs_time_slice); if (row != this->hs_last_row) { @@ -126,14 +134,16 @@ hist_source2::add_value(time_t row, auto& bucket = this->find_bucket(this->hs_last_bucket); bucket.b_time = row; bucket.b_values[htype].hv_value += value; + + this->hs_needs_flush = true; } void hist_source2::init() { - view_colors& vc = view_colors::singleton(); + auto& vc = view_colors::singleton(); - this->hs_chart + this->hs_chart.with_show_state(stacked_bar_chart_base::show_all{}) .with_attrs_for_ident(HT_NORMAL, vc.attrs_for_role(role_t::VCR_TEXT)) .with_attrs_for_ident(HT_WARNING, vc.attrs_for_role(role_t::VCR_WARNING)) @@ -156,16 +166,17 @@ void hist_source2::end_of_row() { if (this->hs_last_bucket >= 0) { - bucket_t& last_bucket = this->find_bucket(this->hs_last_bucket); + auto& last_bucket = this->find_bucket(this->hs_last_bucket); for (int lpc = 0; lpc < HT__MAX; lpc++) { this->hs_chart.add_value((const hist_type_t) lpc, last_bucket.b_values[lpc].hv_value); } + this->hs_chart.next_row(); } } -nonstd::optional<struct timeval> +nonstd::optional<text_time_translator::row_info> hist_source2::time_for_row(vis_line_t row) { if (row < 0 || row > this->hs_line_count) { @@ -174,7 +185,7 @@ hist_source2::time_for_row(vis_line_t row) bucket_t& bucket = this->find_bucket(row); - return timeval{bucket.b_time, 0}; + return row_info{timeval{bucket.b_time, 0}, row}; } hist_source2::bucket_t& |