mirror of
https://github.com/cuigh/swirl
synced 2024-12-31 16:23:13 +00:00
Improve chart unit formatting
This commit is contained in:
parent
536dc59cc6
commit
a10053168a
@ -1203,6 +1203,12 @@ var Swirl;
|
||||
return value.toFixed(1) + "%";
|
||||
case "percent:1":
|
||||
return (value * 100).toFixed(1) + "%";
|
||||
case "time:ns":
|
||||
return value + 'ns';
|
||||
case "time:µs":
|
||||
return value.toFixed(2) + 'µs';
|
||||
case "time:ms":
|
||||
return value.toFixed(2) + 'ms';
|
||||
case "time:s":
|
||||
if (value < 1) {
|
||||
return (value * 1000).toFixed(0) + 'ms';
|
||||
@ -1210,6 +1216,14 @@ var Swirl;
|
||||
else {
|
||||
return value.toFixed(2) + 's';
|
||||
}
|
||||
case "time:m":
|
||||
return value.toFixed(2) + 'm';
|
||||
case "time:h":
|
||||
return value.toFixed(2) + 'h';
|
||||
case "time:d":
|
||||
return value.toFixed(2) + 'd';
|
||||
case "size:bits":
|
||||
value = value / 8;
|
||||
case "size:bytes":
|
||||
if (value < 1024) {
|
||||
return value.toString() + 'B';
|
||||
@ -1223,6 +1237,12 @@ var Swirl;
|
||||
else {
|
||||
return (value / 1073741824).toFixed(2) + 'G';
|
||||
}
|
||||
case "size:kilobytes":
|
||||
return value.toFixed(2) + 'K';
|
||||
case "size:megabytes":
|
||||
return value.toFixed(2) + 'M';
|
||||
case "size:gigabytes":
|
||||
return value.toFixed(2) + 'G';
|
||||
default:
|
||||
return value.toFixed(2);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -104,12 +104,26 @@ namespace Swirl.Core {
|
||||
return value.toFixed(1) + "%";
|
||||
case "percent:1":
|
||||
return (value * 100).toFixed(1) + "%";
|
||||
case "time:ns":
|
||||
return value + 'ns';
|
||||
case "time:µs":
|
||||
return value.toFixed(2) + 'µs';
|
||||
case "time:ms":
|
||||
return value.toFixed(2) + 'ms';
|
||||
case "time:s":
|
||||
if (value < 1) { // 1
|
||||
return (value * 1000).toFixed(0) + 'ms';
|
||||
} else {
|
||||
return value.toFixed(2) + 's';
|
||||
}
|
||||
case "time:m":
|
||||
return value.toFixed(2) + 'm';
|
||||
case "time:h":
|
||||
return value.toFixed(2) + 'h';
|
||||
case "time:d":
|
||||
return value.toFixed(2) + 'd';
|
||||
case "size:bits":
|
||||
value = value / 8; // fall-through
|
||||
case "size:bytes":
|
||||
if (value < 1024) { // 1K
|
||||
return value.toString() + 'B';
|
||||
@ -120,6 +134,12 @@ namespace Swirl.Core {
|
||||
} else {
|
||||
return (value / 1073741824).toFixed(2) + 'G';
|
||||
}
|
||||
case "size:kilobytes":
|
||||
return value.toFixed(2) + 'K';
|
||||
case "size:megabytes":
|
||||
return value.toFixed(2) + 'M';
|
||||
case "size:gigabytes":
|
||||
return value.toFixed(2) + 'G';
|
||||
default:
|
||||
return value.toFixed(2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user