| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/tools/event_log_visualizer/plot_protobuf.h" | 11 #include "webrtc/tools/event_log_visualizer/plot_protobuf.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 namespace webrtc { | 15 namespace webrtc { |
| 16 namespace plotting { | 16 namespace plotting { |
| 17 | 17 |
| 18 ProtobufPlot::ProtobufPlot() {} | 18 ProtobufPlot::ProtobufPlot() {} |
| 19 | 19 |
| 20 ProtobufPlot::~ProtobufPlot() {} | 20 ProtobufPlot::~ProtobufPlot() {} |
| 21 | 21 |
| 22 void ProtobufPlot::Draw() {} | 22 void ProtobufPlot::Draw() {} |
| 23 | 23 |
| 24 void ProtobufPlot::ExportProtobuf(protobuf_plot::Plot* plot) { | 24 void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) { |
| 25 for (size_t i = 0; i < series_list_.size(); i++) { | 25 for (size_t i = 0; i < series_list_.size(); i++) { |
| 26 protobuf_plot::DataSet* data_set = plot->add_data_sets(); | 26 webrtc::analytics::DataSet* data_set = chart->add_data_sets(); |
| 27 for (const auto& point : series_list_[i].points) { | 27 for (const auto& point : series_list_[i].points) { |
| 28 data_set->add_xvalues(point.x); | 28 data_set->add_x_values(point.x); |
| 29 } | 29 } |
| 30 for (const auto& point : series_list_[i].points) { | 30 for (const auto& point : series_list_[i].points) { |
| 31 data_set->add_yvalues(point.y); | 31 data_set->add_y_values(point.y); |
| 32 } | 32 } |
| 33 | 33 |
| 34 if (series_list_[i].style == BAR_GRAPH) { | 34 if (series_list_[i].style == BAR_GRAPH) { |
| 35 data_set->set_style(protobuf_plot::BAR_GRAPH); | 35 data_set->set_style(webrtc::analytics::ChartStyle::BAR_CHART); |
| 36 } else if (series_list_[i].style == LINE_GRAPH) { | 36 } else if (series_list_[i].style == LINE_GRAPH) { |
| 37 data_set->set_style(protobuf_plot::LINE_GRAPH); | 37 data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART); |
| 38 } else if (series_list_[i].style == LINE_DOT_GRAPH) { | 38 } else if (series_list_[i].style == LINE_DOT_GRAPH) { |
| 39 data_set->set_style(protobuf_plot::LINE_DOT_GRAPH); | 39 data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART); |
| 40 data_set->set_highlight_points(true); |
| 40 } else { | 41 } else { |
| 41 data_set->set_style(protobuf_plot::UNDEFINED); | 42 data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED); |
| 42 } | 43 } |
| 43 | 44 |
| 44 data_set->set_label(series_list_[i].label); | 45 data_set->set_label(series_list_[i].label); |
| 45 } | 46 } |
| 46 | 47 |
| 47 plot->set_xaxis_min(xaxis_min_); | 48 chart->set_xaxis_min(xaxis_min_); |
| 48 plot->set_xaxis_max(xaxis_max_); | 49 chart->set_xaxis_max(xaxis_max_); |
| 49 plot->set_yaxis_min(yaxis_min_); | 50 chart->set_yaxis_min(yaxis_min_); |
| 50 plot->set_yaxis_max(yaxis_max_); | 51 chart->set_yaxis_max(yaxis_max_); |
| 51 plot->set_xaxis_label(xaxis_label_); | 52 chart->set_xaxis_label(xaxis_label_); |
| 52 plot->set_yaxis_label(yaxis_label_); | 53 chart->set_yaxis_label(yaxis_label_); |
| 53 plot->set_title(title_); | 54 chart->set_title(title_); |
| 54 } | 55 } |
| 55 | 56 |
| 56 ProtobufPlotCollection::ProtobufPlotCollection() {} | 57 ProtobufPlotCollection::ProtobufPlotCollection() {} |
| 57 | 58 |
| 58 ProtobufPlotCollection::~ProtobufPlotCollection() {} | 59 ProtobufPlotCollection::~ProtobufPlotCollection() {} |
| 59 | 60 |
| 60 void ProtobufPlotCollection::Draw() {} | 61 void ProtobufPlotCollection::Draw() {} |
| 61 | 62 |
| 62 void ProtobufPlotCollection::ExportProtobuf( | 63 void ProtobufPlotCollection::ExportProtobuf( |
| 63 protobuf_plot::PlotCollection* collection) { | 64 webrtc::analytics::ChartCollection* collection) { |
| 64 for (const auto& plot : plots_) { | 65 for (const auto& plot : plots_) { |
| 65 // TODO(terelius): Ensure that there is no way to insert plots other than | 66 // TODO(terelius): Ensure that there is no way to insert plots other than |
| 66 // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast | 67 // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast |
| 67 // here. | 68 // here. |
| 68 protobuf_plot::Plot* protobuf_representation = collection->add_plots(); | 69 webrtc::analytics::Chart* protobuf_representation |
| 70 = collection->add_charts(); |
| 69 static_cast<ProtobufPlot*>(plot.get()) | 71 static_cast<ProtobufPlot*>(plot.get()) |
| 70 ->ExportProtobuf(protobuf_representation); | 72 ->ExportProtobuf(protobuf_representation); |
| 71 } | 73 } |
| 72 } | 74 } |
| 73 | 75 |
| 74 Plot* ProtobufPlotCollection::AppendNewPlot() { | 76 Plot* ProtobufPlotCollection::AppendNewPlot() { |
| 75 Plot* plot = new ProtobufPlot(); | 77 Plot* plot = new ProtobufPlot(); |
| 76 plots_.push_back(std::unique_ptr<Plot>(plot)); | 78 plots_.push_back(std::unique_ptr<Plot>(plot)); |
| 77 return plot; | 79 return plot; |
| 78 } | 80 } |
| 79 | 81 |
| 80 } // namespace plotting | 82 } // namespace plotting |
| 81 } // namespace webrtc | 83 } // namespace webrtc |
| OLD | NEW |