Debian Codegraph @

dojox/color/MeanColorModel.js

raw symbols SCIP
1 define(["dojo/_base/array", "dojo/_base/declare", "./NeutralColorModel"],
2 function(arr, declare, NeutralColorModel){
3
4 return declare("dojox.color.MeanColorModel", NeutralColorModel, {
5 // summary:
6 // A color model that returns a color from a data value
7 // using an interpolation between two extremum colors around the mean value.
8
9 constructor: function(startColor, endColor){
10 // startColor: dojo/_base/Color
11 // The start color.
12 // endColor: dojo/_base/Color?
13 // The end color.
14 },
15
16 computeNeutral: function(min, max, sum, values){
17 // summary:
18 // Return the neutral value in this case the mean value of the data values.
19 // min: Number
20 // The minimal value.
21 // max: Number
22 // The maximum value.
23 // sum: Number
24 // The sum of all values.
25 // values: Number[]
26 // The sorted array of values used to compute colors.
27 var median = min;
28 if(values.length != 0){
29 if(values.length < 3){
30 median = sum / values.length;
31 }else if((values.length & 1) == 0){
32 median = (values[values.length / 2 - 1] + values[values.length / 2]) / 2;
33 }else{
34 median = values[Math.floor(values.length / 2)];
35 }
36 }
37 return median;
38 }
39 });
40 });