diff --git a/webrtc/tools/event_log_visualizer/analyzer.cc b/webrtc/tools/event_log_visualizer/analyzer.cc index a45ec770f0..2c340127de 100644 --- a/webrtc/tools/event_log_visualizer/analyzer.cc +++ b/webrtc/tools/event_log_visualizer/analyzer.cc @@ -555,12 +555,11 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries( TimeSeries time_series; time_series.label = label_prefix + " " + GetStreamName(stream_id); - time_series.style = LINE_GRAPH; + time_series.style = LINE_STEP_GRAPH; for (size_t i = 0; i < packet_stream.size(); i++) { float x = static_cast(packet_stream[i].timestamp - begin_time_) / 1000000; - time_series.points.emplace_back(x, i); time_series.points.emplace_back(x, i + 1); } @@ -893,9 +892,8 @@ void EventLogAnalyzer::CreateTotalBitrateGraph( plot->series_list_.back().points.emplace_back(x, y); } plot->series_list_.back().label = "Loss-based estimate"; - plot->series_list_.back().style = LINE_GRAPH; + plot->series_list_.back().style = LINE_STEP_GRAPH; } - plot->series_list_.back().style = LINE_GRAPH; plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin); if (desired_direction == webrtc::PacketDirection::kIncomingPacket) { diff --git a/webrtc/tools/event_log_visualizer/chart.proto b/webrtc/tools/event_log_visualizer/chart.proto index 685b4bd762..e005391c9f 100644 --- a/webrtc/tools/event_log_visualizer/chart.proto +++ b/webrtc/tools/event_log_visualizer/chart.proto @@ -9,6 +9,7 @@ message ChartStyle { UNDEFINED = 0; LINE_CHART = 1; BAR_CHART = 2; + LINE_STEP_CHART = 3; } } @@ -33,4 +34,4 @@ message Chart { message ChartCollection { repeated Chart charts = 1; -} \ No newline at end of file +} diff --git a/webrtc/tools/event_log_visualizer/plot_base.h b/webrtc/tools/event_log_visualizer/plot_base.h index 5546271132..e2bec2df78 100644 --- a/webrtc/tools/event_log_visualizer/plot_base.h +++ b/webrtc/tools/event_log_visualizer/plot_base.h @@ -18,7 +18,7 @@ namespace webrtc { namespace plotting { -enum PlotStyle { LINE_GRAPH, LINE_DOT_GRAPH, BAR_GRAPH }; +enum PlotStyle { LINE_GRAPH, LINE_DOT_GRAPH, BAR_GRAPH, LINE_STEP_GRAPH }; struct TimeSeriesPoint { TimeSeriesPoint(float x, float y) : x(x), y(y) {} diff --git a/webrtc/tools/event_log_visualizer/plot_protobuf.cc b/webrtc/tools/event_log_visualizer/plot_protobuf.cc index e6e1adc703..6e4558579b 100644 --- a/webrtc/tools/event_log_visualizer/plot_protobuf.cc +++ b/webrtc/tools/event_log_visualizer/plot_protobuf.cc @@ -38,6 +38,8 @@ void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) { } else if (series_list_[i].style == LINE_DOT_GRAPH) { data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART); data_set->set_highlight_points(true); + } else if (series_list_[i].style == LINE_STEP_GRAPH) { + data_set->set_style(webrtc::analytics::ChartStyle::LINE_STEP_CHART); } else { data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED); } diff --git a/webrtc/tools/event_log_visualizer/plot_python.cc b/webrtc/tools/event_log_visualizer/plot_python.cc index d4583444ef..c91efe32c7 100644 --- a/webrtc/tools/event_log_visualizer/plot_python.cc +++ b/webrtc/tools/event_log_visualizer/plot_python.cc @@ -65,6 +65,16 @@ void PythonPlot::Draw() { "plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\', " "marker='.')\n", i, i, i, series_list_[i].label.c_str()); + } else if (series_list_[i].style == LINE_STEP_GRAPH) { + // Draw lines from (x[0],y[0]) to (x[1],y[0]) to (x[1],y[1]) and so on + // to illustrate the "steps". This can be expressed by duplicating all + // elements except the first in x and the last in y. + printf("x%zu = [v for dup in x%zu for v in [dup, dup]]\n", i, i); + printf("y%zu = [v for dup in y%zu for v in [dup, dup]]\n", i, i); + printf( + "plt.plot(x%zu[1:], y%zu[:-1], color=rgb_colors[%zu], " + "label=\'%s\')\n", + i, i, i, series_list_[i].label.c_str()); } else { printf("raise Exception(\"Unknown graph type\")\n"); }