Deprecate inheritance hierachy of plot formats in event_log_visualizer.

Instead add separate printing functions for each plot format in the base class.

Bug: webrtc:11566
Change-Id: I8adfc983b4e8a66c477de4022c2d97b6975d7e5c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176563
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Andrey Logvin <landrey@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31496}
This commit is contained in:
Bjorn Terelius
2020-06-09 17:17:21 +02:00
committed by Commit Bot
parent e366045375
commit 8a89b5bc0d
8 changed files with 272 additions and 236 deletions

View File

@ -24,49 +24,7 @@ ProtobufPlot::~ProtobufPlot() {}
void ProtobufPlot::Draw() {}
void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) {
for (size_t i = 0; i < series_list_.size(); i++) {
webrtc::analytics::DataSet* data_set = chart->add_data_sets();
for (const auto& point : series_list_[i].points) {
data_set->add_x_values(point.x);
}
for (const auto& point : series_list_[i].points) {
data_set->add_y_values(point.y);
}
if (series_list_[i].line_style == LineStyle::kBar) {
data_set->set_style(webrtc::analytics::ChartStyle::BAR_CHART);
} else if (series_list_[i].line_style == LineStyle::kLine) {
data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
} else if (series_list_[i].line_style == LineStyle::kStep) {
data_set->set_style(webrtc::analytics::ChartStyle::LINE_STEP_CHART);
} else if (series_list_[i].line_style == LineStyle::kNone) {
data_set->set_style(webrtc::analytics::ChartStyle::SCATTER_CHART);
} else {
data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED);
}
if (series_list_[i].point_style == PointStyle::kHighlight)
data_set->set_highlight_points(true);
data_set->set_label(series_list_[i].label);
}
chart->set_xaxis_min(xaxis_min_);
chart->set_xaxis_max(xaxis_max_);
chart->set_yaxis_min(yaxis_min_);
chart->set_yaxis_max(yaxis_max_);
chart->set_xaxis_label(xaxis_label_);
chart->set_yaxis_label(yaxis_label_);
chart->set_title(title_);
chart->set_id(id_);
for (const auto& kv : yaxis_tick_labels_) {
webrtc::analytics::TickLabel* tick = chart->add_yaxis_tick_labels();
tick->set_value(kv.first);
tick->set_label(kv.second);
}
}
ProtobufPlotCollection::ProtobufPlotCollection() {}
@ -78,19 +36,6 @@ void ProtobufPlotCollection::Draw() {
std::cout << collection.SerializeAsString();
}
void ProtobufPlotCollection::ExportProtobuf(
webrtc::analytics::ChartCollection* collection) {
for (const auto& plot : plots_) {
// TODO(terelius): Ensure that there is no way to insert plots other than
// ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast
// here.
webrtc::analytics::Chart* protobuf_representation =
collection->add_charts();
static_cast<ProtobufPlot*>(plot.get())
->ExportProtobuf(protobuf_representation);
}
}
Plot* ProtobufPlotCollection::AppendNewPlot() {
Plot* plot = new ProtobufPlot();
plots_.push_back(std::unique_ptr<Plot>(plot));