Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
36d3e018
Commit
36d3e018
authored
Mar 21, 2016
by
GoshaZotov
Committed by
Alexander.Trofimov
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add changes from SVN branch
parent
64b3753d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2009 additions
and
348 deletions
+2009
-348
common/Charts/3DTransformation.js
common/Charts/3DTransformation.js
+1155
-249
common/Charts/ChartsDrawer.js
common/Charts/ChartsDrawer.js
+545
-72
common/Drawings/Format/ChartSpace.js
common/Drawings/Format/ChartSpace.js
+309
-27
No files found.
common/Charts/3DTransformation.js
View file @
36d3e018
...
...
@@ -52,7 +52,7 @@ Processor3D.prototype.calaculate3DProperties = function(baseDepth, gapDepth, isT
//this._calcSpecialStandardScaleX();
//глубина
this
.
depthPerspective
=
this
.
view3D
.
rAngAx
?
this
.
_calculateDepth
()
:
this
.
_calculateDepthPerspective
();
;
this
.
depthPerspective
=
this
.
view3D
.
rAngAx
?
this
.
_calculateDepth
()
:
this
.
_calculateDepthPerspective
();
//угол перспективы
this
.
_calculatePerspective
(
this
.
view3D
);
...
...
@@ -92,18 +92,21 @@ Processor3D.prototype._recalculateScaleWithMaxWidth = function()
{
var
widthLine
=
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
);
var
heightLine
=
this
.
heightCanvas
-
(
this
.
top
+
this
.
bottom
);
var
widthCanvas
=
this
.
widthCanvas
;
//todo оптимальную ширину нужно пересмотреть
//оптимальная ширина - ширина при которой не происходит масштабирования по ширине
var
optimalWidth
=
heightLine
*
10
;
var
subType
=
this
.
chartsDrawer
.
calcProp
.
subType
;
var
isStandardType
=
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Area
"
&&
subType
===
"
normal
"
?
true
:
false
;
var
isStandardType
=
!!
(
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Area
"
&&
subType
===
"
normal
"
);
var
optimalWidthLine
,
kF
;
if
(
!
isStandardType
)
{
var
optimalWidth
=
heightLine
*
10
;
var
widthCanvas
=
this
.
widthCanvas
;
this
.
widthCanvas
=
optimalWidth
+
(
this
.
left
+
this
.
right
);
this
.
_calculateScaleNStandard
();
var
optimalWidthLine
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
;
var
kF
=
optimalWidthLine
/
widthLine
;
optimalWidthLine
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
;
kF
=
optimalWidthLine
/
widthLine
;
if
(
optimalWidthLine
<
widthLine
)
{
...
...
@@ -129,16 +132,11 @@ Processor3D.prototype._recalculateScaleWithMaxWidth = function()
if
(
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
<=
widthLine
)
return
;
//todo оптимальную ширину нужно пересмотреть
//оптимальная ширина - ширина при которой не происходит масштабирования по ширине
var
optimalWidth
=
heightLine
*
10
;
var
widthCanvas
=
this
.
widthCanvas
;
//рассчитываем параметры диаграммы при оптимальной ширине
this
.
widthCanvas
=
optimalWidth
+
(
this
.
left
+
this
.
right
);
this
.
calaculate3DProperties
(
null
,
null
,
true
);
var
optimalWidthLine
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
;
var
kF
=
optimalWidthLine
/
widthLine
;
optimalWidthLine
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
;
kF
=
optimalWidthLine
/
widthLine
;
this
.
aspectRatioX
=
widthLine
/
((
optimalWidthLine
-
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
))
/
kF
);
this
.
scaleY
=
this
.
scaleY
*
kF
;
...
...
@@ -150,11 +148,6 @@ Processor3D.prototype._recalculateScaleWithMaxWidth = function()
}
else
{
//todo оптимальную ширину нужно пересмотреть
//оптимальная ширина - ширина при которой не происходит масштабирования по ширине
var
optimalWidth
=
heightLine
*
10
;
var
widthCanvas
=
this
.
widthCanvas
;
//рассчитываем параметры диаграммы при оптимальной ширине
this
.
widthCanvas
=
optimalWidth
+
(
this
.
left
+
this
.
right
);
var
scaleX
=
this
.
scaleX
;
...
...
@@ -166,7 +159,7 @@ Processor3D.prototype._recalculateScaleWithMaxWidth = function()
var
aspectRatioZ
=
this
.
aspectRatioZ
;
this
.
calaculate3DProperties
(
null
,
null
,
true
);
var
optimalWidthLine
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
;
optimalWidthLine
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
)
+
((
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
))
/
this
.
aspectRatioX
)
/
this
.
scaleX
;
if
(
optimalWidthLine
<
widthLine
)
...
...
@@ -184,7 +177,7 @@ Processor3D.prototype._recalculateScaleWithMaxWidth = function()
}
var
kF
=
optimalWidthLine
/
widthLine
;
kF
=
optimalWidthLine
/
widthLine
;
this
.
aspectRatioX
=
widthLine
/
((
optimalWidthLine
-
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOy
))
/
kF
);
this
.
scaleY
=
this
.
scaleY
*
kF
;
this
.
scaleZ
=
this
.
scaleZ
*
kF
;
...
...
@@ -290,12 +283,29 @@ Processor3D.prototype.calculateZPositionCatAxis = function()
return
result
;
};
//***functions for complete transformation point***
Processor3D
.
prototype
.
convertAndTurnPoint
=
function
(
x
,
y
,
z
,
cameraDiffZ
)
{
var
res
=
null
;
if
(
this
.
view3D
.
rAngAx
)
{
res
=
this
.
convertAndTurnPointRAngAx
(
x
,
y
,
z
,
cameraDiffZ
);
}
else
{
res
=
this
.
convertAndTurnPointPerspective
(
x
,
y
,
z
,
cameraDiffZ
);
}
return
res
;
};
Processor3D
.
prototype
.
convertAndTurnPointRAngAx
=
function
(
x
,
y
,
z
)
{
var
heightChart
=
this
.
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
widthOriginalChart
=
this
.
widthCanvas
-
this
.
left
-
this
.
right
;
var
heightOriginalChart
=
heightChart
;
var
widthChart
=
heightChart
;
//aspectRatio
if
(
this
.
view3D
.
rAngAx
)
...
...
@@ -305,7 +315,7 @@ Processor3D.prototype.convertAndTurnPoint = function(x, y, z, cameraDiffZ)
}
else
{
var
aspectRatio
=
(
widthOriginalChart
)
/
(
height
Original
Chart
);
var
aspectRatio
=
(
widthOriginalChart
)
/
(
heightChart
);
x
=
x
/
aspectRatio
;
}
...
...
@@ -317,7 +327,7 @@ Processor3D.prototype.convertAndTurnPoint = function(x, y, z, cameraDiffZ)
var
point3D
=
new
Point3D
(
x
,
y
,
z
,
this
);
//diff
var
centerXDiff
=
width
Chart
/
2
+
this
.
left
/
2
;
var
centerXDiff
=
height
Chart
/
2
+
this
.
left
/
2
;
var
centerYDiff
=
heightChart
/
2
+
this
.
top
;
var
centerZDiff
=
this
.
depthPerspective
/
2
;
...
...
@@ -351,12 +361,132 @@ Processor3D.prototype.convertAndTurnPoint = function(x, y, z, cameraDiffZ)
return
{
x
:
projectionPoint
.
x
,
y
:
projectionPoint
.
y
};
};
Processor3D
.
prototype
.
convertAndTurnPointPerspective
=
function
(
x
,
y
,
z
)
{
//aspectRatio
x
=
x
/
this
.
aspectRatioX
;
y
=
y
/
this
.
aspectRatioY
;
x
=
x
/
this
.
scaleX
;
y
=
y
/
this
.
scaleY
;
z
=
z
/
this
.
scaleZ
;
var
point3D
=
new
Point3D
(
x
,
y
,
z
,
this
);
//diff
var
centerZDiff
=
this
.
depthPerspective
/
2
;
point3D
.
offset
((
-
this
.
widthCanvas
/
2
)
/
this
.
aspectRatioX
,
(
-
this
.
heightCanvas
/
2
)
/
this
.
aspectRatioY
/** aspectRatio*/
,
0
);
//rotate
var
matrixRotateAllAxis
;
if
(
!
this
.
view3D
.
rAngAx
)
matrixRotateAllAxis
=
this
.
_getMatrixRotateAllAxis
();
else
matrixRotateAllAxis
=
this
.
_shearXY
();
point3D
.
multiplyPointOnMatrix1
(
matrixRotateAllAxis
);
// diff camera for charts write into rect
point3D
.
offset
(
this
.
cameraDiffX
,
this
.
cameraDiffY
,
this
.
cameraDiffZ
);
//project
var
projectionPoint
=
point3D
;
if
(
!
this
.
view3D
.
rAngAx
)
{
var
projectiveMatrix
=
this
.
_getPerspectiveProjectionMatrix
(
1
/
(
this
.
rPerspective
));
projectionPoint
=
point3D
.
project
(
projectiveMatrix
);
}
//undiff
var
specialReverseDiffX
=
this
.
widthCanvas
/
2
+
(
this
.
left
-
this
.
right
)
/
2
;
var
specialReverseDiffY
=
this
.
heightCanvas
/
2
+
(
this
.
top
-
this
.
bottom
)
/
2
;
projectionPoint
.
offset
(
specialReverseDiffX
,
specialReverseDiffY
,
centerZDiff
);
return
{
x
:
projectionPoint
.
x
,
y
:
projectionPoint
.
y
};
};
//functions for step transformation point
Processor3D
.
prototype
.
calculatePointManual
=
function
(
x
,
y
,
z
,
diffX
,
diffY
,
diffZ
)
{
diffX
=
diffX
!==
undefined
?
diffX
:
this
.
cameraDiffX
;
diffY
=
diffY
!==
undefined
?
diffY
:
this
.
cameraDiffY
;
diffZ
=
diffZ
!==
undefined
?
diffZ
:
this
.
cameraDiffZ
;
var
diffAndScalePoints
=
this
.
diffAndScale
(
x
,
y
,
z
);
var
x11
=
diffAndScalePoints
.
x
;
var
y11
=
diffAndScalePoints
.
y
;
var
z11
=
diffAndScalePoints
.
z
;
var
rotatePoints
=
this
.
rotate
(
x11
,
y11
,
z11
);
var
x111
=
rotatePoints
.
x
;
var
y111
=
rotatePoints
.
y
;
var
z111
=
rotatePoints
.
z
;
var
x1111
=
x111
+
diffX
;
var
y1111
=
y111
+
diffY
;
var
z1111
=
z111
+
diffZ
;
var
projectPoints
=
this
.
project
(
x1111
,
y1111
,
z1111
);
var
x11111
=
projectPoints
.
x
;
var
y11111
=
projectPoints
.
y
;
return
{
x
:
x11111
,
y
:
y11111
};
};
Processor3D
.
prototype
.
diffAndScale
=
function
(
x
,
y
,
z
)
{
var
aRX
=
this
.
aspectRatioX
;
var
aRY
=
this
.
aspectRatioY
;
var
w
=
this
.
widthCanvas
;
var
h
=
this
.
heightCanvas
;
var
x1
=
x
/
aRX
;
var
x11
=
x1
-
(
w
/
2
)
/
aRX
;
var
z1
=
z
;
var
z11
=
z1
;
var
y1
=
y
/
aRY
;
var
y11
=
y1
-
(
h
/
2
)
/
aRY
;
return
{
x
:
x11
,
y
:
y11
,
z
:
z11
};
};
Processor3D
.
prototype
.
rotate
=
function
(
x11
,
y11
,
z11
)
{
var
sinOY
=
Math
.
sin
(
-
this
.
angleOy
);
var
cosOY
=
Math
.
cos
(
-
this
.
angleOy
);
var
sinOX
=
Math
.
sin
(
-
this
.
angleOx
);
var
cosOX
=
Math
.
cos
(
-
this
.
angleOx
);
var
x111
=
z11
*
sinOY
+
x11
*
cosOY
;
var
y111
=
x11
*
sinOX
*
sinOY
+
y11
*
cosOX
-
z11
*
sinOX
*
cosOY
;
var
z111
=
-
x11
*
sinOY
*
cosOX
+
y11
*
sinOX
+
z11
*
(
cosOY
*
cosOX
);
return
{
x
:
x111
,
y
:
y111
,
z
:
z111
};
};
Processor3D
.
prototype
.
project
=
function
(
x1111
,
y1111
,
z1111
)
{
var
fov
=
1
/
this
.
rPerspective
;
var
w
=
this
.
widthCanvas
;
var
h
=
this
.
heightCanvas
;
var
x11111
=
(
fov
*
x1111
)
/
(
z1111
+
fov
)
+
w
/
2
;
var
y11111
=
(
fov
*
y1111
)
/
(
z1111
+
fov
)
+
h
/
2
;
return
{
x
:
x11111
,
y
:
y11111
};
};
//exception for pie charts
Processor3D
.
prototype
.
convertAndTurnPointForPie
=
function
(
x
,
y
,
z
,
cameraDiffZ
)
{
var
heightChart
=
this
.
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
widthOriginalChart
=
this
.
widthCanvas
-
this
.
left
-
this
.
right
;
var
heightOriginalChart
=
heightChart
;
var
widthChart
=
heightChart
;
//aspectRatio
/*x = x / this.aspectRatioX;
...
...
@@ -369,7 +499,7 @@ Processor3D.prototype.convertAndTurnPointForPie = function(x, y, z, cameraDiffZ)
var
point3D
=
new
Point3D
(
x
,
y
,
z
,
this
);
//diff
var
centerXDiff
=
width
Chart
/
2
+
this
.
left
/
2
;
var
centerXDiff
=
height
Chart
/
2
+
this
.
left
/
2
;
var
centerYDiff
=
heightChart
/
2
+
this
.
top
;
var
centerZDiff
=
this
.
depthPerspective
/
2
;
...
...
@@ -427,6 +557,9 @@ Processor3D.prototype.calculatePropertiesForPieCharts = function()
return
{
radius1
:
radius1
,
radius2
:
radius2
,
depth
:
depth
};
};
//***functions for matrix transformation***
Processor3D
.
prototype
.
_shearXY
=
function
()
{
//TODO матрица перевёрнута
...
...
@@ -438,6 +571,14 @@ Processor3D.prototype._getMatrixRotateAllAxis = function()
var
matrixRotateOY
=
this
.
_getMatrixRotateOy
();
var
matrixRotateOX
=
this
.
_getMatrixRotateOx
();
/*итоговая матрица
|cosOy 0 sinOy 0|
|sinOx * sinOy cosOx -sinOx * cosOy 0|
|-sinOy * cosOx sinOx cosOy * cosOx 0|
|-sinOy 0 (cosOy + 1) 1|*/
return
Point3D
.
prototype
.
multiplyMatrix
(
matrixRotateOY
,
matrixRotateOX
);
};
...
...
@@ -456,6 +597,18 @@ Processor3D.prototype._getMatrixRotateOz = function()
return
[[
1
,
0
,
0
,
0
],
[
0
,
1
,
0
,
0
],
[
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
1
]];
};
Processor3D
.
prototype
.
_getPerspectiveProjectionMatrix
=
function
(
fov
)
{
/*var zf = this.rPerspective + this.depthPerspective;
var zn = this.rPerspective;
var q = zf / (zf - zn);
return [[1 / Math.tan(this.rPerspective / 2), 0, 0, 0], [0, 1 / Math.tan(this.rPerspective / 2), 0, 0], [0, 0, q, 1], [0, 0, -q * zn, 0]];*/
return
[[
1
,
0
,
0
,
0
],
[
0
,
1
,
0
,
0
],
[
0
,
0
,
0
,
1
/
fov
],
[
0
,
0
,
0
,
1
]];
};
Processor3D
.
prototype
.
correctPointsPosition
=
function
(
chartSpace
)
{
if
(
this
.
chartsDrawer
.
calcProp
.
type
===
"
Pie
"
)
...
...
@@ -540,18 +693,14 @@ Processor3D.prototype.correctPointsPosition = function(chartSpace)
widthText
=
0
;
}
if
(
t
.
view3D
.
rAngAx
)
diffXText
=
0
;
else
diffXText
=
15
;
var
diffXText
=
0
;
var
angleOyAbs
=
Math
.
abs
(
t
.
angleOy
);
if
(
!
t
.
view3D
.
rAngAx
&&
(
angleOyAbs
>=
Math
.
PI
/
2
&&
angleOyAbs
<
3
*
Math
.
PI
/
2
))
diffXText
=
-
diffXText
;
valCatAx
.
transformYPoints
[
i
]
=
{
x
:
(
point
.
x
-
(
diffXText
+
widthText
))
/
pxToMM
,
y
:
point
.
y
/
pxToMM
};
}
}
}
;
var
correctPointsOyHBar
=
function
()
{
...
...
@@ -580,7 +729,7 @@ Processor3D.prototype.correctPointsPosition = function(chartSpace)
valCatAx
.
transformYPoints
[
i
]
=
{
x
:
(
point
.
x
-
widthText
)
/
pxToMM
,
y
:
point
.
y
/
pxToMM
};
}
}
}
;
if
(
xPoints
)
...
...
@@ -600,39 +749,8 @@ Processor3D.prototype.correctPointsPosition = function(chartSpace)
}
};
Processor3D
.
prototype
.
_getIsometricProjectionMatrix
=
function
()
{
var
far
=
this
.
depthPerspective
;
var
near
=
0
;
var
right
=
this
.
widthCanvas
+
this
.
left
;
var
left
=
this
.
left
;
var
bottom
=
this
.
heightCanvas
+
this
.
top
;
var
top
=
this
.
top
;
var
m11
=
2
/
(
right
-
left
);
var
m41
=
(
right
+
left
)
/
(
right
-
left
);
var
m22
=
2
/
(
top
-
bottom
);
var
m42
=
(
top
+
bottom
)
/
(
top
-
bottom
);
var
m33
=
-
2
/
(
far
-
near
);
var
m34
=
(
far
+
near
)
/
(
far
-
near
);
return
[[
m11
,
0
,
0
,
m41
],
[
0
,
m22
,
0
,
m42
],
[
0
,
0
,
m33
,
m34
],
[
0
,
0
,
0
,
1
]];
};
Processor3D
.
prototype
.
_getPerspectiveProjectionMatrix
=
function
(
fov
)
{
/*var zf = this.rPerspective + this.depthPerspective;
var zn = this.rPerspective;
var q = zf / (zf - zn);
return [[1 / Math.tan(this.rPerspective / 2), 0, 0, 0], [0, 1 / Math.tan(this.rPerspective / 2), 0, 0], [0, 0, q, 1], [0, 0, -q * zn, 0]];*/
return
[[
1
,
0
,
0
,
0
],
[
0
,
1
,
0
,
0
],
[
0
,
0
,
0
,
1
/
fov
],
[
0
,
0
,
0
,
1
]];
};
Processor3D
.
prototype
.
_calculatePerspective
=
function
(
view3D
)
{
var
widthLine
=
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
);
var
heightLine
=
this
.
heightCanvas
-
(
this
.
top
+
this
.
bottom
);
var
perspective
=
view3D
&&
view3D
.
perspective
?
view3D
.
perspective
:
global3DPersperctive
;
...
...
@@ -648,75 +766,6 @@ Processor3D.prototype._calculatePerspective = function(view3D)
this
.
rPerspective
=
rPerspective
;
};
Processor3D
.
prototype
.
_calculateDepthClassic
=
function
()
{
var
widthOriginalChart
=
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
);
var
heightOriginalChart
=
this
.
heightCanvas
-
(
this
.
top
+
this
.
bottom
);
var
subType
=
this
.
chartsDrawer
.
calcProp
.
subType
;
var
type
=
this
.
chartsDrawer
.
calcProp
.
type
;
var
defaultOverlap
=
(
subType
==
"
stacked
"
||
subType
==
"
stackedPer
"
||
subType
==
"
standard
"
||
type
==
"
Line
"
||
type
==
"
Area
"
)
?
100
:
0
;
var
overlap
=
this
.
chartSpace
.
chart
.
plotArea
.
chart
.
overlap
?
(
this
.
chartSpace
.
chart
.
plotArea
.
chart
.
overlap
/
100
)
:
(
defaultOverlap
/
100
);
var
gapWidth
=
this
.
chartSpace
.
chart
.
plotArea
.
chart
.
gapWidth
!=
null
?
(
this
.
chartSpace
.
chart
.
plotArea
.
chart
.
gapWidth
/
100
)
:
(
150
/
100
);
var
gapDepth
=
this
.
chartSpace
.
chart
.
plotArea
.
chart
.
gapDepth
!=
null
?
(
this
.
chartSpace
.
chart
.
plotArea
.
chart
.
gapDepth
/
100
)
:
(
150
/
100
);
var
basePercent
=
this
.
view3D
&&
this
.
view3D
.
depthPercent
?
this
.
view3D
.
depthPercent
/
100
:
globalBasePercent
/
100
;
//процент от базовой глубины
var
seriesCount
=
this
.
chartsDrawer
.
calcProp
.
seriesCount
;
var
ptCount
=
this
.
chartsDrawer
.
calcProp
.
ptCount
;
var
sinOx
=
Math
.
sin
(
-
this
.
angleOx
);
var
hPercent
=
this
.
view3D
.
hPercent
!==
null
?
this
.
view3D
.
hPercent
/
100
:
heightOriginalChart
/
widthOriginalChart
;
var
t
=
this
;
var
depth
=
0
;
//STANDARD TYPE
var
calculateDepthForStandardCharts
=
function
()
{
var
angleOxKf
=
sinOx
===
0
?
0
:
sinOx
;
depth
=
(
1
/
(
angleOxKf
+
((
ptCount
+
(
Math
.
floor
((
seriesCount
-
ptCount
)
/
2
)))
/
seriesCount
*
hPercent
)))
*
(
heightOriginalChart
);
return
depth
;
};
var
calculateDepthForAnotherCharts
=
function
()
{
//TODO глубина с некоторыми графиками имеет различия, пересчитать!
var
widthChart
=
(
widthOriginalChart
/
t
.
aspectRatioX
)
/
t
.
specialStandardScaleX
;
var
width
=
widthChart
/
t
.
chartsDrawer
.
calcProp
.
ptCount
;
var
baseDepth
=
width
/
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
if
(
subType
==
"
standard
"
||
type
==
"
Line
"
)
baseDepth
=
(
width
/
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
))
*
seriesCount
;
var
depth
;
if
(
t
.
view3D
.
rAngAx
&&
t
.
aspectRatioY
===
1
)
{
var
b
=
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
if
(
subType
==
"
standard
"
||
type
==
"
Line
"
||
type
==
"
Area
"
)
b
=
b
/
seriesCount
;
var
sinOx
=
Math
.
sin
(
-
t
.
angleOx
);
var
angleOxKf
=
sinOx
===
0
?
1
:
sinOx
;
var
a
=
basePercent
/
(
t
.
chartsDrawer
.
calcProp
.
ptCount
*
b
);
depth
=
(
widthChart
*
a
+
gapDepth
*
widthChart
*
a
)
/
(
1
/
angleOxKf
+
(
gapDepth
)
*
a
+
a
);
depth
=
depth
/
angleOxKf
;
}
else
{
depth
=
baseDepth
*
basePercent
;
depth
=
depth
+
depth
*
gapDepth
;
}
return
depth
;
};
depth
=
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
?
calculateDepthForStandardCharts
()
:
calculateDepthForAnotherCharts
();
return
depth
;
};
Processor3D
.
prototype
.
_calculateDepth
=
function
()
{
var
widthOriginalChart
=
this
.
widthCanvas
-
(
this
.
left
+
this
.
right
);
...
...
@@ -746,18 +795,21 @@ Processor3D.prototype._calculateDepth = function()
standardType
=
true
;
var
heightHPercent
=
heightOriginalChart
/
hPercent
;
var
angleOxKf
;
if
(
!
standardType
)
{
var
widthOneBar
=
((
heightHPercent
/
seriesCount
)
/
(
ptCount
-
(
ptCount
-
1
)
*
(
overlap
)
+
gapWidth
))
*
sinOy
;
var
a
,
b
;
if
(
this
.
angleOx
===
0
&&
this
.
angleOy
===
0
)
//withoutAngleNoAuto + withoutAngleAuto
{
var
widthOneBar
=
((
heightHPercent
/
seriesCount
)
/
(
ptCount
-
(
ptCount
-
1
)
*
(
overlap
)
+
gapWidth
))
*
sinOy
;
//0
chartWidth
=
widthOneBar
+
heightHPercent
;
}
else
if
(
this
.
angleOx
!==
0
/* && this.angleOy !== 0*/
)
//AngleOYNoAut + AngleOYNoAutPerHeight + (ANGLEOX+ANGLEOY) + AngleOYOXNoAut + ANGLEOXANGLEOYHPerDPer(ANGLEOX+ANGLEOY HPercent)
{
//если выставить ширину 255 будет так же, как и в документе с расчётами
var
b
=
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
var
a
=
(
depthPercent
/
(
ptCount
*
b
))
/
hPercent
;
b
=
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
a
=
(
depthPercent
/
(
ptCount
*
b
))
/
hPercent
;
var
width
=
heightOriginalChart
*
areaStackedKf
;
depth
=
(
width
*
a
+
gapDepth
*
width
*
a
)
/
(
1
/
sinOx
+
(
gapDepth
)
*
a
+
a
);
...
...
@@ -766,21 +818,15 @@ Processor3D.prototype._calculateDepth = function()
else
if
(
this
.
angleOy
!==
0
)
//angleOxNoAuto
{
//если выставить ширину = 321.25 будет так же, как и в документе с расчётам
var
widthOneBar
=
((
heightHPercent
/
seriesCount
)
/
(
ptCount
-
(
ptCount
-
1
)
*
(
overlap
)
+
gapWidth
))
*
sinOy
;
chartWidth
=
widthOneBar
+
heightHPercent
;
//TODO глубина с некоторыми графиками имеет различия, пересчитать!
var
widthChart
=
(
widthOriginalChart
/
t
.
aspectRatioX
)
/
t
.
specialStandardScaleX
;
var
b
=
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
b
=
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
if
(
subType
==
"
standard
"
||
type
==
"
Line
"
||
type
==
"
Area
"
)
b
=
b
/
seriesCount
;
var
sinOx
=
Math
.
sin
(
-
t
.
angleOx
);
var
angleOxKf
=
sinOx
===
0
?
1
:
sinOx
;
var
a
=
basePercent
/
(
t
.
chartsDrawer
.
calcProp
.
ptCount
*
b
);
angleOxKf
=
sinOx
===
0
?
1
:
sinOx
;
a
=
basePercent
/
(
t
.
chartsDrawer
.
calcProp
.
ptCount
*
b
);
depth
=
(
widthChart
*
a
+
gapDepth
*
widthChart
*
a
)
/
(
1
/
angleOxKf
+
(
gapDepth
)
*
a
+
a
);
depth
=
depth
/
angleOxKf
;
...
...
@@ -788,12 +834,12 @@ Processor3D.prototype._calculateDepth = function()
}
else
//allStandardDepth
{
var
angleOxKf
=
sinOx
===
0
?
0
:
sinOx
;
angleOxKf
=
sinOx
===
0
?
0
:
sinOx
;
if
(
type
==
"
Area
"
)
depth
=
(
1
*
depthPercent
/
(
angleOxKf
*
depthPercent
+
((
ptCount
+
(
Math
.
floor
((
seriesCount
-
ptCount
)
/
2
-
0.5
)))
/
seriesCount
*
hPercent
)))
*
(
heightOriginalChart
);
depth
=
(
depthPercent
/
(
angleOxKf
*
depthPercent
+
((
ptCount
+
(
Math
.
floor
((
seriesCount
-
ptCount
)
/
2
-
0.5
)))
/
seriesCount
*
hPercent
)))
*
(
heightOriginalChart
);
else
depth
=
(
1
*
depthPercent
/
(
angleOxKf
*
depthPercent
+
((
ptCount
+
(
Math
.
floor
((
seriesCount
-
ptCount
)
/
2
)))
/
seriesCount
*
hPercent
)))
*
(
heightOriginalChart
);
depth
=
(
depthPercent
/
(
angleOxKf
*
depthPercent
+
((
ptCount
+
(
Math
.
floor
((
seriesCount
-
ptCount
)
/
2
)))
/
seriesCount
*
hPercent
)))
*
(
heightOriginalChart
);
if
((
this
.
angleOx
!==
0
))
depth
=
depth
*
Math
.
sin
(
-
this
.
angleOx
);
...
...
@@ -802,18 +848,14 @@ Processor3D.prototype._calculateDepth = function()
return
sinOx
!==
0
?
depth
/
Math
.
sin
(
-
this
.
angleOx
)
:
depth
;
};
Processor3D
.
prototype
.
_calculateDepthPerspective
=
function
()
{
var
widthCanvas
=
this
.
widthCanvas
;
var
heightCanvas
=
this
.
heightCanvas
;
var
widthOriginalChart
=
heightCanvas
-
(
this
.
left
+
this
.
right
);
var
heightOriginalChart
=
heightCanvas
-
(
this
.
top
+
this
.
bottom
);
var
widthOriginalChart
=
widthCanvas
-
(
this
.
left
+
this
.
right
);
var
aspectRatio
=
(
widthOriginalChart
)
/
(
heightOriginalChart
);
var
aspectRatio
=
this
.
aspectRatioX
/
(
this
.
specialStandardScaleX
);
var
widthChart
=
widthOriginalChart
/
aspectRatio
;
var
widthChart
=
widthChart
/
this
.
scaleX
;
widthChart
=
widthChart
/
this
.
scaleX
;
var
seriesCount
=
this
.
chartsDrawer
.
calcProp
.
seriesCount
;
...
...
@@ -835,16 +877,15 @@ Processor3D.prototype._calculateDepthPerspective = function()
depth
=
depth
+
depth
*
gapDepth
;
if
(
this
.
view3D
.
rAngAx
)
//TODO глубина в некоторых случаях отличается(тип Standard)
if
(
this
.
chartsDrawer
.
calcProp
.
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
)
{
var
b
=
(
seriesCount
-
(
seriesCount
-
1
)
*
overlap
+
gapWidth
);
if
(
this
.
chartsDrawer
.
calcProp
.
subType
==
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
==
"
Line
"
||
this
.
chartsDrawer
.
calcProp
.
type
==
"
Area
"
)
b
=
b
/
seriesCount
;
var
b
=
1
/
seriesCount
;
var
sinOx
=
Math
.
sin
(
-
this
.
angleOx
);
var
angleOxKf
=
sinOx
===
0
?
1
:
sinOx
;
var
angleOxKf
=
1
;
var
a
=
basePercent
/
(
this
.
chartsDrawer
.
calcProp
.
ptCount
*
b
);
depth
=
(
widthChart
*
a
+
gapDepth
*
widthChart
*
a
)
/
(
1
/
angleOxKf
+
(
gapDepth
)
*
a
+
a
);
depth
=
(
widthChart
*
a
+
widthChart
*
a
)
/
(
1
/
angleOxKf
+
a
);
depth
=
depth
/
angleOxKf
;
}
...
...
@@ -869,9 +910,6 @@ Processor3D.prototype._calculateScaleFromDepth = function (/*isSkip*/)
//***Calculate scaleY***
if
(
this
.
view3D
.
rAngAx
&&
this
.
aspectRatioY
===
1
)
{
var
widthCanvas
=
this
.
widthCanvas
;
var
originalWidthChart
=
widthCanvas
-
this
.
left
-
this
.
right
;
var
heightCanvas
=
this
.
heightCanvas
;
var
heightChart
=
heightCanvas
-
this
.
top
-
this
.
bottom
;
...
...
@@ -882,20 +920,11 @@ Processor3D.prototype._calculateScaleFromDepth = function (/*isSkip*/)
//this.scaleX += parseInt((this.chartsDrawer.calcProp.seriesCount + 1) / 2) - 1;
var
subType
=
this
.
chartsDrawer
.
calcProp
.
subType
;
if
(
subType
==
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
||
(
this
.
chartsDrawer
.
calcProp
.
type
===
"
Area
"
&&
subType
==
"
normal
"
))
{
var
widthStandard
=
heightChart
/
this
.
specialStandardScaleX
;
if
(
widthStandard
>
originalWidthChart
)
widthStandard
=
originalWidthChart
;
var
newDepth
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOx
);
var
newWidth
=
widthStandard
-
newDepth
;
//this.scaleX = heightChart / newWidth;
}
else
var
newDepth
,
newWidth
;
if
(
!
(
subType
==
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
||
(
this
.
chartsDrawer
.
calcProp
.
type
===
"
Area
"
&&
subType
==
"
normal
"
)))
{
var
newDepth
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOx
);
var
newWidth
=
heightChart
-
newDepth
;
newDepth
=
this
.
depthPerspective
*
Math
.
sin
(
-
this
.
angleOx
);
newWidth
=
heightChart
-
newDepth
;
this
.
scaleX
=
heightChart
/
newWidth
;
}
}
...
...
@@ -912,8 +941,6 @@ Processor3D.prototype._calculateCameraDiff = function (/*isSkip*/)
var
heightCanvas
=
this
.
heightCanvas
;
var
heightChart
=
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
perspectiveDepth
=
this
.
depthPerspective
;
//add test points for parallelepiped rect
var
points
=
[];
var
faces
=
[];
...
...
@@ -936,51 +963,925 @@ Processor3D.prototype._calculateCameraDiff = function (/*isSkip*/)
//***Calculate cameraDiffZ***
if
(
!
this
.
view3D
.
rAngAx
)
this
.
_calculateCameraDiffZ
(
points
,
faces
);
{
//медленная функция поиска сдвигов камеры(все сдвиги корректны)
//this._calculateCameraDiffZ(points, faces);
//быстрая функция поиска сдвигов камеры
console
.
time
(
"
sdf
"
);
this
.
_calculateCameraDiffZX
(
points
,
faces
);
console
.
timeEnd
(
"
sdf
"
);
}
//***Calculate cameraDiffX***
if
(
this
.
view3D
.
rAngAx
)
{
var
minMaxOx
=
this
.
_getMinMaxOx
(
points
,
faces
);
this
.
_calculateCameraDiffX
(
minMaxOx
);
}
//***Calculate cameraDiffY***
var
minMaxOy
=
this
.
_getMinMaxOy
(
points
,
faces
);
this
.
_calculateCameraDiffY
(
minMaxOy
.
top
,
minMaxOy
.
bottom
);
}
};
Processor3D
.
prototype
.
_calculateCameraDiffZ
=
function
(
points
,
face
s
)
Processor3D
.
prototype
.
_calculateCameraDiffZ
X
=
function
(
newPoint
s
)
{
var
widthCanvas
=
this
.
widthCanvas
;
var
originalWidthChart
=
widthCanvas
-
this
.
left
-
this
.
right
;
var
heightChart
=
this
.
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
widthOriginalChart
=
this
.
widthCanvas
-
this
.
left
-
this
.
right
;
var
heightOriginalChart
=
heightChart
;
var
heightCanvas
=
this
.
heightCanvas
;
var
heightChart
=
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
minX
=
null
;
var
maxX
=
null
;
var
minZ
=
null
;
var
widthChart
=
originalWidthChart
;
var
depthChart
=
this
.
depthPerspective
;
var
aspectRatio
=
(
widthOriginalChart
)
/
(
heightOriginalChart
);
var
minMaxOx
=
this
.
_getMinMaxOx
(
points
,
faces
);
var
point1
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostLeftPointX
.
x
,
minMaxOx
.
mostLeftPointX
.
y
,
minMaxOx
.
mostLeftPointX
.
z
,
true
);
var
point2
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostRightPointX
.
x
,
minMaxOx
.
mostRightPointX
.
y
,
minMaxOx
.
mostRightPointX
.
z
,
true
);
var
x1
=
point1
.
x
;
var
x2
=
point2
.
x
;
var
y1
=
point1
.
y
;
var
y2
=
point2
.
y
;
var
diffX
=
Math
.
abs
(
x1
-
x2
);
var
diffY
=
Math
.
abs
(
y1
-
y2
);
//TODO медленная функция, рассчитать сдвиги!
while
(
diffX
>
widthChart
||
diffY
>
heightChart
)
for
(
var
i
=
0
;
i
<
newPoints
.
length
;
i
++
)
{
var
minMaxOx
=
this
.
_getMinMaxOx
(
points
,
faces
);
var
point1
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostLeftPointX
.
x
,
minMaxOx
.
mostLeftPointX
.
y
,
minMaxOx
.
mostLeftPointX
.
z
,
true
);
var
point2
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostRightPointX
.
x
,
minMaxOx
.
mostRightPointX
.
y
,
minMaxOx
.
mostRightPointX
.
z
,
true
);
var
point3D
=
new
Point3D
(
newPoints
[
i
].
x
,
newPoints
[
i
].
y
,
newPoints
[
i
].
z
,
this
);
var
x1
=
point1
.
x
;
var
x2
=
point2
.
x
;
var
y1
=
point1
.
y
;
point3D
.
scale
(
aspectRatio
,
1
,
1
);
point3D
.
offset
((
-
this
.
widthCanvas
/
2
)
/
aspectRatio
,
(
-
this
.
heightCanvas
/
2
)
,
0
);
//rotate
var
matrixRotateAllAxis
=
this
.
_getMatrixRotateAllAxis
();
point3D
.
multiplyPointOnMatrix1
(
matrixRotateAllAxis
);
if
(
minZ
===
null
||
point3D
.
z
<
minZ
)
minZ
=
point3D
.
z
;
if
(
minX
===
null
||
point3D
.
x
<
minX
)
minX
=
point3D
.
x
;
if
(
maxX
===
null
||
point3D
.
x
>
maxX
)
maxX
=
point3D
.
x
;
}
//get min and max point's and diffX
/*if(-t.angleOx === 0)
{
var minMaxOx = this._getMinMaxOxPoints(newPoints, minZ);
this.cameraDiffZ = - minZ;
this.cameraDiffX = - minMaxOx.diffX;
var x111 = this.convertAndTurnPoint(minMaxOx.tempX1, minMaxOx.tempY1, minMaxOx.tempZ1);
var x222 = this.convertAndTurnPoint(minMaxOx.tempX2, minMaxOx.tempY2, minMaxOx.tempZ2);
if(Math.abs(x222.x - x111.x) > widthOriginalChart)
{
var correctOffset;
if(x222.x > x111.x)
{
correctOffset = this._correctZPosition4(minMaxOx.tempX1, minMaxOx.tempX2, minMaxOx.tempZ1, minMaxOx.tempZ2, minZ, minMaxOx.tempY1, minMaxOx.tempY2);
}
else
{
correctOffset = this._correctZPosition4(minMaxOx.tempX1, minMaxOx.tempX2, minMaxOx.tempZ1, minMaxOx.tempZ2, minZ, minMaxOx.tempY1, minMaxOx.tempY2);
}
this.cameraDiffZ = Math.abs(correctOffset.minZ);
this.cameraDiffX = correctOffset.diffX;
}
}
else if(-t.angleOy === 0 && -t.angleOx !== 0)
{
var minMaxOy = this._getMinMaxOyPoints(newPoints, minZ);
this.cameraDiffZ = - minZ;
this.cameraDiffY = -minMaxOy.diffY;
var y111 = this.convertAndTurnPoint(minMaxOy.tempX1, minMaxOy.tempY1, minMaxOy.tempZ1);
var y222 = this.convertAndTurnPoint(minMaxOy.tempX2, minMaxOy.tempY2, minMaxOy.tempZ2);
if(Math.abs(y111.y - y222.y) < heightOriginalChart)
{
var minMaxOx = this._getMinMaxOxPoints(newPoints, minZ);
var x111 = this.convertAndTurnPoint(minMaxOx.tempX1, minMaxOx.tempY1, minMaxOx.tempZ1);
var x222 = this.convertAndTurnPoint(minMaxOx.tempX2, minMaxOx.tempY2, minMaxOx.tempZ2);
var correctOffset;
if(x222.x > x111.x)
{
correctOffset = this._correctZPosition4(minMaxOx.tempX1, minMaxOx.tempX2, minMaxOx.tempZ1, minMaxOx.tempZ2, minZ, minMaxOx.tempY1, minMaxOx.tempY2);
}
else
{
correctOffset = this._correctZPosition4(minMaxOx.tempX1, minMaxOx.tempX2, minMaxOx.tempZ1, minMaxOx.tempZ2, minZ, minMaxOx.tempY1, minMaxOx.tempY2);
}
this.cameraDiffZ = Math.abs(correctOffset.minZ);
this.cameraDiffX = correctOffset.diffX;
var minMaxOy = this._getMinMaxOyPoints(newPoints, 0);
//this.cameraDiffZ = - minZ;
this.cameraDiffY = -minMaxOy.diffY;
}
}*/
/*else if(-t.angleOy !== 0 && -t.angleOx !== 0)
{
var minMaxOx = this._getMinMaxOxPoints(newPoints, minZ);
var x111 = this.convertAndTurnPoint(minMaxOx.tempX1, minMaxOx.tempY1, minMaxOx.tempZ1);
var x222 = this.convertAndTurnPoint(minMaxOx.tempX2, minMaxOx.tempY2, minMaxOx.tempZ2);
var correctOffset;
if(x222.x > x111.x)
{
correctOffset = this._correctZPosition4(minMaxOx.tempX1, minMaxOx.tempX2, minMaxOx.tempZ1, minMaxOx.tempZ2, minZ, minMaxOx.tempY1, minMaxOx.tempY2);
}
else
{
correctOffset = this._correctZPosition4(minMaxOx.tempX2, minMaxOx.tempX1, minMaxOx.tempZ2, minMaxOx.tempZ1, minZ, minMaxOx.tempY2, minMaxOx.tempY1);
}
this.cameraDiffZ = correctOffset.minZ;
this.cameraDiffX = correctOffset.diffX;
var minMaxOy = this._getMinMaxOyPoints2(newPoints, this.cameraDiffZ);
this.cameraDiffY = minMaxOy.diffY;
console.log(" tempX1: " + minMaxOy.tempX1 + " tempX2: " + minMaxOy.tempX2 + " tempY1: " + minMaxOy.tempY1 + " tempY2: " + minMaxOy.tempY2 + " tempZ1: " + minMaxOy.tempZ1 + " tempZ2: " + minMaxOy.tempZ2);
var y111 = this.convertAndTurnPoint(minMaxOy.tempX1, minMaxOy.tempY1, minMaxOy.tempZ1);
var y222 = this.convertAndTurnPoint(minMaxOy.tempX2, minMaxOy.tempY2, minMaxOy.tempZ2);
if(y111.y < this.top || y222.y > this.top + heightOriginalChart)
{
//correctOffset = this._correctZPositionOY(minMaxOy.tempX1, minMaxOy.tempX2, minMaxOy.tempZ1, minMaxOy.tempZ2, minZ, minMaxOy.tempY1, minMaxOy.tempY2);
this.cameraDiffZ = minMaxOy.diffZ;
//this.cameraDiffY = minMaxOy.diffY;
var minMaxOx = this._getMinMaxOxPoints(newPoints, -this.cameraDiffZ);
//correctOffset = this._correctZPosition4(minMaxOx.tempX1, minMaxOx.tempX2, minMaxOx.tempZ1, minMaxOx.tempZ2, -this.cameraDiffZ, minMaxOx.tempY1, minMaxOx.tempY2);
this.cameraDiffX = -minMaxOx.diffX;
}
//TODO пока включаю для поворотов по OX + по OY checkOutSideArea(медленная функция), затем нужно переделать, используя закомментированный код сверху
this.cameraDiffZ = -minZ;
//this.cameraDiffX = -minMaxOx.diffX;
this.checkOutSideArea(newPoints);
}*/
//TODO пока включаю для ВСЕГО checkOutSideArea(медленная функция), затем нужно переделать, используя закомментированный код сверху
this
.
cameraDiffZ
=
-
minZ
;
this
.
checkOutSideArea
(
newPoints
);
};
Processor3D
.
prototype
.
checkOutSideArea
=
function
(
newPoints
)
{
var
i
=
0
;
var
maxI
=
1000
;
var
t
=
this
;
var
heightChart
=
this
.
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
widthChart
=
this
.
widthCanvas
-
this
.
left
-
this
.
right
;
var
calculateZ
=
function
(
step
)
{
var
minMaxOx
=
t
.
_getMinMaxOxPoints
(
newPoints
,
-
t
.
cameraDiffZ
);
t
.
cameraDiffX
=
-
minMaxOx
.
diffX
;
var
x111
=
t
.
convertAndTurnPoint
(
minMaxOx
.
tempX1
,
minMaxOx
.
tempY1
,
minMaxOx
.
tempZ1
);
var
x222
=
t
.
convertAndTurnPoint
(
minMaxOx
.
tempX2
,
minMaxOx
.
tempY2
,
minMaxOx
.
tempZ2
);
var
diffX
=
Math
.
abs
(
x222
.
x
-
x111
.
x
);
var
minMaxOy
=
t
.
_getMinMaxOyPoints
(
newPoints
,
t
.
cameraDiffZ
);
t
.
cameraDiffY
=
-
minMaxOy
.
diffY
;
var
y111
=
t
.
convertAndTurnPoint
(
minMaxOy
.
tempX1
,
minMaxOy
.
tempY1
,
minMaxOy
.
tempZ1
);
var
y222
=
t
.
convertAndTurnPoint
(
minMaxOy
.
tempX2
,
minMaxOy
.
tempY2
,
minMaxOy
.
tempZ2
);
var
diffY
=
Math
.
abs
(
y222
.
y
-
y111
.
y
);
if
(
diffX
<
widthChart
&&
diffY
<
heightChart
)
//if size less then width or height
{
while
(
diffX
<
widthChart
&&
diffY
<
heightChart
)
{
t
.
cameraDiffZ
-=
step
;
i
++
;
minMaxOx
=
t
.
_getMinMaxOxPoints
(
newPoints
,
-
t
.
cameraDiffZ
);
t
.
cameraDiffX
=
-
minMaxOx
.
diffX
;
x111
=
t
.
convertAndTurnPoint
(
minMaxOx
.
tempX1
,
minMaxOx
.
tempY1
,
minMaxOx
.
tempZ1
);
x222
=
t
.
convertAndTurnPoint
(
minMaxOx
.
tempX2
,
minMaxOx
.
tempY2
,
minMaxOx
.
tempZ2
);
diffX
=
Math
.
abs
(
x222
.
x
-
x111
.
x
);
minMaxOy
=
t
.
_getMinMaxOyPoints
(
newPoints
,
t
.
cameraDiffZ
);
t
.
cameraDiffY
=
-
minMaxOy
.
diffY
;
y111
=
t
.
convertAndTurnPoint
(
minMaxOy
.
tempX1
,
minMaxOy
.
tempY1
,
minMaxOy
.
tempZ1
);
y222
=
t
.
convertAndTurnPoint
(
minMaxOy
.
tempX2
,
minMaxOy
.
tempY2
,
minMaxOy
.
tempZ2
);
diffY
=
Math
.
abs
(
y222
.
y
-
y111
.
y
);
if
(
i
>
maxI
)
break
;
}
}
else
if
(
diffX
>
widthChart
||
diffY
>
heightChart
)
//if size more then width or height
{
while
(
diffX
>
widthChart
||
diffY
>
heightChart
)
{
t
.
cameraDiffZ
+=
step
;
i
++
;
minMaxOx
=
t
.
_getMinMaxOxPoints
(
newPoints
,
-
t
.
cameraDiffZ
);
t
.
cameraDiffX
=
-
minMaxOx
.
diffX
;
x111
=
t
.
convertAndTurnPoint
(
minMaxOx
.
tempX1
,
minMaxOx
.
tempY1
,
minMaxOx
.
tempZ1
);
x222
=
t
.
convertAndTurnPoint
(
minMaxOx
.
tempX2
,
minMaxOx
.
tempY2
,
minMaxOx
.
tempZ2
);
diffX
=
Math
.
abs
(
x222
.
x
-
x111
.
x
);
minMaxOy
=
t
.
_getMinMaxOyPoints
(
newPoints
,
t
.
cameraDiffZ
);
t
.
cameraDiffY
=
-
minMaxOy
.
diffY
;
y111
=
t
.
convertAndTurnPoint
(
minMaxOy
.
tempX1
,
minMaxOy
.
tempY1
,
minMaxOy
.
tempZ1
);
y222
=
t
.
convertAndTurnPoint
(
minMaxOy
.
tempX2
,
minMaxOy
.
tempY2
,
minMaxOy
.
tempZ2
);
diffY
=
Math
.
abs
(
y222
.
y
-
y111
.
y
);
if
(
i
>
maxI
)
break
;
}
}
};
calculateZ
(
10
);
calculateZ
(
1
);
};
Processor3D
.
prototype
.
_getMinMaxOxPoints
=
function
(
points
,
minZ
)
{
var
fov
=
1
/
this
.
rPerspective
;
var
t
=
this
;
var
aspectRatioX
=
this
.
aspectRatioX
;
var
aspectRatioY
=
this
.
aspectRatioY
;
var
diffAndRotatePoint
=
function
(
point
)
{
var
point3D
=
new
Point3D
(
point
.
x
,
point
.
y
,
point
.
z
,
t
);
point3D
.
scale
(
aspectRatioX
,
aspectRatioY
,
1
);
point3D
.
offset
((
-
t
.
widthCanvas
/
2
)
/
aspectRatioX
,
(
-
t
.
heightCanvas
/
2
)
/
aspectRatioY
/** aspectRatio*/
,
0
);
//rotate
var
matrixRotateAllAxis
=
t
.
_getMatrixRotateAllAxis
();
point3D
.
multiplyPointOnMatrix1
(
matrixRotateAllAxis
);
return
point3D
;
};
var
calculateDiffX
=
function
(
x1
,
x2
,
z1
,
z2
,
minZ
,
y1
,
y2
)
{
var
diffAndScalePoints1
=
t
.
diffAndScale
(
x1
,
y1
,
z1
);
x1
=
diffAndScalePoints1
.
x
;
y1
=
diffAndScalePoints1
.
y
;
z1
=
diffAndScalePoints1
.
z
;
var
rotatePoints1
=
t
.
rotate
(
x1
,
y1
,
z1
);
var
a1
=
rotatePoints1
.
x
;
//var x1S = a1 - diffX;
var
z1S
=
rotatePoints1
.
z
-
minZ
;
//var x1SS = (fov * x1S / (z1S + fov)) + w / 2;
var
diffAndScalePoints2
=
t
.
diffAndScale
(
x2
,
y2
,
z2
);
x2
=
diffAndScalePoints2
.
x
;
y2
=
diffAndScalePoints2
.
y
;
z2
=
diffAndScalePoints2
.
z
;
var
rotatePoints2
=
t
.
rotate
(
x2
,
y2
,
z2
);
var
a2
=
rotatePoints2
.
x
;
//var x2S = a2 - diffX;
var
z2S
=
rotatePoints2
.
z
-
minZ
;
//var x2SS = (fov * x2S / (z2S + fov)) + w / 2;
var
diffX
=
(
-
a1
*
z2S
-
a1
*
fov
-
a2
*
z1S
-
a2
*
fov
)
/
(
-
z2S
-
fov
-
z1S
-
fov
);
return
diffX
;
};
var
w
=
t
.
widthCanvas
;
var
tempArray
=
this
.
_getArrayAllVergeCube
(
points
);
var
x11
,
x22
,
y11
,
y22
,
z11
,
z22
;
var
tempX1
,
tempY1
,
tempZ1
,
tempX2
,
tempY2
,
tempZ2
,
start
,
end
;
for
(
var
i
=
0
;
i
<
tempArray
.
length
-
1
;
i
++
)
{
start
=
i
;
end
=
i
+
1
;
x11
=
tempArray
[
start
].
x
-
(
t
.
widthCanvas
/
2
);
x22
=
tempArray
[
end
].
x
-
(
t
.
widthCanvas
/
2
);
y11
=
tempArray
[
start
].
y
-
(
t
.
heightCanvas
/
2
);
y22
=
tempArray
[
end
].
y
-
(
t
.
heightCanvas
/
2
);
z11
=
tempArray
[
start
].
z
;
z22
=
tempArray
[
end
].
z
;
tempX1
=
tempArray
[
start
].
x
;
tempY1
=
tempArray
[
start
].
y
;
tempZ1
=
tempArray
[
start
].
z
;
tempX2
=
tempArray
[
end
].
x
;
tempY2
=
tempArray
[
end
].
y
;
tempZ2
=
tempArray
[
end
].
z
;
if
(
x11
>
x22
)
{
start
=
i
+
1
;
end
=
i
;
x11
=
tempArray
[
start
].
x
-
(
t
.
widthCanvas
/
2
);
x22
=
tempArray
[
end
].
x
-
(
t
.
widthCanvas
/
2
);
y11
=
tempArray
[
start
].
y
-
(
t
.
heightCanvas
/
2
);
y22
=
tempArray
[
end
].
y
-
(
t
.
heightCanvas
/
2
);
z11
=
tempArray
[
start
].
z
;
z22
=
tempArray
[
end
].
z
;
tempX1
=
tempArray
[
start
].
x
;
tempY1
=
tempArray
[
start
].
y
;
tempZ1
=
tempArray
[
start
].
z
;
tempX2
=
tempArray
[
end
].
x
;
tempY2
=
tempArray
[
end
].
y
;
tempZ2
=
tempArray
[
end
].
z
;
}
var
diffX
=
calculateDiffX
(
tempX1
,
tempX2
,
tempZ1
,
tempZ2
,
minZ
,
tempY1
,
tempY2
);
var
projectiveMatrix
=
t
.
_getPerspectiveProjectionMatrix
(
1
/
(
t
.
rPerspective
));
var
rotatePoint1
=
diffAndRotatePoint
(
tempArray
[
start
]);
rotatePoint1
.
offset
(
-
diffX
,
0
,
-
minZ
);
rotatePoint1
=
rotatePoint1
.
project
(
projectiveMatrix
);
var
x1
=
Math
.
floor
(
rotatePoint1
.
x
+
t
.
widthCanvas
/
2
);
var
rotatePoint2
=
diffAndRotatePoint
(
tempArray
[
end
]);
rotatePoint2
.
offset
(
-
diffX
,
0
,
-
minZ
);
rotatePoint2
=
rotatePoint2
.
project
(
projectiveMatrix
);
var
x2
=
Math
.
floor
(
rotatePoint2
.
x
+
t
.
widthCanvas
/
2
);
var
leftMargin
=
x1
;
var
rightMargin
=
Math
.
floor
(
w
-
x2
);
if
(
!
((
leftMargin
>=
rightMargin
-
1
)
&&
(
leftMargin
<=
rightMargin
+
1
)))
continue
;
var
isTrue
=
true
;
for
(
var
l
=
0
;
l
<
tempArray
.
length
-
1
;
l
++
)
{
var
rotatePoint
=
diffAndRotatePoint
(
tempArray
[
l
]);
rotatePoint
.
offset
(
-
diffX
,
0
,
-
minZ
);
rotatePoint
=
rotatePoint
.
project
(
projectiveMatrix
);
var
tempX11
=
Math
.
floor
(
rotatePoint
.
x
+
t
.
widthCanvas
/
2
);
if
(
x1
<
x2
)
{
if
(
tempX11
<
x1
||
tempX11
>
x2
)
{
isTrue
=
false
;
break
;
}
}
else
{
if
(
tempX11
>
x1
||
tempX11
<
x2
)
{
isTrue
=
false
;
break
;
}
}
}
if
(
isTrue
)
break
;
}
return
{
diffX
:
diffX
,
tempX1
:
tempX1
,
tempY1
:
tempY1
,
tempZ1
:
tempZ1
,
tempX2
:
tempX2
,
tempY2
:
tempY2
,
tempZ2
:
tempZ2
,
x11
:
x11
,
z11
:
z11
,
x22
:
x22
,
z22
:
z22
,
y11
:
y11
,
y22
:
y22
};
};
Processor3D
.
prototype
.
_getMinMaxOyPoints
=
function
(
points
,
minZ
)
{
var
fov
=
1
/
this
.
rPerspective
;
var
t
=
this
;
var
h
=
t
.
heightCanvas
;
var
w
=
t
.
widthCanvas
;
var
calculateDiffY
=
function
(
x1
,
x2
,
y1
,
y2
,
z1
,
z2
,
minZ
)
{
//var cos1 = Math.cos(-t.angleOy);
//var sin1 = Math.sin(-t.angleOy);
var
diffY
=
0
;
var
diffAndScalePoints
=
t
.
diffAndScale
(
x1
,
y1
,
z1
);
var
x1
=
diffAndScalePoints
.
x
;
var
y1
=
diffAndScalePoints
.
y
;
var
z1
=
diffAndScalePoints
.
z
;
var
rotatePoints
=
t
.
rotate
(
x1
,
y1
,
z1
);
var
a1
=
rotatePoints
.
y
;
//var y1S = (a1 - diffY);
var
z1S
=
rotatePoints
.
z
+
minZ
;
//var x1SS = (fov * y1S / (z1S + fov)) + h / 2;
diffAndScalePoints
=
t
.
diffAndScale
(
x2
,
y2
,
z2
);
x2
=
diffAndScalePoints
.
x
;
y2
=
diffAndScalePoints
.
y
;
z2
=
diffAndScalePoints
.
z
;
rotatePoints
=
t
.
rotate
(
x2
,
y2
,
z2
);
var
a2
=
rotatePoints
.
y
;
//var y2S = (a2 - diffY);
var
z2S
=
rotatePoints
.
z
+
minZ
;
//var x2SS = (fov * y2S / (z2S + fov)) + h / 2;
//var topMargin = (fov * y1S / (z1S + fov)) + h / 2;
//var bottomMargin = h - ((fov * y2S / (z2S + fov)) + h / 2);
//((a1 - diffY) / (z1S + fov)) = - (((a2 - diffY) / (z2S + fov)))
/*(a1 - diffY) * (z2S + fov) = -(z1S + fov) * (a2 - diffY)
a1 * z2S + a1 * fov - diffY * z2S - diffY * fov = -z1S * a2 + z1S * diffY - fov * a2 + fov * diffY
a1 * z2S + a1 * fov + fov * a2 + z1S * a2= diffY * z2S + diffY * fov + z1S * diffY + fov * diffY*/
diffY
=
(
a1
*
z2S
+
a1
*
fov
+
fov
*
a2
+
z1S
*
a2
)
/
(
z2S
+
fov
+
z1S
+
fov
);
//var diffY = (-a1 * z2S - a1 * fov - a2 * z1S -a2 * fov) / ( -z2S - fov - z1S - fov);
return
diffY
;
};
var
tempArray
=
this
.
_getArrayAllVergeCube
(
points
);
var
tempX1
,
tempY1
,
tempZ1
,
tempX2
,
tempY2
,
tempZ2
;
for
(
var
i
=
0
;
i
<
tempArray
.
length
-
1
;
i
++
)
{
var
start
=
i
;
var
end
=
i
+
1
;
tempX1
=
tempArray
[
start
].
x
;
tempY1
=
tempArray
[
start
].
y
;
tempZ1
=
tempArray
[
start
].
z
;
tempX2
=
tempArray
[
end
].
x
;
tempY2
=
tempArray
[
end
].
y
;
tempZ2
=
tempArray
[
end
].
z
;
if
(
tempY1
>
tempY2
)
{
start
=
i
+
1
;
end
=
i
;
tempX1
=
tempArray
[
start
].
x
;
tempY1
=
tempArray
[
start
].
y
;
tempZ1
=
tempArray
[
start
].
z
;
tempX2
=
tempArray
[
end
].
x
;
tempY2
=
tempArray
[
end
].
y
;
tempZ2
=
tempArray
[
end
].
z
;
}
var
diffY
=
calculateDiffY
(
tempX1
,
tempX2
,
tempY1
,
tempY2
,
tempZ1
,
tempZ2
,
minZ
);
var
rotatePoint1
=
this
.
calculatePointManual
(
tempX1
,
tempY1
,
tempZ1
,
this
.
cameraDiffX
,
-
diffY
,
minZ
);
var
y1
=
rotatePoint1
.
y
;
var
rotatePoint2
=
this
.
calculatePointManual
(
tempX2
,
tempY2
,
tempZ2
,
this
.
cameraDiffX
,
-
diffY
,
minZ
);
var
y2
=
rotatePoint2
.
y
;
var
topMargin
=
y1
;
var
bottomMargin
=
Math
.
floor
(
h
-
y2
);
if
(
!
((
topMargin
>=
bottomMargin
-
1
)
&&
(
topMargin
<=
bottomMargin
+
1
)))
continue
;
var
isTrue
=
true
;
for
(
var
l
=
0
;
l
<
tempArray
.
length
-
1
;
l
++
)
{
var
rotatePoint
=
this
.
calculatePointManual
(
tempArray
[
l
].
x
,
tempArray
[
l
].
y
,
tempArray
[
l
].
z
,
this
.
cameraDiffX
,
-
diffY
,
minZ
);
var
tempY11
=
rotatePoint
.
y
;
if
(
y1
<
y2
)
{
if
(
tempY11
<
y1
||
tempY11
>
y2
)
{
isTrue
=
false
;
break
;
}
}
else
{
if
(
tempY11
>
y1
||
tempY11
<
y2
)
{
isTrue
=
false
;
break
;
}
}
}
if
(
isTrue
)
break
;
}
return
{
diffY
:
diffY
,
tempX1
:
tempX1
,
tempY1
:
tempY1
,
tempZ1
:
tempZ1
,
tempX2
:
tempX2
,
tempY2
:
tempY2
,
tempZ2
:
tempZ2
};
};
Processor3D
.
prototype
.
_getArrayAllVergeCube
=
function
(
points
)
{
var
res
=
[];
res
[
0
]
=
points
[
0
];
res
[
1
]
=
points
[
1
];
res
[
2
]
=
points
[
2
];
res
[
3
]
=
points
[
3
];
res
[
4
]
=
points
[
0
];
res
[
5
]
=
points
[
4
];
res
[
6
]
=
points
[
7
];
res
[
7
]
=
points
[
6
];
res
[
8
]
=
points
[
5
];
res
[
9
]
=
points
[
2
];
res
[
10
]
=
points
[
6
];
res
[
11
]
=
points
[
1
];
res
[
12
]
=
points
[
7
];
res
[
13
]
=
points
[
0
];
res
[
14
]
=
points
[
5
];
res
[
15
]
=
points
[
1
];
res
[
16
]
=
points
[
4
];
res
[
17
]
=
points
[
3
];
res
[
18
]
=
points
[
6
];
res
[
19
]
=
points
[
0
];
res
[
20
]
=
points
[
2
];
res
[
21
]
=
points
[
7
];
res
[
22
]
=
points
[
3
];
res
[
23
]
=
points
[
5
];
res
[
24
]
=
points
[
7
];
res
[
25
]
=
points
[
4
];
res
[
26
]
=
points
[
2
];
res
[
27
]
=
points
[
3
];
res
[
28
]
=
points
[
1
];
res
[
29
]
=
points
[
4
];
res
[
30
]
=
points
[
5
];
res
[
31
]
=
points
[
6
];
res
[
32
]
=
points
[
4
];
/*for(var i = 0; i < points.length; i++)
{
for(var j = 0; j < points.length; j++)
{
res.push(points[i]);
res.push(points[j]);
}
}*/
return
res
;
};
Processor3D
.
prototype
.
_getMinMaxOyPoints2
=
function
(
points
,
minZ
)
{
var
t
=
this
;
var
h
=
t
.
heightCanvas
;
var
tempArray
=
[];
tempArray
[
0
]
=
points
[
0
];
//leftNear
tempArray
[
1
]
=
points
[
1
];
//leftFar
tempArray
[
2
]
=
points
[
2
];
//rightFar
tempArray
[
3
]
=
points
[
3
];
//rightNear
tempArray
[
4
]
=
points
[
4
];
//leftNear
tempArray
[
5
]
=
points
[
5
];
//leftFar
tempArray
[
6
]
=
points
[
6
];
//leftFar
tempArray
[
7
]
=
points
[
7
];
//leftFar
tempArray
[
8
]
=
points
[
4
];
//leftFar
tempArray
[
9
]
=
points
[
1
];
//leftFar
tempArray
[
10
]
=
points
[
3
];
//leftFar
tempArray
[
11
]
=
points
[
0
];
//leftFar
tempArray
[
12
]
=
points
[
7
];
//leftFar
tempArray
[
13
]
=
points
[
2
];
//leftFar
tempArray
[
14
]
=
points
[
0
];
//leftFar
tempArray
[
15
]
=
points
[
6
];
//leftFar
tempArray
[
16
]
=
points
[
5
];
//leftFar
tempArray
[
17
]
=
points
[
0
];
//leftFar
tempArray
[
18
]
=
points
[
4
];
//leftFar
var
tempX1
,
tempY1
,
tempZ1
,
tempX2
,
tempY2
,
tempZ2
;
for
(
var
i
=
0
;
i
<
tempArray
.
length
-
1
;
i
++
)
{
var
start
=
i
;
var
end
=
i
+
1
;
tempX1
=
tempArray
[
start
].
x
;
tempY1
=
tempArray
[
start
].
y
;
tempZ1
=
tempArray
[
start
].
z
;
tempX2
=
tempArray
[
end
].
x
;
tempY2
=
tempArray
[
end
].
y
;
tempZ2
=
tempArray
[
end
].
z
;
if
(
tempY1
>
tempY2
)
{
start
=
i
+
1
;
end
=
i
;
tempX1
=
tempArray
[
start
].
x
;
tempY1
=
tempArray
[
start
].
y
;
tempZ1
=
tempArray
[
start
].
z
;
tempX2
=
tempArray
[
end
].
x
;
tempY2
=
tempArray
[
end
].
y
;
tempZ2
=
tempArray
[
end
].
z
;
}
//var diffY = calculateDiffY(tempX1, tempX2, tempY1, tempY2, tempZ1, tempZ2, minZ);
var
correctOffset
=
this
.
_correctZPositionOY
(
tempX1
,
tempX2
,
tempZ1
,
tempZ2
,
minZ
,
tempY1
,
tempY2
);
var
diffZ
=
correctOffset
.
minZ
;
var
diffY
=
correctOffset
.
diffY
;
var
rotatePoint1
=
this
.
calculatePointManual
(
tempX1
,
tempY1
,
tempZ1
,
this
.
cameraDiffX
,
diffY
,
diffZ
);
var
y1
=
rotatePoint1
.
y
;
var
rotatePoint2
=
this
.
calculatePointManual
(
tempX2
,
tempY2
,
tempZ2
,
this
.
cameraDiffX
,
diffY
,
diffZ
);
var
y2
=
rotatePoint2
.
y
;
var
topMargin
=
y1
;
var
bottomMargin
=
Math
.
floor
(
h
-
y2
);
if
(
!
((
topMargin
>=
bottomMargin
-
1
)
&&
(
topMargin
<=
bottomMargin
+
1
)))
continue
;
var
isTrue
=
true
;
for
(
var
l
=
0
;
l
<
tempArray
.
length
-
1
;
l
++
)
{
var
rotatePoint
=
this
.
calculatePointManual
(
tempArray
[
l
].
x
,
tempArray
[
l
].
y
,
tempArray
[
l
].
z
,
this
.
cameraDiffX
,
diffY
,
diffZ
);
var
tempY11
=
rotatePoint
.
y
;
if
(
y1
<
y2
)
{
if
(
tempY11
<
y1
||
tempY11
>
y2
)
{
isTrue
=
false
;
break
;
}
}
else
{
if
(
tempY11
>
y1
||
tempY11
<
y2
)
{
isTrue
=
false
;
break
;
}
}
}
if
(
isTrue
)
break
;
}
return
{
diffY
:
diffY
,
tempX1
:
tempX1
,
tempY1
:
tempY1
,
tempZ1
:
tempZ1
,
tempX2
:
tempX2
,
tempY2
:
tempY2
,
tempZ2
:
tempZ2
,
diffZ
:
diffZ
};
};
Processor3D
.
prototype
.
_correctZPosition4
=
function
(
x1
,
x2
,
z1
,
z2
,
minZ
,
y1
,
y2
)
{
var
t
=
this
;
var
getDiffXZ3
=
function
(
x1
,
x2
,
z1
,
z2
,
y1
,
y2
)
{
var
w
=
t
.
widthCanvas
;
var
fov
=
1
/
t
.
rPerspective
;
var
diffAndScalePoints
=
t
.
diffAndScale
(
x1
,
y1
,
z1
);
var
x11
=
diffAndScalePoints
.
x
;
var
y11
=
diffAndScalePoints
.
y
;
var
z11
=
diffAndScalePoints
.
z
;
var
rotatePoints
=
t
.
rotate
(
x11
,
y11
,
z11
);
var
x111
=
rotatePoints
.
x
;
var
z111
=
rotatePoints
.
z
;
/*var x1111 = x111 + diffX;
var y1111 = y111 + diffY;
var z1111 = z111 + diffZ;
var x11111 = (fov * x1111) / (z1111 + fov) + w / 2;
var y11111 = (fov * y1111) / (z1111 + fov) + h / 2;*/
//(fov * x1111) / (z1111 + fov) + w / 2 = t.left
//(fov * (x111 + diffX)) / ((z111 + diffZ) + fov) + w / 2 = t.left
var
wL
=
t
.
left
-
w
/
2
;
//fov * (x111 + diffX) = wL * ((z111 + diffZ) + fov)
//fov * x111 + fov * diffX = wL * z111 + wL * diffZ + wL * fov
diffAndScalePoints
=
t
.
diffAndScale
(
x2
,
y2
,
z2
);
var
x22
=
diffAndScalePoints
.
x
;
var
y22
=
diffAndScalePoints
.
y
;
var
z22
=
diffAndScalePoints
.
z
;
rotatePoints
=
t
.
rotate
(
x22
,
y22
,
z22
);
var
x222
=
rotatePoints
.
x
;
var
z222
=
rotatePoints
.
z
;
/*var x1111 = x111 + diffX;
var y1111 = y111 + diffY;
var z1111 = z111 + diffZ;
var x11111 = (fov * x1111) / (z1111 + fov) + w / 2;
var y11111 = (fov * y1111) / (z1111 + fov) + h / 2;*/
var
wR
=
w
/
2
-
t
.
left
;
//fov * (x222 + diffX) = wR * ((z222 + diffZ) + fov)
//fov * x222 + fov * diffX = wR * z222 + wR * diffZ + wR * fov
//итого
//fov * x111 + fov * diffX = wL * z111 + wL * diffZ + wL * fov
//fov * x222 + fov * diffX = wR * z222 + wR * diffZ + wR * fov
/*diffX = (wL * z111 + wL * diffZ + wL * fov - fov * x111) / fov;
fov * x222 + wL * z111 + wL * diffZ + wL * fov - fov * x111 = wR * z222 + wR * diffZ + wR * fov
fov * x222 + wL * z111 + wL * fov - fov * x111 - wR * z222 - wR * fov = wR * diffZ - wL * diffZ*/
var
diffZ
=
(
fov
*
x222
+
wL
*
z111
+
wL
*
fov
-
fov
*
x111
-
wR
*
z222
-
wR
*
fov
)
/
(
wR
-
wL
);
var
diffX
=
(
wL
*
z111
+
wL
*
diffZ
+
wL
*
fov
-
fov
*
x111
)
/
fov
;
return
{
minZ
:
diffZ
,
diffX
:
diffX
};
};
var
diffXZ3
=
getDiffXZ3
(
x1
,
x2
,
z1
,
z2
,
y1
,
y2
);
return
{
minZ
:
diffXZ3
.
minZ
,
diffX
:
diffXZ3
.
diffX
};
};
Processor3D
.
prototype
.
_correctZPositionOY
=
function
(
x1
,
x2
,
z1
,
z2
,
minZ
,
y1
,
y2
)
{
var
t
=
this
;
var
getDiffXZ3
=
function
(
x1
,
x2
,
z1
,
z2
,
y1
,
y2
)
{
var
h
=
t
.
heightCanvas
;
var
fov
=
1
/
t
.
rPerspective
;
var
diffAndScalePoints
=
t
.
diffAndScale
(
x1
,
y1
,
z1
);
var
x11
=
diffAndScalePoints
.
x
;
var
y11
=
diffAndScalePoints
.
y
;
var
z11
=
diffAndScalePoints
.
z
;
var
rotatePoints
=
t
.
rotate
(
x11
,
y11
,
z11
);
var
y111
=
rotatePoints
.
y
;
var
z111
=
rotatePoints
.
z
;
/*var x1111 = x111 + diffX;
var y1111 = y111 + diffY;
var z1111 = z111 + diffZ;
var x11111 = (fov * x1111) / (z1111 + fov) + w / 2;
var y11111 = (fov * y1111) / (z1111 + fov) + h / 2;*/
//(fov * x1111) / (z1111 + fov) + w / 2 = t.left
//(fov * (x111 + diffX)) / ((z111 + diffZ) + fov) + w / 2 = t.left
//var wL = t.left - w / 2;
//fov * (x111 + diffX) = wL * ((z111 + diffZ) + fov)
//fov * x111 + fov * diffX = wL * z111 + wL * diffZ + wL * fov
diffAndScalePoints
=
t
.
diffAndScale
(
x2
,
y2
,
z2
);
var
x22
=
diffAndScalePoints
.
x
;
var
y22
=
diffAndScalePoints
.
y
;
var
z22
=
diffAndScalePoints
.
z
;
rotatePoints
=
t
.
rotate
(
x22
,
y22
,
z22
);
var
y222
=
rotatePoints
.
y
;
var
z222
=
rotatePoints
.
z
;
/*var x1111 = x111 + diffX;
var y1111 = y111 + diffY;
var z1111 = z111 + diffZ;
var x11111 = (fov * x1111) / (z1111 + fov) + w / 2;
var y11111 = (fov * y1111) / (z1111 + fov) + h / 2;*/
//(fov * (y111 + diffY)) / ((z111 + diffZ) + fov) + h / 2 = t.top
//(fov * (y222 + diffY)) / ((z222 + diffZ) + fov) + h / 2 = h - t.bottom
var
wL
=
t
.
top
-
h
/
2
;
var
wR
=
h
/
2
-
t
.
bottom
;
/*(fov * (y111 + diffY)) / ((z111 + diffZ) + fov) = wL
(fov * (y222 + diffY)) / ((z222 + diffZ) + fov) = wR
fov * (y111 + diffY) = wL * ((z111 + diffZ) + fov)
fov * y111 + fov * diffY = wL * z111 + wL * diffZ + wL * fov
fov * y222 + fov * diffY = wR * z222 + wR * diffZ + wR * fov
diffY = (wR * z222 + wR * diffZ + wR * fov - fov * y222) / fov
fov * y111 + wR * z222 + wR * diffZ + wR * fov - fov * y222 = wL * z111 + wL * diffZ + wL * fov
fov * y111 + wR * z222 + wR * fov - fov * y222 - wL * z111 - wL * fov = wL * diffZ - wR * diffZ*/
var
diffZ
=
(
fov
*
y111
+
wR
*
z222
+
wR
*
fov
-
fov
*
y222
-
wL
*
z111
-
wL
*
fov
)
/
(
wL
-
wR
);
var
diffY
=
(
wR
*
z222
+
wR
*
diffZ
+
wR
*
fov
-
fov
*
y222
)
/
fov
;
//var diffZ = (fov * x222 + wL * z111 + wL * fov - fov * x111 - wR * z222 - wR * fov) / (wR - wL);
//var diffX = (wL * z111 + wL * diffZ + wL * fov - fov * x111) / fov;
return
{
minZ
:
diffZ
,
diffY
:
diffY
};
};
var
diffXZ3
=
getDiffXZ3
(
x1
,
x2
,
z1
,
z2
,
y1
,
y2
);
return
{
minZ
:
diffXZ3
.
minZ
,
diffY
:
diffXZ3
.
diffY
};
};
Processor3D
.
prototype
.
_calculateCameraDiffZ
=
function
(
points
,
faces
)
{
var
widthCanvas
=
this
.
widthCanvas
;
var
originalWidthChart
=
widthCanvas
-
this
.
left
-
this
.
right
;
var
heightCanvas
=
this
.
heightCanvas
;
var
heightChart
=
heightCanvas
-
this
.
top
-
this
.
bottom
;
var
widthChart
=
originalWidthChart
;
var
depthChart
=
this
.
depthPerspective
;
var
minMaxOx
=
this
.
_getMinMaxOx
(
points
,
faces
);
var
point1
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostLeftPointX
.
x
,
minMaxOx
.
mostLeftPointX
.
y
,
minMaxOx
.
mostLeftPointX
.
z
,
true
);
var
point2
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostRightPointX
.
x
,
minMaxOx
.
mostRightPointX
.
y
,
minMaxOx
.
mostRightPointX
.
z
,
true
);
var
x1
=
point1
.
x
;
var
x2
=
point2
.
x
;
var
y1
=
point1
.
y
;
var
y2
=
point2
.
y
;
var
diffX
=
Math
.
abs
(
x1
-
x2
);
var
diffY
=
Math
.
abs
(
y1
-
y2
);
//TODO медленная функция, рассчитать сдвиги!
while
(
diffX
>
widthChart
||
diffY
>
heightChart
)
{
var
minMaxOx
=
this
.
_getMinMaxOx
(
points
,
faces
);
var
point1
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostLeftPointX
.
x
,
minMaxOx
.
mostLeftPointX
.
y
,
minMaxOx
.
mostLeftPointX
.
z
,
true
);
var
point2
=
this
.
convertAndTurnPoint
(
minMaxOx
.
mostRightPointX
.
x
,
minMaxOx
.
mostRightPointX
.
y
,
minMaxOx
.
mostRightPointX
.
z
,
true
);
var
x1
=
point1
.
x
;
var
x2
=
point2
.
x
;
var
y1
=
point1
.
y
;
var
y2
=
point2
.
y
;
var
leftMargin
=
this
.
left
-
x1
;
...
...
@@ -1106,8 +2007,6 @@ Processor3D.prototype._calculateCameraDiffX = function (minMaxOx)
//так ближе к тому, как смещает excel
var
left
=
this
.
left
;
var
right
=
this
.
right
;
var
widthCanvas
=
this
.
widthCanvas
;
var
originalWidthChart
=
widthCanvas
-
this
.
left
-
this
.
right
;
...
...
@@ -1235,8 +2134,6 @@ Processor3D.prototype._getMinMaxOy = function (points, faces)
var
point1
=
this
.
convertAndTurnPoint
(
points
[
faces
[
i
][
k
]].
x
,
points
[
faces
[
i
][
k
]].
y
,
points
[
faces
[
i
][
k
]].
z
,
true
);
var
point2
=
this
.
convertAndTurnPoint
(
points
[
faces
[
i
][
k
+
1
]].
x
,
points
[
faces
[
i
][
k
+
1
]].
y
,
points
[
faces
[
i
][
k
+
1
]].
z
,
true
);
var
x1
=
point1
.
x
;
var
x2
=
point2
.
x
;
var
y1
=
point1
.
y
;
var
y2
=
point2
.
y
;
...
...
@@ -1283,11 +2180,14 @@ Processor3D.prototype._calcAspectRatio = function()
var
aspectRatioX
=
1
;
var
aspectRatioY
=
1
;
var
sinOx
=
Math
.
sin
(
-
this
.
angleOx
);
var
sinOy
=
Math
.
sin
(
-
this
.
angleOy
);
var
subType
=
this
.
chartsDrawer
.
calcProp
.
subType
;
if
(
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
||
(
this
.
chartsDrawer
.
calcProp
.
type
===
"
Area
"
&&
subType
==
"
normal
"
))
if
((
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
)
&&
!
this
.
view3D
.
rAngAx
)
{
this
.
_calcSpecialStandardScaleX
();
aspectRatioX
=
(
widthOriginalChart
/
(
heightOriginalChart
/
hPercent
))
*
this
.
specialStandardScaleX
;
}
else
if
(
subType
===
"
standard
"
||
this
.
chartsDrawer
.
calcProp
.
type
===
"
Line
"
||
(
this
.
chartsDrawer
.
calcProp
.
type
===
"
Area
"
&&
subType
==
"
normal
"
))
{
var
seriesCount
=
this
.
chartsDrawer
.
calcProp
.
seriesCount
;
var
ptCount
=
this
.
chartsDrawer
.
calcProp
.
ptCount
;
...
...
@@ -1300,7 +2200,7 @@ Processor3D.prototype._calcAspectRatio = function()
else
if
(
hPercent
!==
null
)
//auto scale height
aspectRatioX
=
widthOriginalChart
/
(
heightOriginalChart
/
hPercent
);
if
(
aspectRatioX
<
1
)
if
(
aspectRatioX
<
1
&&
this
.
view3D
.
rAngAx
)
{
aspectRatioY
=
1
/
aspectRatioX
;
aspectRatioX
=
1
;
...
...
@@ -1413,13 +2313,19 @@ Point3D.prototype =
for
(
var
i
=
0
;
i
<
rowsA
;
i
++
)
C
[
i
]
=
[];
for
(
var
k
=
0
;
k
<
colsB
;
k
++
)
{
for
(
var
i
=
0
;
i
<
rowsA
;
i
++
)
{
var
temp
=
0
;
for
(
var
j
=
0
;
j
<
rowsB
;
j
++
)
temp
+=
A
[
i
][
j
]
*
B
[
j
][
k
];
{
for
(
var
i
=
0
;
i
<
rowsA
;
i
++
)
{
var
temp
=
0
;
for
(
var
j
=
0
;
j
<
rowsB
;
j
++
)
{
temp
+=
A
[
i
][
j
]
*
B
[
j
][
k
];
}
C
[
i
][
k
]
=
temp
;
}
}
return
C
;
}
}
\ No newline at end of file
};
common/Charts/ChartsDrawer.js
View file @
36d3e018
...
...
@@ -193,6 +193,13 @@ CChartsDrawer.prototype =
this
.
gridChart
.
draw
(
this
);
}
if
(
this
.
nDimensionCount
===
3
)
{
this
.
cShapeDrawer
.
bIsNoSmartAttack
=
true
;
this
.
chart
.
draw
(
this
);
this
.
cShapeDrawer
.
bIsNoSmartAttack
=
false
;
}
if
(
this
.
calcProp
.
type
!=
"
Pie
"
&&
this
.
calcProp
.
type
!=
"
DoughnutChart
"
)
{
this
.
catAxisChart
.
draw
(
this
);
...
...
@@ -200,10 +207,13 @@ CChartsDrawer.prototype =
this
.
serAxisChart
.
draw
(
this
);
}
if
(
this
.
nDimensionCount
!==
3
)
{
this
.
cShapeDrawer
.
bIsNoSmartAttack
=
true
;
this
.
chart
.
draw
(
this
);
this
.
cShapeDrawer
.
bIsNoSmartAttack
=
false
;
}
}
},
...
...
@@ -669,10 +679,12 @@ CChartsDrawer.prototype =
var
valAx
=
chartSpace
.
chart
.
plotArea
.
valAx
;
var
catAx
=
chartSpace
.
chart
.
plotArea
.
catAx
;
var
orientationValAx
=
valAx
&&
valAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
?
true
:
false
;
var
orientationCatAx
=
catAx
&&
catAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
?
true
:
false
;
if
(
isHBar
===
'
HBar
'
&&
catAx
&&
valAx
&&
catAx
.
yPoints
&&
valAx
.
xPoints
)
{
if
(
catAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
)
if
(
orientationCatAx
)
{
if
(
valAx
.
crossBetween
==
CROSS_BETWEEN_BETWEEN
)
leftDownPointY
=
catAx
.
yPoints
[
0
].
pos
+
Math
.
abs
((
catAx
.
interval
)
/
2
);
...
...
@@ -688,14 +700,14 @@ CChartsDrawer.prototype =
}
if
(
valAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
)
if
(
orientationValAx
)
leftDownPointX
=
valAx
.
xPoints
[
0
].
pos
;
else
leftDownPointX
=
valAx
.
xPoints
[
valAx
.
xPoints
.
length
-
1
].
pos
;
if
(
catAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
)
if
(
orientationCatAx
)
{
if
(
valAx
.
crossBetween
==
CROSS_BETWEEN_BETWEEN
)
rightUpPointY
=
catAx
.
yPoints
[
catAx
.
yPoints
.
length
-
1
].
pos
-
Math
.
abs
((
catAx
.
interval
)
/
2
);
...
...
@@ -711,7 +723,7 @@ CChartsDrawer.prototype =
}
if
(
valAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
)
if
(
orientationValAx
)
rightUpPointX
=
valAx
.
xPoints
[
valAx
.
xPoints
.
length
-
1
].
pos
;
else
rightUpPointX
=
valAx
.
xPoints
[
0
].
pos
;
...
...
@@ -747,10 +759,10 @@ CChartsDrawer.prototype =
else
if
(
isHBar
===
'
Scatter
'
&&
catAx
&&
valAx
&&
catAx
.
xPoints
&&
valAx
.
yPoints
)
{
leftDownPointX
=
catAx
.
xPoints
[
0
].
pos
;
leftDownPointY
=
valAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
?
valAx
.
yPoints
[
0
].
pos
:
valAx
.
yPoints
[
valAx
.
yPoints
.
length
-
1
].
pos
;
leftDownPointY
=
orientationValAx
?
valAx
.
yPoints
[
0
].
pos
:
valAx
.
yPoints
[
valAx
.
yPoints
.
length
-
1
].
pos
;
rightUpPointX
=
catAx
.
xPoints
[
catAx
.
xPoints
.
length
-
1
].
pos
;
rightUpPointY
=
valAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
?
valAx
.
yPoints
[
valAx
.
yPoints
.
length
-
1
].
pos
:
valAx
.
yPoints
[
0
].
pos
;
rightUpPointY
=
orientationValAx
?
valAx
.
yPoints
[
valAx
.
yPoints
.
length
-
1
].
pos
:
valAx
.
yPoints
[
0
].
pos
;
if
(
valAx
.
labels
&&
!
valAx
.
bDelete
)
{
...
...
@@ -781,7 +793,7 @@ CChartsDrawer.prototype =
}
else
if
(
isHBar
!==
undefined
&&
valAx
&&
catAx
&&
catAx
.
xPoints
&&
valAx
.
yPoints
)
{
if
(
catAx
.
scaling
.
orientation
!=
ORIENTATION_MIN_MAX
)
if
(
!
orientationCatAx
)
{
leftDownPointX
=
catAx
.
xPoints
[
catAx
.
xPoints
.
length
-
1
].
pos
-
Math
.
abs
((
catAx
.
interval
)
/
2
);
}
...
...
@@ -793,13 +805,13 @@ CChartsDrawer.prototype =
leftDownPointX
=
catAx
.
xPoints
[
0
].
pos
;
}
if
(
valAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
)
if
(
orientationValAx
)
leftDownPointY
=
valAx
.
yPoints
[
0
].
pos
;
else
leftDownPointY
=
valAx
.
yPoints
[
valAx
.
yPoints
.
length
-
1
].
pos
;
if
(
catAx
.
scaling
.
orientation
!=
ORIENTATION_MIN_MAX
)
if
(
!
orientationCatAx
)
{
rightUpPointX
=
catAx
.
xPoints
[
0
].
pos
;
}
...
...
@@ -812,7 +824,7 @@ CChartsDrawer.prototype =
}
if
(
valAx
.
scaling
.
orientation
==
ORIENTATION_MIN_MAX
)
if
(
orientationValAx
)
rightUpPointY
=
valAx
.
yPoints
[
valAx
.
yPoints
.
length
-
1
].
pos
;
else
rightUpPointY
=
valAx
.
yPoints
[
0
].
pos
;
...
...
@@ -2057,6 +2069,24 @@ CChartsDrawer.prototype =
return
this
.
processor3D
.
convertAndTurnPoint
(
x
,
y
,
z
);
},
//position of catAx labels(left or right) - returns false(left of axis)/true(right of axis) or null(standard position)
calculatePositionLabelsCatAxFromAngle
:
function
(
chartSpace
)
{
var
res
=
null
;
var
angleOy
=
chartSpace
.
chart
.
view3D
&&
chartSpace
.
chart
.
view3D
.
rotY
?
(
-
chartSpace
.
chart
.
view3D
.
rotY
/
360
)
*
(
Math
.
PI
*
2
)
:
0
;
if
(
chartSpace
.
chart
.
view3D
&&
!
chartSpace
.
chart
.
view3D
.
rAngAx
&&
angleOy
!==
0
)
{
var
angleOy
=
Math
.
abs
(
angleOy
);
if
(
angleOy
>=
Math
.
PI
/
2
&&
angleOy
<
3
*
Math
.
PI
/
2
)
res
=
true
;
else
res
=
false
;
}
return
res
;
},
//****accessory functions****
...
...
@@ -2501,7 +2531,7 @@ CChartsDrawer.prototype =
var
chart
=
chartSpace
&&
chartSpace
.
chart
?
chartSpace
.
chart
.
plotArea
.
chart
:
null
;
var
typeChart
=
chart
?
chart
.
getObjectType
()
:
null
;
if
(
isTurnOn3DCharts
&&
chartSpace
&&
chartSpace
.
chart
.
view3D
&&
chartSpace
.
chart
.
view3D
.
rAngAx
&&
((
typeChart
===
historyitem_type_BarChart
&&
chart
&&
chart
.
barDir
!==
BAR_DIR_BAR
)
||
(
typeChart
===
historyitem_type_LineChart
)
||
(
typeChart
===
historyitem_type_BarChart
&&
chart
.
barDir
===
BAR_DIR_BAR
)
/*|| (typeChart === historyitem_type_AreaChart)*/
||
(
typeChart
===
historyitem_type_PieChart
)))
if
(
isTurnOn3DCharts
&&
chartSpace
&&
chartSpace
.
chart
.
view3D
/*&& chartSpace.chart.view3D.rAngAx*/
&&
((
typeChart
===
historyitem_type_BarChart
&&
chart
&&
chart
.
barDir
!==
BAR_DIR_BAR
)
||
(
typeChart
===
historyitem_type_LineChart
)
||
(
typeChart
===
historyitem_type_BarChart
&&
chart
.
barDir
===
BAR_DIR_BAR
)
/*|| (typeChart === historyitem_type_AreaChart)*/
||
(
typeChart
===
historyitem_type_PieChart
)))
{
res
=
true
;
}
...
...
@@ -2904,9 +2934,53 @@ drawBarChart.prototype =
_DrawBars3D
:
function
()
{
var
t
=
this
;
var
draw
=
function
(
onlyLessNull
)
var
processor3D
=
this
.
cChartDrawer
.
processor3D
;
var
directionDraw
=
{
onPoints
:
0
,
reversePointsOnPoints
:
1
,
reverseSeriesOnPoints
:
2
,
reverseSeriesPointsOnPoints
:
3
,
onSeries
:
4
,
reversePointsOnSeries
:
5
,
reverseSeriesOnSeries
:
6
,
reversePointsSeriesOnSeries
:
7
};
var
verges
=
{
front
:
0
,
down
:
1
,
left
:
2
,
right
:
3
,
up
:
4
,
unfront
:
5
};
var
drawVerges
=
function
(
j
,
i
,
onlyLessNull
,
start
,
stop
)
{
var
brush
,
pen
,
options
;
options
=
t
.
_getOptionsForDrawing
(
j
,
i
,
onlyLessNull
);
if
(
options
!==
null
)
{
pen
=
options
.
pen
;
brush
=
options
.
brush
;
for
(
var
k
=
start
;
k
<=
stop
;
k
++
)
{
t
.
_drawBar3D
(
t
.
paths
.
series
[
j
][
i
][
k
],
pen
,
brush
,
k
);
}
}
};
//рисуем по точкам
var
onPoints
=
function
(
onlyLessNull
)
{
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
i
=
0
;
i
<
t
.
chartProp
.
ptCount
;
i
++
)
{
if
(
!
t
.
paths
.
series
)
...
...
@@ -2914,26 +2988,41 @@ drawBarChart.prototype =
for
(
var
j
=
0
;
j
<
t
.
paths
.
series
.
length
;
++
j
)
{
options
=
t
.
_getOptionsForDrawing
(
j
,
i
,
onlyLessNull
);
if
(
options
!==
null
)
{
pen
=
options
.
pen
;
brush
=
options
.
brush
;
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
else
continue
;
}
}
;
for
(
var
k
=
0
;
k
<
t
.
paths
.
series
[
j
][
i
].
length
;
k
++
)
var
angleOx
=
Math
.
abs
(
processor3D
.
angleOx
);
var
angleOy
=
Math
.
abs
(
processor3D
.
angleOy
);
if
(
angleOx
===
0
)
//тестировал все повороты вокруг OY, без обратных осей
{
t
.
_drawBar3D
(
t
.
paths
.
series
[
j
][
i
][
k
],
pen
,
brush
,
k
);
drawNeedVerge
(
verges
.
down
,
verges
.
up
);
drawNeedVerge
(
verges
.
unfront
,
verges
.
unfront
);
drawNeedVerge
(
verges
.
front
,
verges
.
front
);
}
else
if
(
angleOx
!==
0
&&
angleOy
===
0
)
{
drawNeedVerge
(
verges
.
right
,
verges
.
right
);
drawNeedVerge
(
verges
.
left
,
verges
.
left
);
drawNeedVerge
(
verges
.
unfront
,
verges
.
unfront
);
drawNeedVerge
(
verges
.
up
,
verges
.
up
);
drawNeedVerge
(
verges
.
down
,
verges
.
down
);
drawNeedVerge
(
verges
.
front
,
verges
.
front
);
}
else
{
drawNeedVerge
(
verges
.
down
,
verges
.
up
);
drawNeedVerge
(
verges
.
unfront
,
verges
.
unfront
);
drawNeedVerge
(
verges
.
front
,
verges
.
front
);
}
};
var
drawReverse
=
function
(
onlyLessNull
)
var
reverseSeriesOnPoints
=
function
(
onlyLessNull
)
{
var
drawNeedVerge
=
function
(
start
,
stop
)
{
var
brush
,
pen
,
options
;
for
(
var
i
=
0
;
i
<
t
.
chartProp
.
ptCount
;
i
++
)
{
if
(
!
t
.
paths
.
series
)
...
...
@@ -2941,72 +3030,315 @@ drawBarChart.prototype =
for
(
var
j
=
t
.
paths
.
series
.
length
-
1
;
j
>=
0
;
--
j
)
{
options
=
t
.
_getOptionsForDrawing
(
j
,
i
,
onlyLessNull
);
if
(
options
!==
null
)
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
}
};
drawNeedVerge
(
verges
.
front
,
verges
.
unfront
);
};
var
reverseSeriesPointsOnPoints
=
function
(
onlyLessNull
)
{
pen
=
options
.
pen
;
brush
=
options
.
brush
;
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
i
=
t
.
chartProp
.
ptCount
-
1
;
i
>=
0
;
--
i
)
{
if
(
!
t
.
paths
.
series
)
return
;
for
(
var
j
=
t
.
paths
.
series
.
length
-
1
;
j
>=
0
;
--
j
)
{
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
else
continue
;
}
}
;
for
(
var
k
=
0
;
k
<
t
.
paths
.
series
[
j
][
i
].
length
;
k
++
)
drawNeedVerge
(
verges
.
down
,
verges
.
unfront
);
drawNeedVerge
(
verges
.
front
,
verges
.
front
);
};
var
reversePointsOnPoints
=
function
(
onlyLessNull
)
{
t
.
_drawBar3D
(
t
.
paths
.
series
[
j
][
i
][
k
],
pen
,
brush
,
k
);
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
i
=
t
.
chartProp
.
ptCount
-
1
;
i
>=
0
;
--
i
)
{
if
(
!
t
.
paths
.
series
)
return
;
for
(
var
j
=
0
;
j
<
t
.
paths
.
series
.
length
;
j
++
)
{
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
}
};
drawNeedVerge
(
verges
.
front
,
verges
.
unfront
);
};
//рисуем по сериям
var
onSeries
=
function
(
onlyLessNull
)
{
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
j
=
0
;
j
<
t
.
paths
.
series
.
length
;
j
++
)
{
if
(
!
t
.
paths
.
series
)
return
;
for
(
var
i
=
0
;
i
<
t
.
chartProp
.
ptCount
;
i
++
)
{
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
}
};
if
(
this
.
chartProp
.
subType
===
"
standard
"
)
drawNeedVerge
(
verges
.
front
,
verges
.
unfront
);
};
var
reversePointsOnSeries
=
function
(
onlyLessNull
)
{
//вторую половину с конца рисуем
var
brush
,
pen
,
options
;
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
j
=
0
;
j
<
t
.
paths
.
series
.
length
;
j
++
)
{
if
(
!
t
.
paths
.
series
)
return
;
if
(
!
this
.
paths
.
series
)
for
(
var
i
=
t
.
chartProp
.
ptCount
-
1
;
i
>=
0
;
i
--
)
{
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
}
};
drawNeedVerge
(
verges
.
front
,
verges
.
unfront
);
};
var
reverseSeriesOnSeries
=
function
(
onlyLessNull
)
{
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
j
=
t
.
paths
.
series
.
length
-
1
;
j
>=
0
;
j
--
)
{
if
(
!
t
.
paths
.
series
)
return
;
for
(
var
i
=
this
.
paths
.
series
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
var
j
=
this
.
chartProp
.
ptCount
-
1
;
j
>=
0
;
j
--
)
{
for
(
var
i
=
0
;
i
<
t
.
chartProp
.
ptCount
;
i
++
)
{
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
}
};
options
=
t
.
_getOptionsForDrawing
(
i
,
j
);
if
(
options
!==
null
)
drawNeedVerge
(
verges
.
front
,
verges
.
unfront
);
};
var
reversePointsSeriesOnSeries
=
function
(
onlyLessNull
)
{
pen
=
options
.
pen
;
brush
=
options
.
brush
;
var
drawNeedVerge
=
function
(
start
,
stop
)
{
for
(
var
j
=
t
.
paths
.
series
.
length
-
1
;
j
>=
0
;
j
--
)
{
if
(
!
t
.
paths
.
series
)
return
;
for
(
var
i
=
t
.
chartProp
.
ptCount
-
1
;
i
>=
0
;
i
--
)
{
drawVerges
(
j
,
i
,
onlyLessNull
,
start
,
stop
);
}
else
continue
;
}
}
;
for
(
var
k
=
0
;
k
<
this
.
paths
.
series
[
i
][
j
].
length
;
k
++
)
drawNeedVerge
(
verges
.
front
,
verges
.
unfront
);
};
var
direction
=
this
.
_calculateDirectionDraw3D
(
directionDraw
);
for
(
var
n
=
0
;
n
<
direction
.
length
;
n
++
)
{
this
.
_drawBar3D
(
this
.
paths
.
series
[
i
][
j
][
k
],
pen
,
brush
,
k
);
switch
(
direction
[
n
].
res
)
{
case
directionDraw
.
onPoints
:
{
onPoints
(
direction
[
n
].
isLess
);
break
;
}
case
directionDraw
.
reversePointsOnPoints
:
{
reversePointsOnPoints
(
direction
[
n
].
isLess
);
break
;
}
case
directionDraw
.
reverseSeriesOnPoints
:
{
reverseSeriesOnPoints
(
direction
[
n
].
isLess
);
break
;
}
case
directionDraw
.
reverseSeriesPointsOnPoints
:
{
reverseSeriesPointsOnPoints
(
direction
[
n
].
isLess
);
break
;
}
else
if
(
this
.
chartProp
.
subType
==
"
stacked
"
||
this
.
chartProp
.
subType
==
"
stackedPer
"
)
case
directionDraw
.
onSeries
:
{
if
(
this
.
cChartSpace
.
chart
.
plotArea
.
valAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
onSeries
(
direction
[
n
].
isLess
);
break
;
}
case
directionDraw
.
reversePointsOnSeries
:
{
drawReverse
(
true
);
draw
(
false
);
reversePointsOnSeries
(
direction
[
n
].
isLess
);
break
;
}
case
directionDraw
.
reverseSeriesOnSeries
:
{
reverseSeriesOnSeries
(
direction
[
n
].
isLess
);
break
;
}
case
directionDraw
.
reversePointsSeriesOnSeries
:
{
reversePointsSeriesOnSeries
(
direction
[
n
].
isLess
);
break
;
}
}
}
},
_calculateDirectionDraw3D
:
function
(
directionDraw
)
{
var
res
=
[];
var
processor3D
=
this
.
cChartDrawer
.
processor3D
;
var
t
=
this
;
//NOT PERSPECTIVE
var
calculateDirectionNoPerspective
=
function
()
{
if
(
t
.
cChartSpace
.
chart
.
view3D
.
rAngAx
)
{
if
(
t
.
chartProp
.
subType
===
"
standard
"
)
{
res
.
push
({
res
:
directionDraw
.
reversePointsSeriesOnSeries
,
isLess
:
false
});
}
else
if
(
t
.
chartProp
.
subType
==
"
stacked
"
||
t
.
chartProp
.
subType
==
"
stackedPer
"
)
{
if
(
t
.
cChartSpace
.
chart
.
plotArea
.
valAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
false
});
}
else
{
drawReverse
(
false
);
draw
(
true
);
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
false
});
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
true
});
}
}
else
{
if
(
t
.
cChartSpace
.
chart
.
plotArea
.
catAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
{
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
false
});
}
else
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
false
});
}
}
}
};
//PERSPECTIVE
var
calculateDirectionPerspective
=
function
()
{
if
(
t
.
chartProp
.
subType
===
"
standard
"
)
{
var
angle
=
Math
.
abs
(
processor3D
.
angleOy
);
if
(
angle
<=
Math
.
PI
/
2
)
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnSeries
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnSeries
,
isLess
:
false
});
}
else
if
(
angle
<=
Math
.
PI
)
{
res
.
push
({
res
:
directionDraw
.
onSeries
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
onSeries
,
isLess
:
false
});
}
else
if
(
angle
<=
(
3
/
2
)
*
Math
.
PI
)
{
res
.
push
({
res
:
directionDraw
.
reversePointsOnSeries
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
reversePointsOnSeries
,
isLess
:
false
});
}
else
{
if
(
this
.
cChartSpace
.
chart
.
plotArea
.
catAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
draw
();
res
.
push
({
res
:
directionDraw
.
reversePointsSeriesOnSeries
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
reversePointsSeriesOnSeries
,
isLess
:
false
});
}
}
else
if
(
t
.
chartProp
.
subType
==
"
stacked
"
||
t
.
chartProp
.
subType
==
"
stackedPer
"
)
{
if
(
Math
.
abs
(
processor3D
.
angleOy
)
>
Math
.
PI
)
{
if
(
t
.
cChartSpace
.
chart
.
plotArea
.
valAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
{
res
.
push
({
res
:
directionDraw
.
reversePointsOnPoints
,
isLess
:
false
});
}
else
drawReverse
();
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
false
});
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
true
});
}
}
else
{
if
(
t
.
cChartSpace
.
chart
.
plotArea
.
valAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
false
});
}
else
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
false
});
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
true
});
}
}
}
else
{
if
(
t
.
cChartSpace
.
chart
.
plotArea
.
catAx
.
scaling
.
orientation
===
ORIENTATION_MIN_MAX
)
{
if
(
Math
.
abs
(
processor3D
.
angleOy
)
>
Math
.
PI
)
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesPointsOnPoints
,
isLess
:
false
});
res
.
push
({
res
:
directionDraw
.
reverseSeriesPointsOnPoints
,
isLess
:
true
});
}
else
{
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
true
});
res
.
push
({
res
:
directionDraw
.
onPoints
,
isLess
:
false
});
}
}
else
{
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
false
});
res
.
push
({
res
:
directionDraw
.
reverseSeriesOnPoints
,
isLess
:
true
});
}
}
};
if
(
t
.
cChartSpace
.
chart
.
view3D
.
rAngAx
)
{
calculateDirectionNoPerspective
();
}
else
{
calculateDirectionPerspective
();
}
return
res
;
},
_getOptionsForDrawing
:
function
(
ser
,
point
,
onlyLessNull
)
...
...
@@ -3523,27 +3855,80 @@ drawLineChart.prototype =
_drawLines3D
:
function
()
{
//вторую половину с конца рисуем
var
t
=
this
;
var
drawVerges
=
function
(
j
,
i
,
onlyLessNull
)
{
var
brush
,
pen
,
seria
;
for
(
var
i
=
this
.
paths
.
series
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
var
j
=
0
;
j
<
this
.
chartProp
.
ptCount
;
j
++
)
{
seria
=
this
.
chartProp
.
series
[
i
];
seria
=
t
.
chartProp
.
series
[
j
];
brush
=
seria
.
brush
;
pen
=
seria
.
pen
;
if
(
!
this
.
paths
.
series
[
i
]
||
!
this
.
paths
.
series
[
i
][
j
]
||
!
seria
.
val
.
numRef
.
numCache
.
pts
[
j
])
continue
;
if
(
!
(
!
t
.
paths
.
series
[
j
]
||
!
t
.
paths
.
series
[
j
][
i
]
||
!
seria
.
val
.
numRef
.
numCache
.
pts
[
i
]))
{
if
(
seria
.
val
.
numRef
.
numCache
.
pts
[
i
].
pen
)
pen
=
seria
.
val
.
numRef
.
numCache
.
pts
[
i
].
pen
;
if
(
seria
.
val
.
numRef
.
numCache
.
pts
[
i
].
brush
)
brush
=
seria
.
val
.
numRef
.
numCache
.
pts
[
i
].
brush
;
if
(
seria
.
val
.
numRef
.
numCache
.
pts
[
j
].
pen
)
pen
=
seria
.
val
.
numRef
.
numCache
.
pts
[
j
].
pen
;
if
(
seria
.
val
.
numRef
.
numCache
.
pts
[
j
].
brush
)
brush
=
seria
.
val
.
numRef
.
numCache
.
pts
[
j
].
brush
;
for
(
var
k
=
0
;
k
<
t
.
paths
.
series
[
j
][
i
].
length
;
k
++
)
{
t
.
_drawLine3D
(
t
.
paths
.
series
[
j
][
i
][
k
],
pen
,
brush
,
k
);
}
}
};
for
(
var
k
=
0
;
k
<
this
.
paths
.
series
[
i
][
j
].
length
;
k
++
)
//рисуем по сериям
var
onSeries
=
function
(
onlyLessNull
)
{
var
drawNeedVerge
=
function
()
{
for
(
var
j
=
0
;
j
<
t
.
paths
.
series
.
length
;
j
++
)
{
for
(
var
i
=
0
;
i
<
t
.
chartProp
.
ptCount
;
i
++
)
{
drawVerges
(
j
,
i
,
onlyLessNull
);
}
}
};
drawNeedVerge
();
};
var
reverseSeriesOnSeries
=
function
(
onlyLessNull
)
{
this
.
_drawLine3D
(
this
.
paths
.
series
[
i
][
j
][
k
],
pen
,
brush
,
k
);
var
drawNeedVerge
=
function
()
{
for
(
var
j
=
t
.
paths
.
series
.
length
-
1
;
j
>=
0
;
j
--
)
{
if
(
!
t
.
paths
.
series
)
return
;
for
(
var
i
=
0
;
i
<
t
.
chartProp
.
ptCount
;
i
++
)
{
drawVerges
(
j
,
i
,
onlyLessNull
);
}
}
};
drawNeedVerge
();
};
if
(
!
this
.
cChartDrawer
.
processor3D
.
view3D
.
rAngAx
)
{
var
angle
=
Math
.
abs
(
this
.
cChartDrawer
.
processor3D
.
angleOy
);
if
(
angle
>
Math
.
PI
/
2
&&
angle
<
3
*
Math
.
PI
/
2
)
onSeries
();
else
reverseSeriesOnSeries
();
}
else
{
reverseSeriesOnSeries
();
}
},
...
...
@@ -8980,6 +9365,9 @@ gridChart.prototype =
}
}
//для того, чтобы отрисовывался один параллелепипед. необходимо верхний FOR закомментировать и раскомментировать то, что внизу. + убрать отрисовку самого chart'a
//this.paths.horisontalLines = [];
//this.paths.horisontalLines.push(this._calculate3DParallalepiped());
},
_calculateVerticalLines
:
function
()
...
...
@@ -9153,6 +9541,91 @@ gridChart.prototype =
return
path
;
},
_calculate3DParallalepiped
:
function
()
{
var
path
=
new
Path
();
var
pathH
=
this
.
chartProp
.
pathH
;
var
pathW
=
this
.
chartProp
.
pathW
;
var
gdLst
=
[];
path
.
pathH
=
pathH
;
path
.
pathW
=
pathW
;
gdLst
[
"
w
"
]
=
1
;
gdLst
[
"
h
"
]
=
1
;
var
perspectiveDepth
=
this
.
cChartDrawer
.
processor3D
.
depthPerspective
;
var
left
=
this
.
chartProp
.
chartGutter
.
_left
;
var
right
=
this
.
chartProp
.
chartGutter
.
_right
;
var
top
=
this
.
chartProp
.
chartGutter
.
_top
;
var
bottom
=
this
.
chartProp
.
chartGutter
.
_bottom
;
var
height
=
this
.
chartProp
.
heightCanvas
-
(
top
+
bottom
);
var
width
=
this
.
chartProp
.
widthCanvas
-
(
left
+
right
);
var
point0
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
,
top
,
perspectiveDepth
);
var
x0
=
point0
.
x
;
var
y0
=
point0
.
y
;
var
point1
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
,
top
+
height
,
perspectiveDepth
);
var
x1
=
point1
.
x
;
var
y1
=
point1
.
y
;
var
point2
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
+
width
,
top
+
height
,
perspectiveDepth
);
var
x2
=
point2
.
x
;
var
y2
=
point2
.
y
;
var
point3
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
+
width
,
top
,
perspectiveDepth
);
var
x3
=
point3
.
x
;
var
y3
=
point3
.
y
;
var
point4
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
+
width
,
top
,
0
);
var
x4
=
point4
.
x
;
var
y4
=
point4
.
y
;
var
point5
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
+
width
,
top
+
height
,
0
);
var
x5
=
point5
.
x
;
var
y5
=
point5
.
y
;
var
point6
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
,
top
+
height
,
0
);
var
x6
=
point6
.
x
;
var
y6
=
point6
.
y
;
var
point7
=
this
.
cChartDrawer
.
_convertAndTurnPoint
(
left
,
top
,
0
);
var
x7
=
point7
.
x
;
var
y7
=
point7
.
y
;
path
.
stroke
=
true
;
var
pxToMm
=
this
.
chartProp
.
pxToMM
;
path
.
moveTo
(
x0
/
pxToMm
*
pathW
,
y0
/
pxToMm
*
pathH
);
path
.
lnTo
(
x1
/
pxToMm
*
pathW
,
y1
/
pxToMm
*
pathH
);
path
.
lnTo
(
x2
/
pxToMm
*
pathW
,
y2
/
pxToMm
*
pathH
);
path
.
lnTo
(
x3
/
pxToMm
*
pathW
,
y3
/
pxToMm
*
pathH
);
path
.
lnTo
(
x4
/
pxToMm
*
pathW
,
y4
/
pxToMm
*
pathH
);
path
.
lnTo
(
x5
/
pxToMm
*
pathW
,
y5
/
pxToMm
*
pathH
);
path
.
lnTo
(
x6
/
pxToMm
*
pathW
,
y6
/
pxToMm
*
pathH
);
path
.
lnTo
(
x7
/
pxToMm
*
pathW
,
y7
/
pxToMm
*
pathH
);
path
.
lnTo
(
x0
/
pxToMm
*
pathW
,
y0
/
pxToMm
*
pathH
);
path
.
lnTo
(
x1
/
pxToMm
*
pathW
,
y1
/
pxToMm
*
pathH
);
path
.
lnTo
(
x6
/
pxToMm
*
pathW
,
y6
/
pxToMm
*
pathH
);
path
.
lnTo
(
x5
/
pxToMm
*
pathW
,
y5
/
pxToMm
*
pathH
);
path
.
lnTo
(
x2
/
pxToMm
*
pathW
,
y2
/
pxToMm
*
pathH
);
path
.
lnTo
(
x3
/
pxToMm
*
pathW
,
y3
/
pxToMm
*
pathH
);
path
.
lnTo
(
x0
/
pxToMm
*
pathW
,
y0
/
pxToMm
*
pathH
);
path
.
lnTo
(
x7
/
pxToMm
*
pathW
,
y7
/
pxToMm
*
pathH
);
path
.
lnTo
(
x4
/
pxToMm
*
pathW
,
y4
/
pxToMm
*
pathH
);
path
.
recalculate
(
gdLst
);
return
path
;
},
_drawHorisontalLines
:
function
()
{
var
pen
;
...
...
common/Drawings/Format/ChartSpace.js
View file @
36d3e018
...
...
@@ -2913,6 +2913,15 @@ CChartSpace.prototype =
return
true
;
},
getNeedReflect
:
function
()
{
if
(
!
this
.
chartObj
)
{
this
.
chartObj
=
new
CChartsDrawer
();
}
return
this
.
chartObj
.
calculatePositionLabelsCatAxFromAngle
(
this
);
},
recalculateAxis
:
function
()
{
if
(
this
.
chart
&&
this
.
chart
.
plotArea
&&
this
.
chart
.
plotArea
.
chart
)
...
...
@@ -2999,6 +3008,8 @@ CChartSpace.prototype =
}
return
;
}
var
bNeedReflect
=
this
.
getNeedReflect
();
if
(
chart_type
===
historyitem_type_ScatterChart
)
{
var
x_ax
,
y_ax
;
...
...
@@ -3171,7 +3182,14 @@ CChartSpace.prototype =
{
left_align_labels
=
false
;
if
(
bNeedReflect
)
{
right_gap
=
Math
.
max
(
last_hor_label_half_width
,
0
);
}
else
{
right_gap
=
Math
.
max
(
last_hor_label_half_width
,
y_ax
.
labels
.
extX
);
}
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
right_gap
-
first_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
for
(
i
=
0
;
i
<
arr_x_val
.
length
;
++
i
)
{
...
...
@@ -3182,8 +3200,15 @@ CChartSpace.prototype =
break
;
}
case
TICK_LABEL_POSITION_LOW
:
{
if
(
bNeedReflect
)
{
left_gap
=
Math
.
max
(
first_hor_label_half_width
,
0
);
}
else
{
left_gap
=
Math
.
max
(
first_hor_label_half_width
,
y_ax
.
labels
.
extX
);
}
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
left_gap
-
last_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
for
(
i
=
0
;
i
<
arr_x_val
.
length
;
++
i
)
{
...
...
@@ -3209,7 +3234,14 @@ CChartSpace.prototype =
if
(
y_ax
.
crosses
===
CROSSES_MAX
)
{
left_align_labels
=
false
;
if
(
bNeedReflect
)
{
right_gap
=
Math
.
max
(
right_gap
,
0
);
}
else
{
right_gap
=
Math
.
max
(
right_gap
,
y_ax
.
labels
.
extX
);
}
y_ax
.
labels
.
x
=
rect
.
x
+
rect
.
w
-
right_gap
;
y_ax
.
xPos
=
rect
.
x
+
rect
.
w
-
right_gap
;
...
...
@@ -3222,7 +3254,7 @@ CChartSpace.prototype =
else
{
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
first_hor_label_half_width
-
last_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
if
(
first_hor_label_half_width
+
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
<
y_ax
.
labels
.
extX
)
if
(
!
bNeedReflect
&&
first_hor_label_half_width
+
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
<
y_ax
.
labels
.
extX
)
{
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
y_ax
.
labels
.
extX
-
last_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
crosses
));
}
...
...
@@ -3242,8 +3274,15 @@ CChartSpace.prototype =
switch
(
labels_pos
)
{
case
TICK_LABEL_POSITION_HIGH
:
{
if
(
bNeedReflect
)
{
left_gap
=
Math
.
max
(
0
,
last_hor_label_half_width
);
}
else
{
left_gap
=
Math
.
max
(
y_ax
.
labels
.
extX
,
last_hor_label_half_width
);
}
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
left_gap
-
first_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
y_ax
.
xPos
=
rect
.
x
+
rect
.
w
-
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
-
first_hor_label_half_width
;
...
...
@@ -3258,7 +3297,14 @@ CChartSpace.prototype =
{
left_align_labels
=
false
;
if
(
bNeedReflect
)
{
right_gap
=
Math
.
max
(
0
,
first_hor_label_half_width
);
}
else
{
right_gap
=
Math
.
max
(
y_ax
.
labels
.
extX
,
first_hor_label_half_width
);
}
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
right_gap
-
last_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
y_ax
.
xPos
=
rect
.
x
+
rect
.
w
-
right_gap
-
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
;
for
(
i
=
0
;
i
<
arr_x_val
.
length
;
++
i
)
...
...
@@ -3283,8 +3329,15 @@ CChartSpace.prototype =
{
//TICK_LABEL_POSITION_NEXT_TO рядом с осью
if
(
y_ax
.
crosses
===
CROSSES_MAX
)
{
if
(
bNeedReflect
)
{
left_gap
=
Math
.
max
(
0
,
last_hor_label_half_width
);
}
else
{
left_gap
=
Math
.
max
(
y_ax
.
labels
.
extX
,
last_hor_label_half_width
);
}
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
left_gap
-
first_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
y_ax
.
xPos
=
rect
.
x
+
rect
.
w
-
first_hor_label_half_width
-
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
;
y_ax
.
labels
.
x
=
y_ax
.
xPos
-
((
arr_x_val
[
arr_x_val
.
length
-
1
]
-
crosses
)
*
hor_interval_width
)
-
y_ax
.
labels
.
extX
;
...
...
@@ -3293,7 +3346,7 @@ CChartSpace.prototype =
{
left_align_labels
=
false
;
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
first_hor_label_half_width
-
last_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
arr_x_val
[
0
]));
if
(
first_hor_label_half_width
+
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
<
y_ax
.
labels
.
extX
)
if
(
!
bNeedReflect
&&
first_hor_label_half_width
+
(
crosses
-
arr_x_val
[
0
])
*
hor_interval_width
<
y_ax
.
labels
.
extX
)
{
hor_interval_width
=
checkFiniteNumber
((
rect
.
w
-
y_ax
.
labels
.
extX
-
last_hor_label_half_width
)
/
(
arr_x_val
[
arr_x_val
.
length
-
1
]
-
crosses
));
}
...
...
@@ -3544,6 +3597,7 @@ CChartSpace.prototype =
if
(
x_ax
.
labels
)
{
arr_labels
=
x_ax
.
labels
.
arrLabels
;
x_ax
.
labels
.
align
=
bottom_align_labels
;
if
(
bottom_align_labels
)
{
var
top_line
=
x_ax
.
labels
.
y
+
vert_gap
;
...
...
@@ -3590,6 +3644,20 @@ CChartSpace.prototype =
if
(
y_ax
.
labels
)
{
if
(
bNeedReflect
)
{
if
(
left_align_labels
)
{
left_align_labels
=
false
;
y_ax
.
labels
.
x
+=
y_ax
.
labels
.
extX
;
}
else
{
left_align_labels
=
true
;
y_ax
.
labels
.
x
-=
y_ax
.
labels
.
extX
;
}
}
y_ax
.
labels
.
align
=
left_align_labels
;
arr_labels
=
y_ax
.
labels
.
arrLabels
;
if
(
left_align_labels
)
{
...
...
@@ -3906,7 +3974,14 @@ CChartSpace.prototype =
{
left_val_ax_labels_align
=
false
;
val_ax
.
labels
.
x
=
rect
.
x
+
rect
.
w
-
val_ax
.
labels
.
extX
;
if
(
!
bNeedReflect
)
{
point_interval
=
(
rect
.
w
-
val_ax
.
labels
.
extX
)
/
intervals_count
;
}
else
{
point_interval
=
rect
.
w
/
intervals_count
;
}
val_ax
.
posX
=
val_ax
.
labels
.
x
;
if
(
cross_between
===
CROSS_BETWEEN_MID_CAT
)
{
...
...
@@ -3922,7 +3997,7 @@ CChartSpace.prototype =
else
{
left_points_width
=
point_interval
*
(
crosses
-
1
);
//общая ширина левых точек если считать что точки занимают все пространство
if
(
left_points_width
<
val_ax
.
labels
.
extX
)
//подписи верт. оси выходят за пределы области построения
if
(
!
bNeedReflect
&&
left_points_width
<
val_ax
.
labels
.
extX
)
//подписи верт. оси выходят за пределы области построения
{
var
right_intervals_count
=
intervals_count
-
(
crosses
-
1
);
//количесво интервалов правее вертикальной оси
//скорректируем point_interval, поделив расстояние, которое осталось справа от подписей осей на количество интервалов справа
...
...
@@ -3959,24 +4034,55 @@ CChartSpace.prototype =
}
}
else
if
(
labels_pos
===
TICK_LABEL_POSITION_LOW
)
//подписи слева от области построения
{
if
(
!
bNeedReflect
)
{
point_interval
=
(
rect
.
w
-
val_ax
.
labels
.
extX
)
/
intervals_count
;
}
else
{
point_interval
=
rect
.
w
/
intervals_count
;
}
val_ax
.
labels
.
x
=
rect
.
x
;
if
(
cross_between
===
CROSS_BETWEEN_MID_CAT
)
{
if
(
!
bNeedReflect
)
{
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
arr_cat_labels_points
[
i
]
=
rect
.
x
+
val_ax
.
labels
.
extX
+
point_interval
*
i
;
}
else
{
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
arr_cat_labels_points
[
i
]
=
rect
.
x
+
point_interval
*
i
;
}
}
else
{
if
(
!
bNeedReflect
)
{
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
arr_cat_labels_points
[
i
]
=
rect
.
x
+
val_ax
.
labels
.
extX
+
point_interval
/
2
+
point_interval
*
i
;
}
else
{
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
arr_cat_labels_points
[
i
]
=
rect
.
x
+
point_interval
/
2
+
point_interval
*
i
;
}
}
val_ax
.
posX
=
val_ax
.
labels
.
x
+
val_ax
.
labels
.
extX
+
point_interval
*
(
crosses
-
1
);
}
else
if
(
labels_pos
===
TICK_LABEL_POSITION_HIGH
)
//подписи справа от области построения
{
if
(
!
bNeedReflect
)
{
point_interval
=
(
rect
.
w
-
val_ax
.
labels
.
extX
)
/
intervals_count
;
}
else
{
point_interval
=
rect
.
w
/
intervals_count
;
}
val_ax
.
labels
.
x
=
rect
.
x
+
rect
.
w
-
val_ax
.
labels
.
extX
;
left_val_ax_labels_align
=
false
;
if
(
cross_between
===
CROSS_BETWEEN_MID_CAT
)
...
...
@@ -4014,7 +4120,14 @@ CChartSpace.prototype =
if
(
val_ax
.
crosses
===
CROSSES_MAX
)
{
val_ax
.
labels
.
x
=
rect
.
x
;
if
(
!
bNeedReflect
)
{
point_interval
=
(
rect
.
w
-
val_ax
.
labels
.
extX
)
/
intervals_count
;
}
else
{
point_interval
=
rect
.
w
/
intervals_count
;
}
if
(
cross_between
===
CROSS_BETWEEN_MID_CAT
)
{
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
...
...
@@ -4025,13 +4138,21 @@ CChartSpace.prototype =
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
arr_cat_labels_points
[
i
]
=
rect
.
x
+
rect
.
w
-
point_interval
/
2
-
point_interval
*
i
;
}
if
(
!
bNeedReflect
)
{
val_ax
.
posX
=
val_ax
.
labels
.
x
+
val_ax
.
labels
.
extX
;
}
else
{
val_ax
.
posX
=
val_ax
.
labels
.
x
;
}
}
else
{
left_val_ax_labels_align
=
false
;
right_point_width
=
point_interval
*
(
crosses
-
1
);
if
(
right_point_width
<
val_ax
.
labels
.
extX
)
if
(
!
bNeedReflect
&&
right_point_width
<
val_ax
.
labels
.
extX
)
{
val_ax
.
labels
.
x
=
rect
.
x
+
rect
.
w
-
val_ax
.
labels
.
extX
;
var
left_points_interval_count
=
intervals_count
-
(
crosses
-
1
);
...
...
@@ -4068,7 +4189,14 @@ CChartSpace.prototype =
else
if
(
labels_pos
===
TICK_LABEL_POSITION_LOW
)
//подписи справа от области построения
{
left_val_ax_labels_align
=
false
;
if
(
!
bNeedReflect
)
{
point_interval
=
(
rect
.
w
-
val_ax
.
labels
.
extX
)
/
intervals_count
;
}
else
{
point_interval
=
rect
.
w
/
intervals_count
;
}
val_ax
.
labels
.
x
=
rect
.
x
+
rect
.
w
-
val_ax
.
labels
.
extX
;
if
(
cross_between
===
CROSS_BETWEEN_MID_CAT
)
...
...
@@ -4081,11 +4209,26 @@ CChartSpace.prototype =
for
(
i
=
0
;
i
<
string_pts
.
length
;
++
i
)
arr_cat_labels_points
[
i
]
=
val_ax
.
labels
.
x
-
point_interval
/
2
-
point_interval
*
i
;
}
if
(
!
bNeedReflect
)
{
val_ax
.
posX
=
rect
.
x
+
rect
.
w
-
point_interval
*
(
crosses
-
1
)
-
val_ax
.
labels
.
extX
;
}
else
{
val_ax
.
posX
=
rect
.
x
+
rect
.
w
-
point_interval
*
(
crosses
-
1
);
}
}
else
if
(
labels_pos
===
TICK_LABEL_POSITION_HIGH
)
//подписи слева от области построения
{
if
(
!
bNeedReflect
)
{
point_interval
=
(
rect
.
w
-
val_ax
.
labels
.
extX
)
/
intervals_count
;
}
else
{
point_interval
=
rect
.
w
/
intervals_count
;
}
val_ax
.
labels
.
x
=
rect
.
x
;
if
(
cross_between
===
CROSS_BETWEEN_MID_CAT
)
...
...
@@ -4552,6 +4695,20 @@ CChartSpace.prototype =
var
arr_labels
,
transform_text
,
local_text_transform
;
if
(
val_ax
.
labels
)
{
if
(
bNeedReflect
)
{
if
(
left_val_ax_labels_align
)
{
left_val_ax_labels_align
=
false
;
val_ax
.
labels
.
x
+=
val_ax
.
labels
.
extX
;
}
else
{
left_val_ax_labels_align
=
true
;
val_ax
.
labels
.
x
-=
val_ax
.
labels
.
extX
;
}
}
val_ax
.
labels
.
align
=
left_val_ax_labels_align
;
val_ax
.
labels
.
y
=
Math
.
min
.
apply
(
Math
,
arr_val_labels_points
)
-
max_val_labels_text_height
/
2
;
val_ax
.
labels
.
extY
=
Math
.
max
.
apply
(
Math
,
arr_val_labels_points
)
-
Math
.
min
.
apply
(
Math
,
arr_val_labels_points
)
+
max_val_labels_text_height
;
arr_labels
=
val_ax
.
labels
.
arrLabels
;
...
...
@@ -4614,6 +4771,7 @@ CChartSpace.prototype =
}
cat_ax
.
labels
.
extX
=
arr_cat_labels_points
[
arr_cat_labels_points
.
length
-
1
]
+
max_cat_label_width
/
2
-
cat_ax
.
labels
.
x
;
cat_ax
.
labels
.
align
=
cat_labels_align_bottom
;
if
(
cat_labels_align_bottom
)
{
for
(
i
=
0
;
i
<
cat_ax
.
labels
.
arrLabels
.
length
;
++
i
)
...
...
@@ -5357,8 +5515,15 @@ CChartSpace.prototype =
if
(
hor_labels_pos
===
TICK_LABEL_POSITION_NEXT_TO
||
!
isRealNumber
(
hor_labels_pos
))
{
if
(
cat_ax
.
crosses
===
CROSSES_MAX
)
{
if
(
!
bNeedReflect
)
{
right_gap
=
Math
.
max
(
last_val_lbl_half_width
,
cat_ax_ext_x
);
}
else
{
right_gap
=
Math
.
max
(
last_val_lbl_half_width
,
0
);
}
cat_labels_align_left
=
false
;
//в данном случае подписи будут выравниваться по верхнему краю блока с подписями
if
(
cat_ax
.
labels
)
cat_ax
.
labels
.
x
=
rect
.
x
+
rect
.
w
-
right_gap
;
...
...
@@ -5367,7 +5532,7 @@ CChartSpace.prototype =
}
else
{
if
((
crosses_val_ax
-
arr_val
[
0
])
*
unit_width
+
first_val_lbl_half_width
<
cat_ax_ext_x
)
if
(
!
bNeedReflect
&&
(
crosses_val_ax
-
arr_val
[
0
])
*
unit_width
+
first_val_lbl_half_width
<
cat_ax_ext_x
)
{
unit_width
=
checkFiniteNumber
((
rect
.
w
-
cat_ax_ext_x
-
last_val_lbl_half_width
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
crosses_val_ax
));
}
...
...
@@ -5379,8 +5544,16 @@ CChartSpace.prototype =
arr_val_labels_points
[
i
]
=
cat_ax
.
posX
+
(
arr_val
[
i
]
-
crosses_val_ax
)
*
unit_width
;
}
else
if
(
hor_labels_pos
===
TICK_LABEL_POSITION_LOW
)
{
if
(
!
bNeedReflect
)
{
left_gap
=
Math
.
max
(
first_val_lbl_half_width
,
cat_ax_ext_x
);
}
else
{
left_gap
=
Math
.
max
(
first_val_lbl_half_width
,
0
);
}
unit_width
=
checkFiniteNumber
((
rect
.
w
-
left_gap
-
last_val_lbl_half_width
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
arr_val
[
0
]));
...
...
@@ -5395,7 +5568,15 @@ CChartSpace.prototype =
{
cat_labels_align_left
=
false
;
if
(
!
bNeedReflect
)
{
right_gap
=
Math
.
max
(
last_val_lbl_half_width
,
cat_ax_ext_x
);
}
else
{
right_gap
=
Math
.
max
(
last_val_lbl_half_width
,
0
);
}
unit_width
=
checkFiniteNumber
((
rect
.
w
-
right_gap
-
first_val_lbl_half_width
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
arr_val
[
0
]));
cat_ax
.
posX
=
rect
.
x
+
first_val_lbl_half_width
+
(
crosses_val_ax
-
arr_val
[
0
])
*
unit_width
;
...
...
@@ -5417,8 +5598,15 @@ CChartSpace.prototype =
if
(
hor_labels_pos
===
TICK_LABEL_POSITION_NEXT_TO
||
!
isRealNumber
(
hor_labels_pos
))
{
if
(
cat_ax
.
crosses
===
CROSSES_MAX
)
{
if
(
!
bNeedReflect
)
{
left_gap
=
Math
.
max
(
cat_ax_ext_x
,
last_val_lbl_half_width
);
}
else
{
left_gap
=
Math
.
max
(
0
,
last_val_lbl_half_width
);
}
unit_width
=
checkFiniteNumber
((
rect
.
w
-
left_gap
-
first_val_lbl_half_width
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
arr_val
[
0
]));
cat_ax
.
xPos
=
rect
.
x
+
rect
.
w
-
first_val_lbl_half_width
-
(
crosses_val_ax
-
arr_val
[
0
])
*
unit_width
;
if
(
cat_ax
.
labels
)
...
...
@@ -5427,7 +5615,7 @@ CChartSpace.prototype =
else
{
cat_labels_align_left
=
false
;
if
(
first_val_lbl_half_width
<
cat_ax_ext_x
)
if
(
!
bNeedReflect
&&
first_val_lbl_half_width
<
cat_ax_ext_x
)
{
unit_width
=
checkFiniteNumber
((
rect
.
w
-
cat_ax_ext_x
-
last_val_lbl_half_width
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
arr_val
[
0
]));
}
...
...
@@ -5441,7 +5629,15 @@ CChartSpace.prototype =
else
if
(
hor_labels_pos
===
TICK_LABEL_POSITION_LOW
)
{
cat_labels_align_left
=
false
;
if
(
!
bNeedReflect
)
{
right_gap
=
Math
.
max
(
first_val_lbl_half_width
,
cat_ax_ext_x
);
}
else
{
right_gap
=
Math
.
max
(
first_val_lbl_half_width
,
0
);
}
unit_width
=
checkFiniteNumber
((
rect
.
w
-
last_val_lbl_half_width
-
right_gap
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
arr_val
[
0
]));
cat_ax
.
xPos
=
rect
.
x
+
last_val_lbl_half_width
+
(
arr_val
[
arr_val
.
length
-
1
]
-
crosses_val_ax
)
*
crosses_val_ax
;
if
(
cat_ax
.
labels
)
...
...
@@ -5451,8 +5647,16 @@ CChartSpace.prototype =
}
else
if
(
hor_labels_pos
===
TICK_LABEL_POSITION_HIGH
)
{
if
(
!
bNeedReflect
)
{
left_gap
=
Math
.
max
(
cat_ax_ext_x
,
last_val_lbl_half_width
);
}
else
{
left_gap
=
Math
.
max
(
0
,
last_val_lbl_half_width
);
}
unit_width
=
checkFiniteNumber
((
rect
.
w
-
left_gap
-
first_val_lbl_half_width
)
/
(
arr_val
[
arr_val
.
length
-
1
]
-
arr_val
[
0
]));
cat_ax
.
xPos
=
rect
.
x
+
rect
.
w
-
first_val_lbl_half_width
-
(
crosses_val_ax
-
arr_val
[
0
])
*
unit_width
;
if
(
cat_ax
.
labels
)
...
...
@@ -5477,6 +5681,8 @@ CChartSpace.prototype =
val_ax
.
labels
.
x
=
Math
.
min
.
apply
(
Math
,
arr_val_labels_points
)
-
max_val_ax_label_width
/
2
;
val_ax
.
labels
.
extX
=
Math
.
max
.
apply
(
Math
,
arr_val_labels_points
)
-
Math
.
min
.
apply
(
Math
,
arr_val_labels_points
)
+
max_val_ax_label_width
;
//val_axis_labels_gap - вертикальный зазор
val_ax
.
labels
.
align
=
bottom_val_ax_labels_align
;
if
(
bottom_val_ax_labels_align
)
{
var
y_pos
=
val_ax
.
labels
.
y
+
val_axis_labels_gap
;
...
...
@@ -5525,9 +5731,24 @@ CChartSpace.prototype =
{
cat_ax
.
labels
.
y
=
rect
.
y
;
cat_ax
.
labels
.
extY
=
point_interval
*
intervals_count
;
if
(
bNeedReflect
)
{
if
(
cat_labels_align_left
)
{
cat_labels_align_left
=
false
;
cat_ax
.
labels
.
x
+=
cat_ax
.
labels
.
extX
;
}
else
{
cat_labels_align_left
=
true
;
cat_ax
.
labels
.
x
-=
cat_ax
.
labels
.
extX
;
}
}
if
(
cat_labels_align_left
)
{
if
(
width_flag
===
0
)
{
for
(
i
=
0
;
i
<
cat_ax
.
labels
.
arrLabels
.
length
;
++
i
)
...
...
@@ -5693,24 +5914,40 @@ CChartSpace.prototype =
{
var
oAxisByTypes
=
this
.
chart
.
plotArea
.
chart
.
getAxisByTypes
();
var
oCatAx
=
oAxisByTypes
.
catAx
[
0
],
oValAx
=
oAxisByTypes
.
valAx
[
0
],
deltaX
,
deltaY
,
i
,
oAxisLabels
,
oLabel
,
oNewPos
;
if
(
oCatAx
&&
oValAx
)
var
oProcessor3D
=
this
.
chartObj
&&
this
.
chartObj
.
processor3D
;
if
(
oCatAx
&&
oValAx
&&
oProcessor3D
)
{
if
((
(
oCatAx
.
axPos
===
AX_POS_B
||
oCatAx
.
axPos
===
AX_POS_T
)
&&
oCatAx
.
transformXPoints
&&
oCatAx
.
xPoints
)
&&
((
oValAx
.
axPos
===
AX_POS_L
||
oValAx
.
axPos
===
AX_POS_R
)
&&
oValAx
.
transformYPoints
&&
oValAx
.
yPoints
))
if
((
(
oCatAx
.
axPos
===
AX_POS_B
||
oCatAx
.
axPos
===
AX_POS_T
)
&&
oCatAx
.
xPoints
)
&&
((
oValAx
.
axPos
===
AX_POS_L
||
oValAx
.
axPos
===
AX_POS_R
)
&&
oValAx
.
yPoints
))
{
oAxisLabels
=
oCatAx
.
labels
;
if
(
oAxisLabels
)
{
var
dZPositionCatAxis
=
oProcessor3D
.
calculateZPositionCatAxis
();
var
dPosY
,
dPosY2
if
(
oAxisLabels
.
align
)
{
dPosY
=
oAxisLabels
.
y
*
this
.
chartObj
.
calcProp
.
pxToMM
;
dPosY2
=
oAxisLabels
.
y
;
}
else
{
dPosY
=
(
oAxisLabels
.
y
+
oAxisLabels
.
extY
)
*
this
.
chartObj
.
calcProp
.
pxToMM
;
dPosY2
=
oAxisLabels
.
y
+
oAxisLabels
.
extY
;
}
for
(
i
=
0
;
i
<
oAxisLabels
.
arrLabels
.
length
;
++
i
)
{
oLabel
=
oAxisLabels
.
arrLabels
[
i
];
if
(
oLabel
)
{
deltaX
=
oLabel
.
localTransformText
.
tx
-
oCatAx
.
xPoints
[
i
].
pos
;
deltaY
=
oLabel
.
localTransformText
.
ty
-
oAxisLabels
.
y
;
oNewPos
=
oCatAx
.
transformXPoints
[
i
];
oLabel
.
setPosition2
(
oNewPos
.
x
+
deltaX
,
oNewPos
.
y
+
deltaY
);
var
oCPosLabelX
=
oLabel
.
localTransformText
.
TransformPointX
(
oLabel
.
txBody
.
content
.
XLimit
/
2
,
0
);
var
oCPosLabelY
=
oLabel
.
localTransformText
.
TransformPointY
(
oLabel
.
txBody
.
content
.
XLimit
/
2
,
0
);
oNewPos
=
oProcessor3D
.
convertAndTurnPoint
(
oCPosLabelX
*
this
.
chartObj
.
calcProp
.
pxToMM
,
dPosY
,
dZPositionCatAxis
);
oLabel
.
setPosition2
(
oNewPos
.
x
/
this
.
chartObj
.
calcProp
.
pxToMM
+
oLabel
.
localTransformText
.
tx
-
oCPosLabelX
,
oLabel
.
localTransformText
.
ty
-
dPosY2
+
oNewPos
.
y
/
this
.
chartObj
.
calcProp
.
pxToMM
);
}
}
}
...
...
@@ -5719,36 +5956,68 @@ CChartSpace.prototype =
oAxisLabels
=
oValAx
.
labels
;
if
(
oAxisLabels
)
{
var
dZPositionCatAxis
=
oProcessor3D
.
calculateZPositionValAxis
();
var
dPosX
,
dPosX2
;
if
(
!
oAxisLabels
.
align
)
{
dPosX2
=
oAxisLabels
.
x
;
dPosX
=
oAxisLabels
.
x
*
this
.
chartObj
.
calcProp
.
pxToMM
;
}
else
{
dPosX2
=
oAxisLabels
.
x
+
oAxisLabels
.
extX
;
dPosX
=
(
oAxisLabels
.
x
+
oAxisLabels
.
extX
)
*
this
.
chartObj
.
calcProp
.
pxToMM
;
}
for
(
i
=
0
;
i
<
oAxisLabels
.
arrLabels
.
length
;
++
i
)
{
oLabel
=
oAxisLabels
.
arrLabels
[
i
];
if
(
oLabel
)
{
deltaX
=
oLabel
.
localTransformText
.
tx
-
oAxisLabels
.
x
;
deltaY
=
oLabel
.
localTransformText
.
ty
-
oValAx
.
yPoints
[
i
].
pos
;
oNewPos
=
oValAx
.
transformYPoints
[
i
];
oLabel
.
setPosition2
(
oNewPos
.
x
+
deltaX
,
oNewPos
.
y
+
deltaY
);
oNewPos
=
oProcessor3D
.
convertAndTurnPoint
(
dPosX
,
oLabel
.
localTransformText
.
ty
*
this
.
chartObj
.
calcProp
.
pxToMM
,
dZPositionCatAxis
);
oLabel
.
setPosition2
(
oLabel
.
localTransformText
.
tx
-
dPosX2
+
oNewPos
.
x
/
this
.
chartObj
.
calcProp
.
pxToMM
,
oNewPos
.
y
/
this
.
chartObj
.
calcProp
.
pxToMM
);
}
}
}
}
else
if
(((
oCatAx
.
axPos
===
AX_POS_L
||
oCatAx
.
axPos
===
AX_POS_R
)
&&
oCatAx
.
transformYPoints
&&
oCatAx
.
yPoints
)
&&
((
oValAx
.
axPos
===
AX_POS_T
||
oValAx
.
axPos
===
AX_POS_B
)
&&
oValAx
.
transformXPoints
&&
oValAx
.
xPoints
))
else
if
(((
oCatAx
.
axPos
===
AX_POS_L
||
oCatAx
.
axPos
===
AX_POS_R
)
&&
oCatAx
.
yPoints
)
&&
((
oValAx
.
axPos
===
AX_POS_T
||
oValAx
.
axPos
===
AX_POS_B
)
&&
oValAx
.
xPoints
))
{
oAxisLabels
=
oValAx
.
labels
;
if
(
oAxisLabels
)
{
var
dZPositionValAxis
=
oProcessor3D
.
calculateZPositionValAxis
();
var
dPosY
,
dPosY2
if
(
oAxisLabels
.
align
)
{
dPosY
=
oAxisLabels
.
y
*
this
.
chartObj
.
calcProp
.
pxToMM
;
dPosY2
=
oAxisLabels
.
y
;
}
else
{
dPosY
=
(
oAxisLabels
.
y
+
oAxisLabels
.
extY
)
*
this
.
chartObj
.
calcProp
.
pxToMM
;
dPosY2
=
oAxisLabels
.
y
+
oAxisLabels
.
extY
;
}
for
(
i
=
0
;
i
<
oAxisLabels
.
arrLabels
.
length
;
++
i
)
{
oLabel
=
oAxisLabels
.
arrLabels
[
i
];
if
(
oLabel
)
{
deltaX
=
oLabel
.
localTransformText
.
tx
-
oValAx
.
xPoints
[
i
].
pos
;
deltaY
=
oLabel
.
localTransformText
.
ty
-
oAxisLabels
.
y
;
oNewPos
=
oValAx
.
transformXPoints
[
i
];
oLabel
.
setPosition2
(
oNewPos
.
x
+
deltaX
,
oNewPos
.
y
+
deltaY
);
var
oCPosLabelX
=
oLabel
.
localTransformText
.
TransformPointX
(
oLabel
.
txBody
.
content
.
XLimit
/
2
,
0
);
var
oCPosLabelY
=
oLabel
.
localTransformText
.
TransformPointY
(
oLabel
.
txBody
.
content
.
XLimit
/
2
,
0
);
oNewPos
=
oProcessor3D
.
convertAndTurnPoint
(
oCPosLabelX
*
this
.
chartObj
.
calcProp
.
pxToMM
,
dPosY
,
dZPositionValAxis
);
oLabel
.
setPosition2
(
oNewPos
.
x
/
this
.
chartObj
.
calcProp
.
pxToMM
+
oLabel
.
localTransformText
.
tx
-
oCPosLabelX
,
oLabel
.
localTransformText
.
ty
-
dPosY2
+
oNewPos
.
y
/
this
.
chartObj
.
calcProp
.
pxToMM
);
//oNewPos = oProcessor3D.convertAndTurnPoint(oLabel.localTransformText.tx*this.chartObj.calcProp.pxToMM, oLabel.localTransformText.ty*this.chartObj.calcProp.pxToMM, dZPositionValAxis);;
//oLabel.setPosition2(oNewPos.x/this.chartObj.calcProp.pxToMM, oNewPos.y/this.chartObj.calcProp.pxToMM);
}
}
}
...
...
@@ -5758,15 +6027,28 @@ CChartSpace.prototype =
if
(
oAxisLabels
)
{
var
dZPositionCatAxis
=
oProcessor3D
.
calculateZPositionCatAxis
();
var
dPosX
,
dPosX2
;
if
(
oAxisLabels
.
align
)
{
dPosX2
=
oAxisLabels
.
x
;
dPosX
=
oAxisLabels
.
x
*
this
.
chartObj
.
calcProp
.
pxToMM
;
}
else
{
dPosX2
=
oAxisLabels
.
x
+
oAxisLabels
.
extX
;
dPosX
=
(
oAxisLabels
.
x
+
oAxisLabels
.
extX
)
*
this
.
chartObj
.
calcProp
.
pxToMM
;
}
for
(
i
=
0
;
i
<
oAxisLabels
.
arrLabels
.
length
;
++
i
)
{
oLabel
=
oAxisLabels
.
arrLabels
[
i
];
if
(
oLabel
)
{
deltaX
=
oLabel
.
localTransformText
.
tx
-
oAxisLabels
.
x
;
deltaY
=
oLabel
.
localTransformText
.
ty
-
oCatAx
.
yPoints
[
i
].
pos
;
oNewPos
=
oCatAx
.
transformYPoints
[
i
];
oLabel
.
setPosition2
(
oNewPos
.
x
+
deltaX
,
oNewPos
.
y
+
deltaY
);
oNewPos
=
oProcessor3D
.
convertAndTurnPoint
(
dPosX
,
oLabel
.
localTransformText
.
ty
*
this
.
chartObj
.
calcProp
.
pxToMM
,
dZPositionCatAxis
);
oLabel
.
setPosition2
(
oLabel
.
localTransformText
.
tx
-
dPosX2
+
oNewPos
.
x
/
this
.
chartObj
.
calcProp
.
pxToMM
,
oNewPos
.
y
/
this
.
chartObj
.
calcProp
.
pxToMM
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment