source: Dev/branches/rest-dojo-ui/client/dojox/charting/themes/ThreeD.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.8 KB
Line 
1define(["dojox","dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/array", "../Theme", "./gradientGenerator", "./PrimaryColors", "dojo/colors" /* for sanitize */, "./common"],
2        function(dojox, kernel, lang, ArrayUtil, Theme, gradientGenerator, PrimaryColors, themes){
3
4        var colors = ["#f00", "#0f0", "#00f", "#ff0", "#0ff", "#f0f", "./common"],      // the same is in PrimaryColors
5                defaultFill = {type: "linear", space: "shape", x1: 0, y1: 0, x2: 100, y2: 0},
6                // 3D cylinder map is calculated using dojox.gfx3d
7                cyl3dMap = [
8                        {o: 0.00, i: 174}, {o: 0.08, i: 231}, {o: 0.18, i: 237}, {o: 0.30, i: 231},
9                        {o: 0.39, i: 221}, {o: 0.49, i: 206}, {o: 0.58, i: 187}, {o: 0.68, i: 165},
10                        {o: 0.80, i: 128}, {o: 0.90, i: 102}, {o: 1.00, i: 174}
11                ],
12                hiliteIndex = 2, hiliteIntensity = 100, lumStroke = 50,
13                cyl3dFills = ArrayUtil.map(colors, function(c){
14                        var fill = lang.delegate(defaultFill),
15                                colors = fill.colors = gradientGenerator.generateGradientByIntensity(c, cyl3dMap),
16                                hilite = colors[hiliteIndex].color;
17                        // add highlight
18                        hilite.r += hiliteIntensity;
19                        hilite.g += hiliteIntensity;
20                        hilite.b += hiliteIntensity;
21                        hilite.sanitize();
22                        return fill;
23                });
24
25        themes.ThreeD = PrimaryColors.clone();
26        themes.ThreeD.series.shadow = {dx: 1, dy: 1, width: 3, color: [0, 0, 0, 0.15]};
27
28        themes.ThreeD.next = function(elementType, mixin, doPost){
29                if(elementType == "bar" || elementType == "column"){
30                        // custom processing for bars and columns: substitute fills
31                        var index = this._current % this.seriesThemes.length,
32                                s = this.seriesThemes[index], old = s.fill;
33                        s.fill = cyl3dFills[index];
34                        var theme = Theme.prototype.next.apply(this, arguments);
35                        // cleanup
36                        s.fill = old;
37                        return theme;
38                }
39                return Theme.prototype.next.apply(this, arguments);
40        };
41       
42        return themes.ThreeD;
43});
Note: See TracBrowser for help on using the repository browser.