Chromium Code Reviews| Index: tracing/tracing/value/convert_chart_json.html |
| diff --git a/tracing/tracing/value/convert_chart_json.html b/tracing/tracing/value/convert_chart_json.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7111c8f687647751117bd27e8525b2f284e88dd1 |
| --- /dev/null |
| +++ b/tracing/tracing/value/convert_chart_json.html |
| @@ -0,0 +1,49 @@ |
| +<!DOCTYPE html> |
|
nednguyen
2016/11/03 21:10:24
nits: name this chart_json_converter.html
I thin
benjhayden
2016/11/09 23:48:55
Done.
|
| +<!-- |
| +Copyright 2016 The Chromium Authors. All rights reserved. |
| +Use of this source code is governed by a BSD-style license that can be |
| +found in the LICENSE file. |
| +--> |
| + |
| +<link rel="import" href="/tracing/value/histogram.html"> |
| + |
| +<script> |
| +'use strict'; |
| +tr.exportTo('tr.v', function() { |
| + /** |
| + * Parses Values from |charts|, converts them to Histograms, and adds those to |
| + * |histograms|. |
| + * |
| + * @param {!Array.<!Object>} charts |
| + * @param {!tr.v.HistogramSet} histograms |
| + */ |
| + function convertChartJson(charts, histograms) { |
| + tr.b.iterItems(charts.charts, (name, pageValues) => { |
| + tr.b.iterItems(pageValues, (storyName, value) => { |
| + var unit = tr.b.Unit.byName.unitlessNumber; |
|
nednguyen
2016/11/03 21:10:24
this doesn't seem right. ChartJson can contain exi
benjhayden
2016/11/09 23:48:55
Yes, sorry, I hadn't finished the unit mapping. PT
|
| + var hist = new tr.v.Histogram(name, unit, |
| + tr.v.HistogramBinBoundaries.SINGULAR); |
| + histograms.addHistogram(hist); |
| + |
| + var iterationInfo = new tr.v.d.IterationInfo(); |
| + iterationInfo.addInfo({ |
| + storyDisplayName: storyName, |
| + }); |
| + iterationInfo.addToValue(hist); |
| + |
| + if (value.type === 'list_of_scalar_values') { |
| + for (var sample of value.values) { |
| + hist.addSample(sample); |
| + } |
| + } else if (value.type === 'scalar') { |
| + hist.addSample(value.value); |
| + } |
| + }); |
| + }); |
| + } |
| + |
| + return { |
| + convertChartJson, |
| + }; |
| +}); |
| +</script> |