Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: webrtc/tools/event_log_visualizer/plot_base.h

Issue 2179223003: Convenience functions to set axis properties in visualization tool. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments from Danil Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_
11 #define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ 11 #define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_
12 12
13 #include <algorithm>
danilchap 2016/07/27 08:39:07 with implementation moved to .cc this include can
terelius 2016/07/28 15:23:04 Done.
13 #include <memory> 14 #include <memory>
14 #include <string> 15 #include <string>
15 #include <utility> 16 #include <utility>
16 #include <vector> 17 #include <vector>
17 18
19 #include "webrtc/base/checks.h"
danilchap 2016/07/27 08:39:07 and this one too
terelius 2016/07/28 15:23:04 Done.
20
18 namespace webrtc { 21 namespace webrtc {
19 namespace plotting { 22 namespace plotting {
20 23
21 enum PlotStyle { LINE_GRAPH, BAR_GRAPH }; 24 enum PlotStyle { LINE_GRAPH, BAR_GRAPH };
22 25
23 struct TimeSeriesPoint { 26 struct TimeSeriesPoint {
24 TimeSeriesPoint(float x, float y) : x(x), y(y) {} 27 TimeSeriesPoint(float x, float y) : x(x), y(y) {}
25 float x; 28 float x;
26 float y; 29 float y;
27 }; 30 };
28 31
29 struct TimeSeries { 32 struct TimeSeries {
30 TimeSeries() = default; 33 TimeSeries() = default;
31 TimeSeries(TimeSeries&& other) 34 TimeSeries(TimeSeries&& other)
32 : label(std::move(other.label)), 35 : label(std::move(other.label)),
33 style(other.style), 36 style(other.style),
34 points(std::move(other.points)) {} 37 points(std::move(other.points)) {}
35 TimeSeries& operator=(TimeSeries&& other) { 38 TimeSeries& operator=(TimeSeries&& other) {
36 label = std::move(other.label); 39 label = std::move(other.label);
37 style = other.style; 40 style = other.style;
38 points = std::move(other.points); 41 points = std::move(other.points);
39 return *this; 42 return *this;
40 } 43 }
41 44
42 std::string label; 45 std::string label;
43 PlotStyle style; 46 PlotStyle style;
44 std::vector<TimeSeriesPoint> points; 47 std::vector<TimeSeriesPoint> points;
45 }; 48 };
46 49
47 // This is basically a struct that represents of a general graph, with axes, 50 // A container that represents a general graph, with axes, title and one or
48 // title and one or more data series. We make it a class only to document that 51 // more data series. A subclass should define the output format by overriding
49 // it also specifies an interface for the draw()ing objects. 52 // the Draw() method.
50 class Plot { 53 class Plot {
51 public: 54 public:
52 virtual ~Plot() {} 55 virtual ~Plot() {}
53 virtual void draw() = 0;
54 56
55 float xaxis_min; 57 // Overloaded to draw the plot.
56 float xaxis_max; 58 virtual void Draw() = 0;
57 std::string xaxis_label; 59
58 float yaxis_min; 60 // Sets the lower x-axis limit to min_value (if left_margin == 0).
59 float yaxis_max; 61 // Sets the upper x-axis limit to max_value (if right_margin == 0).
60 std::string yaxis_label; 62 // The margins are measured as fractions of the interval
61 std::vector<TimeSeries> series; 63 // (max_value - min_value) and are added to either side of the plot.
62 std::string title; 64 void SetXAxis(float min_value,
65 float max_value,
66 std::string label,
67 float left_margin = 0,
68 float right_margin = 0);
69
70 // Sets the lower and upper x-axis limits based on min_value and max_value,
71 // but modified such that all points in the data series can be represented
72 // on the x-axis. The margins are measured as fractions of the range of
73 // x-values and are added to either side of the plot.
74 void SetSuggestedXAxis(float min_value,
75 float max_value,
76 std::string label,
77 float left_margin = 0,
78 float right_margin = 0);
79
80 // Sets the lower y-axis limit to min_value (if bottom_margin == 0).
81 // Sets the upper y-axis limit to max_value (if top_margin == 0).
82 // The margins are measured as fractions of the interval
83 // (max_value - min_value) and are added to either side of the plot.
84 void SetYAxis(float min_value,
85 float max_value,
86 std::string label,
87 float bottom_margin = 0,
88 float top_margin = 0);
89
90 // Sets the lower and upper y-axis limits based on min_value and max_value,
91 // but modified such that all points in the data series can be represented
92 // on the y-axis. The margins are measured as fractions of the range of
93 // y-values and are added to either side of the plot.
94 void SetSuggestedYAxis(float min_value,
95 float max_value,
96 std::string label,
97 float bottom_margin = 0,
98 float top_margin = 0);
99
100 // Sets the title of the plot.
101 void SetTitle(std::string title);
102
103 std::vector<TimeSeries> series_list_;
104
105 protected:
106 float xaxis_min_;
107 float xaxis_max_;
108 std::string xaxis_label_;
109 float yaxis_min_;
110 float yaxis_max_;
111 std::string yaxis_label_;
112 std::string title_;
63 }; 113 };
64 114
65 class PlotCollection { 115 class PlotCollection {
66 public: 116 public:
67 virtual ~PlotCollection() {} 117 virtual ~PlotCollection() {}
68 virtual void draw() = 0; 118 virtual void Draw() = 0;
69 virtual Plot* append_new_plot() = 0; 119 virtual Plot* AppendNewPlot() = 0;
70 120
71 protected: 121 protected:
72 std::vector<std::unique_ptr<Plot> > plots; 122 std::vector<std::unique_ptr<Plot> > plots_;
73 }; 123 };
74 124
75 } // namespace plotting 125 } // namespace plotting
76 } // namespace webrtc 126 } // namespace webrtc
77 127
78 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_ 128 #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_BASE_H_
OLDNEW
« no previous file with comments | « webrtc/tools/event_log_visualizer/generate_timeseries.cc ('k') | webrtc/tools/event_log_visualizer/plot_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698