source: Dev/branches/rest-dojo-ui/client/dojox/charting/scaler/primitive.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.0 KB
Line 
1define(["dojo/_base/lang"],
2  function(lang){
3        var primitive = lang.getObject("dojox.charting.scaler.primitive", true);
4        return lang.mixin(primitive, {
5                buildScaler: function(/*Number*/ min, /*Number*/ max, /*Number*/ span, /*Object*/ kwArgs){
6                        if(min == max){
7                                // artificially extend bounds
8                                min -= 0.5;
9                                max += 0.5;
10                                // now the line will be centered
11                        }
12                        return {
13                                bounds: {
14                                        lower: min,
15                                        upper: max,
16                                        from:  min,
17                                        to:    max,
18                                        scale: span / (max - min),
19                                        span:  span
20                                },
21                                scaler: primitive
22                        };
23                },
24                buildTicks: function(/*Object*/ scaler, /*Object*/ kwArgs){
25                        return {major: [], minor: [], micro: []};       // Object
26                },
27                getTransformerFromModel: function(/*Object*/ scaler){
28                        var offset = scaler.bounds.from, scale = scaler.bounds.scale;
29                        return function(x){ return (x - offset) * scale; };     // Function
30                },
31                getTransformerFromPlot: function(/*Object*/ scaler){
32                        var offset = scaler.bounds.from, scale = scaler.bounds.scale;
33                        return function(x){ return x / scale + offset; };       // Function
34                }
35        });
36});
Note: See TracBrowser for help on using the repository browser.