OLD | NEW |
(Empty) | |
| 1 /* |
| 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 |
| 11 #include "webrtc/tools/event_log_visualizer/plot_base.h" |
| 12 |
| 13 #include <algorithm> |
| 14 |
| 15 #include "webrtc/base/checks.h" |
| 16 |
| 17 namespace webrtc { |
| 18 namespace plotting { |
| 19 |
| 20 void Plot::SetXAxis(float min_value, |
| 21 float max_value, |
| 22 std::string label, |
| 23 float left_margin, |
| 24 float right_margin) { |
| 25 RTC_DCHECK_LE(min_value, max_value); |
| 26 xaxis_min_ = min_value - left_margin * (max_value - min_value); |
| 27 xaxis_max_ = max_value + right_margin * (max_value - min_value); |
| 28 xaxis_label_ = label; |
| 29 } |
| 30 |
| 31 void Plot::SetSuggestedXAxis(float min_value, |
| 32 float max_value, |
| 33 std::string label, |
| 34 float left_margin, |
| 35 float right_margin) { |
| 36 for (const auto& series : series_list_) { |
| 37 for (const auto& point : series.points) { |
| 38 min_value = std::min(min_value, point.x); |
| 39 max_value = std::max(max_value, point.x); |
| 40 } |
| 41 } |
| 42 SetXAxis(min_value, max_value, label, left_margin, right_margin); |
| 43 } |
| 44 |
| 45 void Plot::SetYAxis(float min_value, |
| 46 float max_value, |
| 47 std::string label, |
| 48 float bottom_margin, |
| 49 float top_margin) { |
| 50 RTC_DCHECK_LE(min_value, max_value); |
| 51 yaxis_min_ = min_value - bottom_margin * (max_value - min_value); |
| 52 yaxis_max_ = max_value + top_margin * (max_value - min_value); |
| 53 yaxis_label_ = label; |
| 54 } |
| 55 |
| 56 void Plot::SetSuggestedYAxis(float min_value, |
| 57 float max_value, |
| 58 std::string label, |
| 59 float bottom_margin, |
| 60 float top_margin) { |
| 61 for (const auto& series : series_list_) { |
| 62 for (const auto& point : series.points) { |
| 63 min_value = std::min(min_value, point.y); |
| 64 max_value = std::max(max_value, point.y); |
| 65 } |
| 66 } |
| 67 SetYAxis(min_value, max_value, label, bottom_margin, top_margin); |
| 68 } |
| 69 |
| 70 void Plot::SetTitle(std::string title) { |
| 71 title_ = title; |
| 72 } |
| 73 |
| 74 } // namespace plotting |
| 75 } // namespace webrtc |
OLD | NEW |