Chromium Code Reviews| 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 #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ | 10 #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 enum PlotStyle { LINE_GRAPH, LINE_DOT_GRAPH, BAR_GRAPH, LINE_STEP_GRAPH }; | 21 enum PlotStyle { LINE_GRAPH, LINE_DOT_GRAPH, BAR_GRAPH, LINE_STEP_GRAPH }; |
| 22 | 22 |
| 23 struct TimeSeriesPoint { | 23 struct TimeSeriesPoint { |
| 24 TimeSeriesPoint(float x, float y) : x(x), y(y) {} | 24 TimeSeriesPoint(float x, float y) : x(x), y(y) {} |
| 25 float x; | 25 float x; |
| 26 float y; | 26 float y; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 struct TimeSeries { | 29 struct TimeSeries { |
| 30 TimeSeries() = default; | 30 TimeSeries() = default; |
| 31 TimeSeries(const char* label, PlotStyle style) | |
| 32 : label(label), style(style), points() {} | |
| 33 TimeSeries(const std::string& label, PlotStyle style) | |
| 34 : label(label), style(style), points() {} | |
| 31 TimeSeries(TimeSeries&& other) | 35 TimeSeries(TimeSeries&& other) |
| 32 : label(std::move(other.label)), | 36 : label(std::move(other.label)), |
| 33 style(other.style), | 37 style(other.style), |
| 34 points(std::move(other.points)) {} | 38 points(std::move(other.points)) {} |
| 35 TimeSeries& operator=(TimeSeries&& other) { | 39 TimeSeries& operator=(TimeSeries&& other) { |
| 36 label = std::move(other.label); | 40 label = std::move(other.label); |
| 37 style = other.style; | 41 style = other.style; |
| 38 points = std::move(other.points); | 42 points = std::move(other.points); |
| 39 return *this; | 43 return *this; |
| 40 } | 44 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // y-values and are added to either side of the plot. | 94 // y-values and are added to either side of the plot. |
| 91 void SetSuggestedYAxis(float min_value, | 95 void SetSuggestedYAxis(float min_value, |
| 92 float max_value, | 96 float max_value, |
| 93 std::string label, | 97 std::string label, |
| 94 float bottom_margin = 0, | 98 float bottom_margin = 0, |
| 95 float top_margin = 0); | 99 float top_margin = 0); |
| 96 | 100 |
| 97 // Sets the title of the plot. | 101 // Sets the title of the plot. |
| 98 void SetTitle(std::string title); | 102 void SetTitle(std::string title); |
| 99 | 103 |
| 104 // Add a new TimeSeries to the plot. | |
| 105 TimeSeries* AddTimeSeries(const char* label, PlotStyle style) { | |
|
michaelt
2017/03/13 15:36:42
Shouldn't we code this in the cc file ?
terelius
2017/03/14 17:13:59
Yes. Done.
| |
| 106 series_list_.emplace_back(label, style); | |
| 107 return &series_list_.back(); | |
| 108 } | |
| 109 | |
| 110 // Add a new TimeSeries to the plot. | |
| 111 TimeSeries* AddTimeSeries(const std::string& label, PlotStyle style) { | |
| 112 series_list_.emplace_back(label, style); | |
| 113 return &series_list_.back(); | |
| 114 } | |
| 115 | |
| 100 std::vector<TimeSeries> series_list_; | 116 std::vector<TimeSeries> series_list_; |
| 101 | 117 |
| 102 protected: | 118 protected: |
| 103 float xaxis_min_; | 119 float xaxis_min_; |
| 104 float xaxis_max_; | 120 float xaxis_max_; |
| 105 std::string xaxis_label_; | 121 std::string xaxis_label_; |
| 106 float yaxis_min_; | 122 float yaxis_min_; |
| 107 float yaxis_max_; | 123 float yaxis_max_; |
| 108 std::string yaxis_label_; | 124 std::string yaxis_label_; |
| 109 std::string title_; | 125 std::string title_; |
| 110 }; | 126 }; |
| 111 | 127 |
| 112 class PlotCollection { | 128 class PlotCollection { |
| 113 public: | 129 public: |
| 114 virtual ~PlotCollection() {} | 130 virtual ~PlotCollection() {} |
| 115 virtual void Draw() = 0; | 131 virtual void Draw() = 0; |
| 116 virtual Plot* AppendNewPlot() = 0; | 132 virtual Plot* AppendNewPlot() = 0; |
| 117 | 133 |
| 118 protected: | 134 protected: |
| 119 std::vector<std::unique_ptr<Plot> > plots_; | 135 std::vector<std::unique_ptr<Plot> > plots_; |
| 120 }; | 136 }; |
| 121 | 137 |
| 122 } // namespace plotting | 138 } // namespace plotting |
| 123 } // namespace webrtc | 139 } // namespace webrtc |
| 124 | 140 |
| 125 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ | 141 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ |
| OLD | NEW |