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

Unified Diff: tracing/tracing/base/unit.html

Issue 2341623002: Display Histograms in value-set-table-cells. (Closed)
Patch Set: . Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/base/statistics_test.html ('k') | tracing/tracing/ui/base/bar_chart.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/base/unit.html
diff --git a/tracing/tracing/base/unit.html b/tracing/tracing/base/unit.html
index d7b9d45838562f1b4dd9b44a3bfc909121c42b8a..c260f55fe26a4a0082d5569f852e6deb383eef88 100644
--- a/tracing/tracing/base/unit.html
+++ b/tracing/tracing/base/unit.html
@@ -57,6 +57,31 @@ tr.exportTo('tr.b', function() {
return this.jsonName;
},
+ get unitString() {
+ // TODO(benjhayden): Refactor with format() and test.
+ var formatSpec = this.formatSpec_;
+ if (typeof formatSpec === 'function')
+ formatSpec = formatSpec();
+ if (!formatSpec.unit) {
+ return '';
+ }
+
+ var unitString = '';
+ var unitPrefix = formatSpec.unitPrefix;
+ if (unitPrefix !== undefined) {
+ var selectedPrefix;
+ if (unitPrefix instanceof Array) {
+ selectedPrefix = unitPrefix[0];
+ } else {
+ selectedPrefix = unitPrefix;
+ }
+ unitString += selectedPrefix.symbol || '';
+ }
+ unitString += formatSpec.unit;
+
+ return unitString;
+ },
+
format: function(value, opt_context) {
var context = opt_context || {};
var formatSpec = this.formatSpec_;
@@ -224,21 +249,23 @@ tr.exportTo('tr.b', function() {
definedUnits.forEach(u => u.baseUnit = baseUnit);
};
- Unit.defineUnitVariant_ = function(params, isDelta, improvementDirection) {
- var nameSuffix = isDelta ? 'Delta' : '';
+ Unit.nameSuffixForImprovementDirection = function(improvementDirection) {
switch (improvementDirection) {
case ImprovementDirection.DONT_CARE:
- break;
+ return '';
case ImprovementDirection.BIGGER_IS_BETTER:
- nameSuffix += '_biggerIsBetter';
- break;
+ return '_biggerIsBetter';
case ImprovementDirection.SMALLER_IS_BETTER:
- nameSuffix += '_smallerIsBetter';
- break;
+ return '_smallerIsBetter';
default:
throw new Error(
'Unknown improvement direction: ' + improvementDirection);
}
+ };
+
+ Unit.defineUnitVariant_ = function(params, isDelta, improvementDirection) {
+ var nameSuffix = isDelta ? 'Delta' : '';
+ nameSuffix += Unit.nameSuffixForImprovementDirection(improvementDirection);
var unitName = params.baseUnitName + nameSuffix;
var jsonName = params.baseJsonName + nameSuffix;
@@ -340,6 +367,16 @@ tr.exportTo('tr.b', function() {
}
});
+ Unit.define({
+ baseUnitName: 'sigma',
+ baseJsonName: 'sigma',
+ formatSpec: {
+ unit: String.fromCharCode(963),
+ minimumFractionDigits: 1,
+ maximumFractionDigits: 1
+ }
+ });
+
return {
ImprovementDirection: ImprovementDirection,
Unit: Unit
« no previous file with comments | « tracing/tracing/base/statistics_test.html ('k') | tracing/tracing/ui/base/bar_chart.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698