]> git.proxmox.com Git - extjs.git/blob - extjs/packages/charts/src/chart/interactions/RotatePie3D.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / charts / src / chart / interactions / RotatePie3D.js
1 /**
2 * @class Ext.chart.interactions.RotatePie3D
3 * @extends Ext.chart.interactions.Rotate
4 *
5 * A special version of the Rotate interaction used by Pie3D Chart.
6 */
7 Ext.define('Ext.chart.interactions.RotatePie3D', {
8
9 extend: 'Ext.chart.interactions.Rotate',
10
11 type: 'rotatePie3d',
12
13 alias: 'interaction.rotatePie3d',
14
15 getAngle: function (e) {
16 var chart = this.getChart(),
17 rtl = chart.getInherited().rtl,
18 direction = rtl ? -1 : 1,
19 pageXY = e.getXY(),
20 xy = chart.element.getXY(),
21 rect = chart.getMainRect();
22
23 return direction * Math.atan2(
24 pageXY[1] - xy[1] - rect[3] * 0.5,
25 pageXY[0] - xy[0] - rect[2] * 0.5
26 );
27 },
28
29 getRadius: function (e) {
30 var chart = this.getChart(),
31 radius = chart.getRadius(),
32 seriesList = chart.getSeries(),
33 ln = seriesList.length,
34 i = 0,
35 series, seriesRadius;
36
37 // With 3D pie series, series may have a radius that is
38 // different from the radius of the chart, because the 'pie3d'
39 // series will automatically adjust its radius based on
40 // distortion, thickness and other configs.
41 // It's not critical to check if the series radius is smaller
42 // than the chart radius, since the base Rotate interaction
43 // will rotate all series there are anyway.
44 // Rotating series individually (i.e. if having multiple concentric
45 // pie series) is not possible with neither this nor the base Rotate
46 // interaction.
47 for (; i < ln; i++) {
48 series = seriesList[i];
49 if (series.isPie3D) {
50 seriesRadius = series.getRadius();
51 if (seriesRadius > radius) {
52 radius = seriesRadius;
53 }
54 }
55 }
56
57 return radius;
58 }
59
60 });