~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/src/scale/pow.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-10 14:28:58 UTC
  • Revision ID: package-import@ubuntu.com-20120410142858-nk453o1z7t7py3bs
Tags: 0.1.26
* Take ownership of the NetworkManager state variant on setup and
  unref it, plugging a memory leak.
* Log the reason the server rejected the submitted crash report.
* Send the Whoopsie version with each crash submission.
* Delete both .upload and .uploaded files after 14 days. Thanks
  Marc Deslauriers (LP: #973687).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
d3.scale.pow = function() {
 
2
  return d3_scale_pow(d3.scale.linear(), 1);
 
3
};
 
4
 
 
5
function d3_scale_pow(linear, exponent) {
 
6
  var powp = d3_scale_powPow(exponent),
 
7
      powb = d3_scale_powPow(1 / exponent);
 
8
 
 
9
  function scale(x) {
 
10
    return linear(powp(x));
 
11
  }
 
12
 
 
13
  scale.invert = function(x) {
 
14
    return powb(linear.invert(x));
 
15
  };
 
16
 
 
17
  scale.domain = function(x) {
 
18
    if (!arguments.length) return linear.domain().map(powb);
 
19
    linear.domain(x.map(powp));
 
20
    return scale;
 
21
  };
 
22
 
 
23
  scale.ticks = function(m) {
 
24
    return d3_scale_linearTicks(scale.domain(), m);
 
25
  };
 
26
 
 
27
  scale.tickFormat = function(m) {
 
28
    return d3_scale_linearTickFormat(scale.domain(), m);
 
29
  };
 
30
 
 
31
  scale.nice = function() {
 
32
    return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
 
33
  };
 
34
 
 
35
  scale.exponent = function(x) {
 
36
    if (!arguments.length) return exponent;
 
37
    var domain = scale.domain();
 
38
    powp = d3_scale_powPow(exponent = x);
 
39
    powb = d3_scale_powPow(1 / exponent);
 
40
    return scale.domain(domain);
 
41
  };
 
42
 
 
43
  scale.copy = function() {
 
44
    return d3_scale_pow(linear.copy(), exponent);
 
45
  };
 
46
 
 
47
  return d3_scale_linearRebind(scale, linear);
 
48
}
 
49
 
 
50
function d3_scale_powPow(e) {
 
51
  return function(x) {
 
52
    return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
 
53
  };
 
54
}