| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2014 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <link rel="import" href="/tracing/base/iteration_helpers.html"> | 8 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
| 9 <link rel="import" href="/tracing/base/math.html"> | 9 <link rel="import" href="/tracing/base/math.html"> |
| 10 <link rel="import" href="/tracing/base/raf.html"> | 10 <link rel="import" href="/tracing/base/raf.html"> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 var rightWidth = this.getXForDatum_(data[rightIndex], rightIndex) - | 167 var rightWidth = this.getXForDatum_(data[rightIndex], rightIndex) - |
| 168 this.getXForDatum_(data[index], index); | 168 this.getXForDatum_(data[index], index); |
| 169 return tr.b.Statistics.mean([leftWidth, rightWidth]); | 169 return tr.b.Statistics.mean([leftWidth, rightWidth]); |
| 170 }, | 170 }, |
| 171 | 171 |
| 172 updateSeriesKeys_() { | 172 updateSeriesKeys_() { |
| 173 // Don't clear seriesByKey_; the caller might have put state in it using | 173 // Don't clear seriesByKey_; the caller might have put state in it using |
| 174 // getDataSeries() before setting data. | 174 // getDataSeries() before setting data. |
| 175 this.data_.forEach(function(datum) { | 175 this.data_.forEach(function(datum) { |
| 176 Object.keys(datum).forEach(function(key) { | 176 Object.keys(datum).forEach(function(key) { |
| 177 if (this.isDatumFieldSeries_(key)) | 177 if (this.isDatumFieldSeries_(key)) { |
| 178 this.getDataSeries(key); | 178 this.getDataSeries(key); |
| 179 } |
| 179 }, this); | 180 }, this); |
| 180 }, this); | 181 }, this); |
| 181 }, | 182 }, |
| 182 | 183 |
| 183 isDatumFieldSeries_(fieldName) { | 184 isDatumFieldSeries_(fieldName) { |
| 184 return fieldName !== 'x'; | 185 return fieldName !== 'x'; |
| 185 }, | 186 }, |
| 186 | 187 |
| 187 getXForDatum_(datum, index) { | 188 getXForDatum_(datum, index) { |
| 188 return datum.x; | 189 return datum.x; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 for (var i = 0; i < values.length; i++) { | 316 for (var i = 0; i < values.length; i++) { |
| 316 this.autoDataRange_.addValue(values[i][series]); | 317 this.autoDataRange_.addValue(values[i][series]); |
| 317 } | 318 } |
| 318 } | 319 } |
| 319 | 320 |
| 320 // Choose the closest power of 10, rounded down, as the smallest tick | 321 // Choose the closest power of 10, rounded down, as the smallest tick |
| 321 // to display. | 322 // to display. |
| 322 this.yLogScaleMin_ = undefined; | 323 this.yLogScaleMin_ = undefined; |
| 323 if (this.autoDataRange_.min !== undefined) { | 324 if (this.autoDataRange_.min !== undefined) { |
| 324 var minValue = this.autoDataRange_.min; | 325 var minValue = this.autoDataRange_.min; |
| 325 if (minValue === 0) | 326 if (minValue === 0) { |
| 326 minValue = 1; | 327 minValue = 1; |
| 328 } |
| 327 | 329 |
| 328 var onePowerLess = tr.b.lesserPower(minValue / 10); | 330 var onePowerLess = tr.b.lesserPower(minValue / 10); |
| 329 this.yLogScaleMin_ = onePowerLess; | 331 this.yLogScaleMin_ = onePowerLess; |
| 330 } | 332 } |
| 331 }, | 333 }, |
| 332 | 334 |
| 333 updateYAxis_(yAxis) { | 335 updateYAxis_(yAxis) { |
| 334 yAxis.selectAll('*').remove(); | 336 yAxis.selectAll('*').remove(); |
| 335 yAxis[0][0].style.opacity = 0; | 337 yAxis[0][0].style.opacity = 0; |
| 336 if (this.hideYAxis) return; | 338 if (this.hideYAxis) return; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 var dataBySeriesKey = {}; | 436 var dataBySeriesKey = {}; |
| 435 for (var [key, series] of this.seriesByKey_) { | 437 for (var [key, series] of this.seriesByKey_) { |
| 436 dataBySeriesKey[key] = []; | 438 dataBySeriesKey[key] = []; |
| 437 } | 439 } |
| 438 | 440 |
| 439 this.data_.forEach(function(multiSeriesDatum, index) { | 441 this.data_.forEach(function(multiSeriesDatum, index) { |
| 440 var x = this.getXForDatum_(multiSeriesDatum, index); | 442 var x = this.getXForDatum_(multiSeriesDatum, index); |
| 441 | 443 |
| 442 d3.keys(multiSeriesDatum).forEach(function(seriesKey) { | 444 d3.keys(multiSeriesDatum).forEach(function(seriesKey) { |
| 443 // Skip 'x' - it's not a series | 445 // Skip 'x' - it's not a series |
| 444 if (seriesKey === 'x') | 446 if (seriesKey === 'x') return; |
| 445 return; | |
| 446 | 447 |
| 447 if (multiSeriesDatum[seriesKey] === undefined) | 448 if (multiSeriesDatum[seriesKey] === undefined) return; |
| 448 return; | |
| 449 | 449 |
| 450 if (!this.isDatumFieldSeries_(seriesKey)) | 450 if (!this.isDatumFieldSeries_(seriesKey)) return; |
| 451 return; | |
| 452 | 451 |
| 453 var singleSeriesDatum = {x: x}; | 452 var singleSeriesDatum = {x: x}; |
| 454 singleSeriesDatum[seriesKey] = multiSeriesDatum[seriesKey]; | 453 singleSeriesDatum[seriesKey] = multiSeriesDatum[seriesKey]; |
| 455 dataBySeriesKey[seriesKey].push(singleSeriesDatum); | 454 dataBySeriesKey[seriesKey].push(singleSeriesDatum); |
| 456 }, this); | 455 }, this); |
| 457 }, this); | 456 }, this); |
| 458 | 457 |
| 459 return dataBySeriesKey; | 458 return dataBySeriesKey; |
| 460 }, | 459 }, |
| 461 | 460 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 this.dispatchEvent(dataEvent); | 521 this.dispatchEvent(dataEvent); |
| 523 Polymer.dom(this).classList.remove('updating-brushing-state'); | 522 Polymer.dom(this).classList.remove('updating-brushing-state'); |
| 524 } | 523 } |
| 525 }; | 524 }; |
| 526 | 525 |
| 527 return { | 526 return { |
| 528 ChartBase2D, | 527 ChartBase2D, |
| 529 }; | 528 }; |
| 530 }); | 529 }); |
| 531 </script> | 530 </script> |
| OLD | NEW |