### More standard precision interpretation.

```Rather than overload the meaning of precision to bias the selection of the SI
prefix, always use the standard SI prefix, and use the precision in the same
sense as with fixed digits: the number of digits after the decimal point.```
parent 621558c2
 ... ... @@ -7475,8 +7475,8 @@ var match = d3_format_re.exec(format); match.shift(); if (match === "s") { var prefix = d3.formatPrefix(Math.max(abs(range), abs(range)) * (match ? Math.pow(10, -match.substring(1)) : 1)); match = "." + d3_scale_linearPrecision(prefix.scale(range)), match = "f"; var prefix = d3.formatPrefix(Math.max(abs(range), abs(range))); match = match ? "f" : "r"; format = d3.format(match.join("")); return function(d) { return format(prefix.scale(d)) + prefix.symbol; ... ... @@ -7501,7 +7501,7 @@ } function d3_scale_linearFormatPrecision(type, range) { var p = d3_scale_linearPrecision(range); return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(Math.abs(range), Math.abs(range)))) + +(type !== "e") : p - (type === "%") * 2; return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range), abs(range)))) + +(type !== "e") : p - (type === "%") * 2; } d3.scale.log = function() { return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); ... ...
This source diff could not be displayed because it is too large. You can view the blob instead.
 ... ... @@ -121,8 +121,8 @@ function d3_scale_linearTickFormat(domain, m, format) { var match = d3_format_re.exec(format); match.shift(); if (match === "s") { var prefix = d3.formatPrefix(Math.max(abs(range), abs(range)) * (match ? Math.pow(10, -match.substring(1)) : 1)); match = "." + d3_scale_linearPrecision(prefix.scale(range)), match = "f"; var prefix = d3.formatPrefix(Math.max(abs(range), abs(range))); match = match ? "f" : "r"; format = d3.format(match.join("")); return function(d) { return format(prefix.scale(d)) + prefix.symbol; ... ... @@ -152,6 +152,6 @@ function d3_scale_linearPrecision(value) { function d3_scale_linearFormatPrecision(type, range) { var p = d3_scale_linearPrecision(range); return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(Math.abs(range), Math.abs(range)))) + +(type !== "e") ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range), abs(range)))) + +(type !== "e") : p - (type === "%") * 2; }
 ... ... @@ -223,8 +223,9 @@ suite.addBatch({ }, "applies fixed-scale SI-prefix notation": function(d3) { var x = d3.scale.linear().domain([0, 1e6]); assert.deepEqual(x.ticks(10).map(x.tickFormat(10, "s")), ["0.0M", "0.1M", "0.2M", "0.3M", "0.4M", "0.5M", "0.6M", "0.7M", "0.8M", "0.9M", "1.0M"]); assert.deepEqual(x.ticks(10).map(x.tickFormat(10, "+\$s")), ["+\$0.0M", "+\$0.1M", "+\$0.2M", "+\$0.3M", "+\$0.4M", "+\$0.5M", "+\$0.6M", "+\$0.7M", "+\$0.8M", "+\$0.9M", "+\$1.0M"]); assert.deepEqual(x.ticks(10).map(x.tickFormat(10, "s")), ["0M", "0.1M", "0.2M", "0.3M", "0.4M", "0.5M", "0.6M", "0.7M", "0.8M", "0.9M", "1M"]); assert.deepEqual(x.ticks(10).map(x.tickFormat(10, ".1s")), ["0.0M", "0.1M", "0.2M", "0.3M", "0.4M", "0.5M", "0.6M", "0.7M", "0.8M", "0.9M", "1.0M"]); assert.deepEqual(x.ticks(10).map(x.tickFormat(10, "+\$.1s")), ["+\$0.0M", "+\$0.1M", "+\$0.2M", "+\$0.3M", "+\$0.4M", "+\$0.5M", "+\$0.6M", "+\$0.7M", "+\$0.8M", "+\$0.9M", "+\$1.0M"]); var x = d3.scale.linear().domain([0, 1e5]); assert.deepEqual(x.ticks(10).map(x.tickFormat(10, "s")), ["0k", "10k", "20k", "30k", "40k", "50k", "60k", "70k", "80k", "90k", "100k"]); var x = d3.scale.linear().domain([0, 1e-4]); ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!