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
5761a27a
Commit
5761a27a
authored
Jun 21, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify functions: cPERCENTILE, cRANK, cRANK_AVG
parent
d2b5f8d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
56 deletions
+55
-56
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+12
-13
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+43
-43
No files found.
cell/model/FormulaObjects/parserFormula.js
View file @
5761a27a
...
...
@@ -2435,22 +2435,21 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
){
var
arg
=
args
[
i
];
if
(
cElementType
.
cellsRange
===
arg
.
type
||
cElementType
.
cellsRange3D
===
arg
.
type
)
{
if
(
typeArray
&&
cElementType
.
array
===
typeArray
[
i
]){
newArgs
[
i
]
=
arg
;
}
else
{
newArgs
[
i
]
=
arg
.
cross
(
arg1
);
//для массивов отдельная ветка
if
(
typeArray
&&
cElementType
.
array
===
typeArray
[
i
])
{
if
(
cElementType
.
cellsRange
===
arg
.
type
||
cElementType
.
array
===
arg
.
type
)
{
newArgs
[
i
]
=
arg
.
getMatrix
();
}
else
if
(
cElementType
.
cellsRange3D
===
arg
.
type
)
{
newArgs
[
i
]
=
arg
.
getMatrix
()[
0
];
}
else
{
newArgs
[
i
]
=
new
cError
(
cErrorType
.
not_available
);
}
}
else
if
(
cElementType
.
cellsRange
===
arg
.
type
||
cElementType
.
cellsRange3D
===
arg
.
type
)
{
newArgs
[
i
]
=
arg
.
cross
(
arg1
);
}
else
if
(
cElementType
.
array
===
arg
.
type
){
if
(
bAddFirstArrElem
){
if
(
typeArray
&&
cElementType
.
array
===
typeArray
[
i
]){
newArgs
[
i
]
=
[];
arg
.
foreach
(
function
(
elem
)
{
newArgs
[
i
].
push
(
elem
);
});
}
else
{
newArgs
[
i
]
=
arg
.
getElementRowCol
(
0
,
0
);
}
newArgs
[
i
]
=
arg
.
getElementRowCol
(
0
,
0
);
}
else
{
indexArr
=
i
;
newArgs
[
i
]
=
arg
;
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
5761a27a
...
...
@@ -908,7 +908,7 @@
{
//sort array
aSortArray
.
sort
(
function
sortArr
(
a
,
b
)
{
return
a
.
value
-
b
.
value
;
return
a
-
b
;
});
var
nSize
=
aSortArray
.
length
;
...
...
@@ -917,7 +917,7 @@
if
(
nSize
==
0
/*|| nGlobalError != FormulaError::NONE*/
){
res
=
null
;
}
else
{
if
(
fVal
<
aSortArray
[
0
]
.
value
||
fVal
>
aSortArray
[
nSize
-
1
].
value
){
if
(
fVal
<
aSortArray
[
0
]
||
fVal
>
aSortArray
[
nSize
-
1
]
){
res
=
null
;
}
else
{
var
fLastPos
=
0
;
...
...
@@ -925,12 +925,12 @@
var
bFinished
=
false
;
var
i
;
for
(
i
=
0
;
i
<
nSize
&&
!
bFinished
/*&& nGlobalError == FormulaError::NONE*/
;
i
++
){
if
(
aSortArray
[
i
]
.
value
===
fVal
){
if
(
aSortArray
[
i
]
===
fVal
){
if
(
fFirstPos
<
0
){
fFirstPos
=
i
+
1.0
;
}
}
else
{
if
(
aSortArray
[
i
]
.
value
>
fVal
){
if
(
aSortArray
[
i
]
>
fVal
){
fLastPos
=
i
;
bFinished
=
true
;
}
...
...
@@ -5019,10 +5019,9 @@
cPERCENTILE
.
prototype
.
argumentsMax
=
2
;
cPERCENTILE
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cPERCENTILE
.
prototype
.
Calculate
=
function
(
arg
)
{
function
percentile
(
argArray
)
{
function
percentile
(
A
,
k
)
{
var
tA
=
[],
alpha
=
k
.
getValue
();
var
tA
=
[],
A
=
argArray
[
0
],
alpha
=
argArray
[
1
];
for
(
var
i
=
0
;
i
<
A
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
A
[
i
].
length
;
j
++
)
{
...
...
@@ -5039,30 +5038,17 @@
return
getPercentile
(
tA
,
alpha
);
}
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArray
)
{
arg0
=
arg0
.
getMatrix
();
}
else
if
(
arg0
instanceof
cArea3D
)
{
arg0
=
arg0
.
getMatrix
()[
0
];
}
else
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_available
);
}
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
=
arg1
.
getElement
(
0
);
}
var
oArguments
=
this
.
_prepareArguments
(
arg
,
arguments
[
1
],
true
,
[
cElementType
.
array
]);
var
argClone
=
oArguments
.
args
;
arg
1
=
arg1
.
tocNumber
();
arg
Clone
[
1
]
=
argClone
[
1
]
.
tocNumber
();
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
return
this
.
value
=
percentile
(
arg0
,
arg1
);
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
percentile
);
};
/**
...
...
@@ -5575,26 +5561,33 @@
return
this
.
value
=
argError
;
}
var
calc
TDist
=
function
(
argArray
){
var
calc
Rank
=
function
(
argArray
){
var
number
=
argArray
[
0
];
var
ref
=
argArray
[
1
];
var
order
=
argArray
[
2
];
if
(
!
ref
.
length
){
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
var
changedRef
=
[];
for
(
var
i
=
0
;
i
<
ref
.
length
;
i
++
){
if
(
cElementType
.
number
===
ref
[
i
].
type
){
changedRef
.
push
(
ref
[
i
]);
for
(
var
i
=
0
;
i
<
ref
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
ref
[
i
].
length
;
j
++
)
{
if
(
ref
[
i
][
j
]
instanceof
cError
)
{
return
ref
[
i
][
j
];
}
else
if
(
ref
[
i
][
j
]
instanceof
cNumber
)
{
changedRef
.
push
(
ref
[
i
][
j
].
getValue
());
}
else
if
(
ref
[
i
][
j
]
instanceof
cBool
)
{
changedRef
.
push
(
ref
[
i
][
j
].
tocNumber
().
getValue
());
}
}
}
if
(
!
changedRef
.
length
){
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
var
res
=
rank
(
number
,
changedRef
,
order
);
return
null
!==
res
&&
!
isNaN
(
res
)
?
new
cNumber
(
res
)
:
new
cError
(
cErrorType
.
wrong_value_type
);
};
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calc
TDist
);
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calc
Rank
);
};
/**
...
...
@@ -5623,26 +5616,33 @@
return
this
.
value
=
argError
;
}
var
calc
TDist
=
function
(
argArray
){
var
calc
Rank
=
function
(
argArray
){
var
number
=
argArray
[
0
];
var
ref
=
argArray
[
1
];
var
order
=
argArray
[
2
];
if
(
!
ref
.
length
){
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
var
changedRef
=
[];
for
(
var
i
=
0
;
i
<
ref
.
length
;
i
++
){
if
(
cElementType
.
number
===
ref
[
i
].
type
){
changedRef
.
push
(
ref
[
i
]);
for
(
var
i
=
0
;
i
<
ref
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
ref
[
i
].
length
;
j
++
)
{
if
(
ref
[
i
][
j
]
instanceof
cError
)
{
return
ref
[
i
][
j
];
}
else
if
(
ref
[
i
][
j
]
instanceof
cNumber
)
{
changedRef
.
push
(
ref
[
i
][
j
].
getValue
());
}
else
if
(
ref
[
i
][
j
]
instanceof
cBool
)
{
changedRef
.
push
(
ref
[
i
][
j
].
tocNumber
().
getValue
());
}
}
}
if
(
!
changedRef
.
length
){
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
var
res
=
rank
(
number
,
changedRef
,
order
,
true
);
return
null
!==
res
&&
!
isNaN
(
res
)
?
new
cNumber
(
res
)
:
new
cError
(
cErrorType
.
wrong_value_type
);
};
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calc
TDist
);
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
oArguments
,
calc
Rank
);
};
/**
...
...
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