1 /*
  2  * Copyright (c) 2012-2015 LabKey Corporation
  3  *
  4  * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
  5  */
  6 
  7 if(!LABKEY.vis.Scale){
  8     /**
  9      * @namespace Namespace used for scales in {@link LABKEY.vis.Plot} objects.
 10      */
 11     LABKEY.vis.Scale = {};
 12 }
 13 
 14 /**
 15  * The default color scale used in plots.
 16  */
 17 LABKEY.vis.Scale.ColorDiscrete = function(){
 18     // Used for discrete color scales (color assigned to categorical data)
 19     return [ "#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", "#FFD92F", "#E5C494", "#B3B3B3"];
 20 };
 21 
 22 /**
 23  * An alternate darker color scale.
 24  */
 25 LABKEY.vis.Scale.DarkColorDiscrete = function(){
 26     // Used for discrete color scales (color assigned to categorical data)
 27     return ["#378a70", "#f34704", "#4b67a6", "#d53597", "#72a124", "#c8a300", "#d19641", "#808080"];
 28 };
 29 
 30 /**
 31  * Function that returns a discrete scale used to determine the shape of points in {@link LABKEY.vis.Geom.BoxPlot} and
 32  * {@link LABKEY.vis.Geom.Point} geoms.
 33  */
 34 LABKEY.vis.Scale.Shape = function(){
 35     var circle = function(s){
 36         return "M0," + s + "A" + s + "," + s + " 0 1,1 0," + -s + "A" + s + "," + s + " 0 1,1 0," + s + "Z";
 37     };
 38     var square = function(s){
 39         return "M" + -s + "," + -s + "L" + s + "," + -s + " " + s + "," + s + " " + -s + "," + s + "Z";
 40     };
 41     var diamond = function(s){
 42         var r = (Math.sqrt(1.5 * Math.pow(s * 2, 2))) / 2;
 43         return 'M0 ' + r + ' L ' + r + ' 0 L 0 ' + -r + ' L ' + -r + ' 0 Z';
 44     };
 45     var triangle = function(s){
 46         return 'M0,' + s + 'L' + s + ',' + -s + 'L' + -s + ',' + -s + ' Z';
 47     };
 48     var x = function(s){
 49         var r = s / 2;
 50         return 'M0,' + r + 'L' + r + ',' + (2*r) + 'L' + (2*r) + ',' + r +
 51                 'L' + r + ',0L' + (2*r) + ',' + -r +
 52                 'L' + r + ',' + (-2*r) + 'L0,' + -r +
 53                 'L' + -r + ',' + (-2*r) + 'L' + (-2*r) + ',' + -r +
 54                 'L' + -r + ',0L' + (-2*r) + ',' + r +
 55                 'L' + -r + ',' + (2*r) + 'L0,' + r + 'Z';
 56     };
 57 
 58     return [circle, triangle, square, diamond, x];
 59 };
 60 
 61 LABKEY.vis.Scale.DataspaceShape = function(){
 62     var shape01 = function(s){
 63         return 'M0-2.6c-1.5,0-2.6,1.1-2.6,2.6S-1.4,2.6,0,2.6 c1.5,0,2.6-1.2,2.6-2.6C2.6-1.5,1.5-2.6,0-2.6z M0,1.9c-1.1,0-1.9-0.8-1.9-1.9S-1-1.9,0-1.9C1.1-1.9,1.9-1,1.9,0 C1.9,1.1,1.1,1.9,0,1.9z';
 64     };
 65     var shape02 = function(s){
 66         return 'M3.1-0.6H0.6v-2.5h-1.2v2.5h-2.5v1.2h2.5v2.5h1.2V0.6h2.5C3.1,0.6,3.1-0.6,3.1-0.6z';
 67     };
 68     var shape03 = function(s){
 69         return 'M2.8-2.2L2.2-2.8L0-0.6l-2.2-2.2l-0.6,0.6L-0.6,0l-2.2,2.2l0.6,0.6L0,0.6l2.2,2.2l0.6-0.6L0.6,0L2.8-2.2z';
 70     };
 71     var shape04 = function(s){
 72         return 'M1.2-2.6h-2.6h-1.2v1.3v2.5v1.3h1.3h2.5h1.3V1.2v-2.6v-1.2H1.2z M1.2,1.2h-2.6v-2.6h2.5v2.6H1.2z';
 73     };
 74     var shape05 = function(s){
 75         return 'M3-1.1L2.6-1.9L0.5-0.8v-1.8h-1v1.8l-2.1-1.1L-3-1.1L-0.9,0L-3,1.1l0.4,0.7l2.1-1.1v1.9h1V0.7l2.1,1.1L3,1.1 L0.9,0L3-1.1z';
 76     };
 77     var shape06 = function(s){
 78         return 'M1.9-3.1V0C1.9,1,1,1.9,0,1.9C-1,1.9-1.9,1-1.9,0v-3.1h-1.3V0c0,1.7,1.4,3.1,3.1,3.1c1.7,0,3.1-1.4,3.1-3.1 v-3.1H1.9z';
 79     };
 80     var shape07 = function(s){
 81         return 'M0-3.5l-3.7,7h1h6.3L0-3.5z M2,2.3l-4,0l2-3.8L2,2.3z';
 82     };
 83     var shape08 = function(s){
 84         return 'M0-3.6l-0.3,0.3L-3.6,0L0,3.6L3.6,0L0-3.6z M-2.4,0L0-2.4L2.4,0L0,2.4L-2.4,0z';
 85     };
 86     var shape09 = function(s){
 87         return 'M1.9,-1.9 L1.9,-3.1 L0.6,-3.1 L-0.6,-3.1 L-1.9,-3.1 L-1.9,-1.9 L-0.6,-1.9 L-0.6,1.9 L-1.9,1.9 L-1.9,3.1 L-0.6,3.1 L0.6,3.1 L1.9,3.1 L1.9,1.9 L0.6,1.9 L0.6,-1.9z';
 88     };
 89     var shape10 = function(s){
 90         return 'M2.5,0c0-0.4-0.1-0.8-0.3-1.2l1.2-1.2L2.4-3.4L1.2-2.2C0.9-2.4,0.5-2.5,0-2.5c-0.5,0-0.9,0.1-1.2,0.3 l-1.2-1.2l-0.9,0.9l1.2,1.2C-2.4-0.9-2.5-0.5-2.5,0c0,0.5,0.1,0.9,0.3,1.2l-1.2,1.2l0.9,0.9l1.2-1.2C-0.8,2.3-0.4,2.5,0,2.5 c0.4,0,0.8-0.1,1.2-0.3l1.2,1.2l0.9-0.9L2.2,1.2C2.4,0.8,2.5,0.4,2.5,0z M-1.7,0C-1.7-1-1-1.7,0-1.7C1-1.7,1.7-1,1.7,0 c0,1-0.8,1.7-1.7,1.7C-1,1.7-1.7,0.9-1.7,0z';
 91     };
 92     var shape11 = function(s){
 93         return 'M2.9-0.8L0-3.6l-3.1,2.9v4.2h6.3v-4.2L2.9-0.8z M-1.9,2.3v-2.4L0-1.9l1.9,1.9v2.4H-1.9z';
 94     };
 95     var shape12 = function(s){
 96         return 'M2.7-2.7C2.4-3.1,1.8-3.4,1.3-3.4C1-3.4,0.7-3.2,0.5-3C0.3-2.8,0.1-2.6,0-2.4C-0.1-2.6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2c0-0.5-0.8-1-1.8-1s-1.8,0.4-1.8,1s0.8,1,1.8,1c0.4,0,0.7-0.1,1-0.2C-1.1-0.4-1.1-0.2-1.1,0c0,0,0,0.1,0,0.1 C-1.2,0-1.3,0-1.4,0c-0.5,0-1,0.8-1,1.8c0,1,0.4,1.8,1,1.8s1-0.8,1-1.8c0-0.3,0-0.6-0.1-0.9c0.2,0.1,0.4,0.2,0.6,0.2 c0,0,0.1,0,0.1,0C0.1,1.2,0.1,1.3,0.1,1.4c0,0.5,0.8,1,1.9,1s1.9-0.4,1.9-1S3,0.5,1.9,0.5z';
103     };
104     var shape15 = function(s){
105         return 'M0,3.5l3.7-7h-1h-6.3L0,3.5z M-2-2.3l4,0L0,1.5L-2-2.3z';
106     };
107     var shape16 = function(s){
108         return 'M-0.6-1.9v-1.3h-1.3v3.8h-1.3v1.3h3.8v1.3h1.3v-3.8h1.3v-1.3H-0.6z M0.6,0.6h-1.3v-1.3h1.3V0.6z';
109     };
110     var shape17 = function(s){
111         return 'M-2.9,0.8L0,3.6l3.1-2.9v-4.2h-6.3v4.2L-2.9,0.8z M1.9-2.3v2.4L0,1.9l-1.9-1.9v-2.4H1.9z';
112     };
113     var shape18 = function(s){
114         return 'M-1.4,-3.7 L-2.3,-3.2 L-0.9,-0.6 L-3.1,-0.6 L-3.1,0.6 L-0.9,0.6 L-2.3,3.2 L-1.4,3.7 L0,1.1 L1.3,3.7 L2.2,3.2 L0.9,0.6 L3.1,0.6 L3.1,-0.6 L0.9,-0.6 L2.2,-3.2 L1.3,-3.7 L0,-1.1z';
115     };
116     var shape19 = function(s){
117         return 'M1.7,0c0.7-0.4,1.4-1,1.8-1.8L2.8-2.2C2.1-1.1,1.1-0.4,0-0.4c-1.1,0-2.1-0.7-2.8-1.8l-0.8,0.4 C-3.1-1-2.5-0.4-1.7,0c-0.7,0.4-1.4,1-1.8,1.8l0.8,0.4C-2.1,1.1-1.1,0.4,0,0.4c1.1,0,2.1,0.7,2.8,1.8l0.8-0.4C3.1,1,2.5,0.4,1.7,0z';
118     };
119     var shape20 = function(s){
120         return 'M3,0.6 L3,0.6 L0,-3.4 L-3,0.6 L-2,1.3 L-0.6,-0.5 L-0.6,3.4 L0.6,3.4 L0.6,-0.5 L2,1.3z';
121     };
122 
123     return [
124         shape01,
125         shape02,
126         shape03,
127         shape04,
128         shape05,
129         shape06,
130         shape07,
131         shape08,
132         shape09,
133         shape10,
134         shape11,
135         shape12,
136         shape13,
137         shape14,
138         shape15,
139         shape16,
140         shape17,
141         shape18,
142         shape19,
143         shape20
144     ];
145 };
146 
147 LABKEY.vis.Scale.DataspaceColor = function(){
148     return [
149         '#010101',
150         '#52B700',
151         '#B30FAC',
152         '#FF9400',
153         '#0069F9',
154         '#FF1200',
155         '#0D6201',
156         '#964904',
157         '#FF33E5',
158         '#964904',
159         '#000000',
160         '#52B700',
161         '#FF9400',
162         '#FF1200',
163         '#B30FAC',
164         '#0D6201',
165         '#FF9400',
166         '#FF9400',
167         '#000000',
168         '#FF33E5'
169     ];
170 };