OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // | 5 // |
6 // This file contains helper methods to draw the stats timeline graphs. | 6 // This file contains helper methods to draw the stats timeline graphs. |
7 // Each graph represents a series of stats report for a PeerConnection, | 7 // Each graph represents a series of stats report for a PeerConnection, |
8 // e.g. 1234-0-ssrc-abcd123-bytesSent is the graph for the series of bytesSent | 8 // e.g. 1234-0-ssrc-abcd123-bytesSent is the graph for the series of bytesSent |
9 // for ssrc-abcd123 of PeerConnection 0 in process 1234. | 9 // for ssrc-abcd123 of PeerConnection 0 in process 1234. |
10 // The graphs are drawn as CANVAS, grouped per report type per PeerConnection. | 10 // The graphs are drawn as CANVAS, grouped per report type per PeerConnection. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 graphViews[graphViewId] = createStatsGraphView(peerConnectionElement, | 133 graphViews[graphViewId] = createStatsGraphView(peerConnectionElement, |
134 report, | 134 report, |
135 graphType); | 135 graphType); |
136 var date = new Date(stats.timestamp); | 136 var date = new Date(stats.timestamp); |
137 graphViews[graphViewId].setDateRange(date, date); | 137 graphViews[graphViewId].setDateRange(date, date); |
138 } | 138 } |
139 // Adds the new dataSeries to the graphView. We have to do it here to cover | 139 // Adds the new dataSeries to the graphView. We have to do it here to cover |
140 // both the simple and compound graph cases. | 140 // both the simple and compound graph cases. |
141 if (!graphViews[graphViewId].hasDataSeries(dataSeries[finalDataSeriesId])) | 141 if (!graphViews[graphViewId].hasDataSeries(dataSeries[finalDataSeriesId])) |
142 graphViews[graphViewId].addDataSeries(dataSeries[finalDataSeriesId]); | 142 graphViews[graphViewId].addDataSeries(dataSeries[finalDataSeriesId]); |
143 // Draw the stats of the last 5 minutes. | 143 graphViews[graphViewId].updateEndDate(); |
144 graphViews[graphViewId].setDateRange( | |
145 new Date(singleReport.timestamp - 1000 * 60 * 5), | |
146 new Date(singleReport.timestamp)); | |
147 } | 144 } |
148 } | 145 } |
149 | 146 |
150 // Makes sure the TimelineDataSeries with id |dataSeriesId| is created, | 147 // Makes sure the TimelineDataSeries with id |dataSeriesId| is created, |
151 // and adds the new data point to it. | 148 // and adds the new data point to it. |
152 function addDataSeriesPoint(dataSeriesId, time, label, value) { | 149 function addDataSeriesPoint(dataSeriesId, time, label, value) { |
153 if (!dataSeries[dataSeriesId]) { | 150 if (!dataSeries[dataSeriesId]) { |
154 dataSeries[dataSeriesId] = new TimelineDataSeries(); | 151 dataSeries[dataSeriesId] = new TimelineDataSeries(); |
155 if (bweCompoundGraphConfig[label]) { | 152 if (bweCompoundGraphConfig[label]) { |
156 dataSeries[dataSeriesId].setColor( | 153 dataSeries[dataSeriesId].setColor( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 div.graphViewId = | 224 div.graphViewId = |
228 peerConnectionElement.id + '-' + reportName + '-bweCompound'; | 225 peerConnectionElement.id + '-' + reportName + '-bweCompound'; |
229 div.firstChild.addEventListener('click', function(event) { | 226 div.firstChild.addEventListener('click', function(event) { |
230 var target = dataSeries[event.target.parentNode.dataSeriesId]; | 227 var target = dataSeries[event.target.parentNode.dataSeriesId]; |
231 target.show(event.target.checked); | 228 target.show(event.target.checked); |
232 graphViews[event.target.parentNode.graphViewId].repaint(); | 229 graphViews[event.target.parentNode.graphViewId].repaint(); |
233 }); | 230 }); |
234 } | 231 } |
235 return legend; | 232 return legend; |
236 } | 233 } |
OLD | NEW |