blob: e986a74fdc6509e75456e0e94b1e9aafcb30a115 [file] [log] [blame]
tereliusb246a292016-08-24 01:15:251/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 04:47:3111#include "rtc_tools/event_log_visualizer/plot_protobuf.h"
tereliusb246a292016-08-24 01:15:2512
13#include <memory>
14
15namespace webrtc {
tereliusb246a292016-08-24 01:15:2516
17ProtobufPlot::ProtobufPlot() {}
18
19ProtobufPlot::~ProtobufPlot() {}
20
21void ProtobufPlot::Draw() {}
22
skvladf581eb72016-09-07 18:15:3723void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) {
tereliusb246a292016-08-24 01:15:2524 for (size_t i = 0; i < series_list_.size(); i++) {
skvladf581eb72016-09-07 18:15:3725 webrtc::analytics::DataSet* data_set = chart->add_data_sets();
tereliusb246a292016-08-24 01:15:2526 for (const auto& point : series_list_[i].points) {
skvladf581eb72016-09-07 18:15:3727 data_set->add_x_values(point.x);
tereliusb246a292016-08-24 01:15:2528 }
29 for (const auto& point : series_list_[i].points) {
skvladf581eb72016-09-07 18:15:3730 data_set->add_y_values(point.y);
tereliusb246a292016-08-24 01:15:2531 }
32
Bjorn Tereliusb577d5e2017-11-10 15:21:3433 if (series_list_[i].line_style == LineStyle::kBar) {
skvladf581eb72016-09-07 18:15:3734 data_set->set_style(webrtc::analytics::ChartStyle::BAR_CHART);
Bjorn Tereliusb577d5e2017-11-10 15:21:3435 } else if (series_list_[i].line_style == LineStyle::kLine) {
skvladf581eb72016-09-07 18:15:3736 data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
Bjorn Tereliusb577d5e2017-11-10 15:21:3437 } else if (series_list_[i].line_style == LineStyle::kStep) {
terelius77f05802017-02-01 14:34:5338 data_set->set_style(webrtc::analytics::ChartStyle::LINE_STEP_CHART);
Bjorn Tereliusb577d5e2017-11-10 15:21:3439 } else if (series_list_[i].line_style == LineStyle::kNone) {
philipele127e7a2017-03-29 14:28:5340 data_set->set_style(webrtc::analytics::ChartStyle::SCATTER_CHART);
tereliusb246a292016-08-24 01:15:2541 } else {
skvladf581eb72016-09-07 18:15:3742 data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED);
tereliusb246a292016-08-24 01:15:2543 }
44
Bjorn Tereliusb577d5e2017-11-10 15:21:3445 if (series_list_[i].point_style == PointStyle::kHighlight)
46 data_set->set_highlight_points(true);
47
tereliusb246a292016-08-24 01:15:2548 data_set->set_label(series_list_[i].label);
49 }
50
skvladf581eb72016-09-07 18:15:3751 chart->set_xaxis_min(xaxis_min_);
52 chart->set_xaxis_max(xaxis_max_);
53 chart->set_yaxis_min(yaxis_min_);
54 chart->set_yaxis_max(yaxis_max_);
55 chart->set_xaxis_label(xaxis_label_);
56 chart->set_yaxis_label(yaxis_label_);
57 chart->set_title(title_);
tereliusb246a292016-08-24 01:15:2558}
59
60ProtobufPlotCollection::ProtobufPlotCollection() {}
61
62ProtobufPlotCollection::~ProtobufPlotCollection() {}
63
64void ProtobufPlotCollection::Draw() {}
65
66void ProtobufPlotCollection::ExportProtobuf(
skvladf581eb72016-09-07 18:15:3767 webrtc::analytics::ChartCollection* collection) {
tereliusb246a292016-08-24 01:15:2568 for (const auto& plot : plots_) {
69 // TODO(terelius): Ensure that there is no way to insert plots other than
70 // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast
71 // here.
skvladf581eb72016-09-07 18:15:3772 webrtc::analytics::Chart* protobuf_representation
73 = collection->add_charts();
tereliusb246a292016-08-24 01:15:2574 static_cast<ProtobufPlot*>(plot.get())
75 ->ExportProtobuf(protobuf_representation);
76 }
77}
78
79Plot* ProtobufPlotCollection::AppendNewPlot() {
80 Plot* plot = new ProtobufPlot();
81 plots_.push_back(std::unique_ptr<Plot>(plot));
82 return plot;
83}
84
tereliusb246a292016-08-24 01:15:2585} // namespace webrtc