/public/javascripts/dojo/release/dojo/dojox/charting/scaler/primitive.js

http://enginey.googlecode.com/ · JavaScript · 39 lines · 30 code · 4 blank · 5 comment · 1 complexity · 0d34117becace6d30b5ef0e36ca27315 MD5 · raw file

  1. /*
  2. Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.charting.scaler.primitive"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.scaler.primitive"] = true;
  8. dojo.provide("dojox.charting.scaler.primitive");
  9. dojox.charting.scaler.primitive = {
  10. buildScaler: function(/*Number*/ min, /*Number*/ max, /*Number*/ span, /*Object*/ kwArgs){
  11. return {
  12. bounds: {
  13. lower: min,
  14. upper: max,
  15. from: min,
  16. to: max,
  17. scale: span / (max - min),
  18. span: span
  19. },
  20. scaler: dojox.charting.scaler.primitive
  21. };
  22. },
  23. buildTicks: function(/*Object*/ scaler, /*Object*/ kwArgs){
  24. return {major: [], minor: [], micro: []}; // Object
  25. },
  26. getTransformerFromModel: function(/*Object*/ scaler){
  27. var offset = scaler.bounds.from, scale = scaler.bounds.scale;
  28. return function(x){ return (x - offset) * scale; }; // Function
  29. },
  30. getTransformerFromPlot: function(/*Object*/ scaler){
  31. var offset = scaler.bounds.from, scale = scaler.bounds.scale;
  32. return function(x){ return x / scale + offset; }; // Function
  33. }
  34. };
  35. }