]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @class Ext.chart.axis.Axis3D\r | |
3 | * @extends Ext.chart.axis.Axis\r | |
4 | * @xtype axis3d\r | |
5 | *\r | |
6 | * Defines a 3D axis for charts.\r | |
7 | *\r | |
8 | * A 3D axis has the same properties as the regular {@link Ext.chart.axis.Axis axis},\r | |
9 | * plus a notion of depth. The depth of the 3D axis is determined automatically\r | |
10 | * based on the depth of the bound series.\r | |
11 | *\r | |
12 | * This type of axis has the following limitations compared to the regular axis class:\r | |
13 | * - supported {@link Ext.chart.axis.Axis#position positions} are 'left' and 'bottom' only;\r | |
14 | * - floating axes are not supported.\r | |
15 | *\r | |
16 | * At the present moment only {@link Ext.chart.series.Bar3D} series can make use of the 3D axis.\r | |
17 | */\r | |
18 | Ext.define('Ext.chart.axis.Axis3D', {\r | |
19 | extend: 'Ext.chart.axis.Axis',\r | |
20 | xtype: 'axis3d',\r | |
21 | \r | |
22 | requires: [\r | |
23 | 'Ext.chart.axis.sprite.Axis3D'\r | |
24 | ],\r | |
25 | \r | |
26 | config: {\r | |
27 | /**\r | |
28 | * @private\r | |
29 | * The depth of the axis. Determined automatically.\r | |
30 | */\r | |
31 | depth: 0\r | |
32 | \r | |
33 | /**\r | |
34 | * @cfg {String} position\r | |
35 | * Where to set the axis. Available options are `left` and `bottom`.\r | |
36 | */\r | |
37 | },\r | |
38 | \r | |
39 | onSeriesChange: function (chart) {\r | |
40 | var me = this,\r | |
41 | eventName = 'depthchange',\r | |
42 | listenerName = 'onSeriesDepthChange',\r | |
43 | i, series;\r | |
44 | \r | |
45 | function toggle(action) {\r | |
46 | var boundSeries = me.boundSeries;\r | |
47 | for (i = 0; i < boundSeries.length; i++) {\r | |
48 | series = boundSeries[i];\r | |
49 | series[action](eventName, listenerName, me);\r | |
50 | }\r | |
51 | }\r | |
52 | \r | |
53 | // Remove 'depthchange' listeners from old bound series, if any.\r | |
54 | toggle('un');\r | |
55 | \r | |
56 | me.callParent(arguments);\r | |
57 | \r | |
58 | // Add 'depthchange' listeners to new bound series.\r | |
59 | toggle('on');\r | |
60 | },\r | |
61 | \r | |
62 | onSeriesDepthChange: function (series, depth) {\r | |
63 | var me = this,\r | |
64 | maxDepth = depth,\r | |
65 | boundSeries = me.boundSeries,\r | |
66 | i, item;\r | |
67 | \r | |
68 | if (depth > me.getDepth()) {\r | |
69 | maxDepth = depth;\r | |
70 | } else {\r | |
71 | for (i = 0; i < boundSeries.length; i++) {\r | |
72 | item = boundSeries[i];\r | |
73 | if (item !== series && item.getDepth) {\r | |
74 | depth = item.getDepth();\r | |
75 | if (depth > maxDepth) {\r | |
76 | maxDepth = depth;\r | |
77 | }\r | |
78 | }\r | |
79 | }\r | |
80 | }\r | |
81 | me.setDepth(maxDepth);\r | |
82 | },\r | |
83 | \r | |
84 | updateDepth: function (depth) {\r | |
85 | var me = this,\r | |
86 | sprites = me.getSprites(),\r | |
87 | attr = {depth: depth};\r | |
88 | \r | |
89 | if (sprites && sprites.length) {\r | |
90 | sprites[0].setAttributes(attr);\r | |
91 | }\r | |
92 | if (me.gridSpriteEven && me.gridSpriteOdd) {\r | |
93 | me.gridSpriteEven.getTemplate().setAttributes(attr);\r | |
94 | me.gridSpriteOdd.getTemplate().setAttributes(attr);\r | |
95 | }\r | |
96 | },\r | |
97 | \r | |
98 | getGridAlignment: function () {\r | |
99 | switch (this.getPosition()) {\r | |
100 | case 'left':\r | |
101 | case 'right':\r | |
102 | return 'horizontal3d';\r | |
103 | case 'top':\r | |
104 | case 'bottom':\r | |
105 | return 'vertical3d';\r | |
106 | }\r | |
107 | }\r | |
108 | \r | |
109 | }); |