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
91b7ef47
Commit
91b7ef47
authored
Sep 14, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix percentile calculate
parent
008d0461
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
35 deletions
+51
-35
cell/model/ConditionalFormatting.js
cell/model/ConditionalFormatting.js
+13
-8
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+25
-22
cell/model/Workbook.js
cell/model/Workbook.js
+13
-5
No files found.
cell/model/ConditionalFormatting.js
View file @
91b7ef47
...
@@ -243,19 +243,19 @@
...
@@ -243,19 +243,19 @@
res
.
aColors
.
push
(
this
.
aColors
[
i
].
clone
());
res
.
aColors
.
push
(
this
.
aColors
[
i
].
clone
());
return
res
;
return
res
;
};
};
CColorScale
.
prototype
.
getMin
=
function
(
min
,
max
,
count
)
{
CColorScale
.
prototype
.
getMin
=
function
(
min
,
max
,
values
)
{
var
oCFVO
=
(
0
<
this
.
aCFVOs
.
length
)
?
this
.
aCFVOs
[
0
]
:
null
;
var
oCFVO
=
(
0
<
this
.
aCFVOs
.
length
)
?
this
.
aCFVOs
[
0
]
:
null
;
return
this
.
getValue
(
min
,
max
,
count
,
oCFVO
);
return
this
.
getValue
(
min
,
max
,
values
,
oCFVO
);
};
};
CColorScale
.
prototype
.
getMid
=
function
(
min
,
max
,
count
)
{
CColorScale
.
prototype
.
getMid
=
function
(
min
,
max
,
values
)
{
var
oCFVO
=
(
2
<
this
.
aCFVOs
.
length
?
this
.
aCFVOs
[
1
]
:
null
);
var
oCFVO
=
(
2
<
this
.
aCFVOs
.
length
?
this
.
aCFVOs
[
1
]
:
null
);
return
this
.
getValue
(
min
,
max
,
count
,
oCFVO
);
return
this
.
getValue
(
min
,
max
,
values
,
oCFVO
);
};
};
CColorScale
.
prototype
.
getMax
=
function
(
min
,
max
,
count
)
{
CColorScale
.
prototype
.
getMax
=
function
(
min
,
max
,
values
)
{
var
oCFVO
=
(
2
===
this
.
aCFVOs
.
length
)
?
this
.
aCFVOs
[
1
]
:
(
2
<
this
.
aCFVOs
.
length
?
this
.
aCFVOs
[
2
]
:
null
);
var
oCFVO
=
(
2
===
this
.
aCFVOs
.
length
)
?
this
.
aCFVOs
[
1
]
:
(
2
<
this
.
aCFVOs
.
length
?
this
.
aCFVOs
[
2
]
:
null
);
return
this
.
getValue
(
min
,
max
,
count
,
oCFVO
);
return
this
.
getValue
(
min
,
max
,
values
,
oCFVO
);
};
};
CColorScale
.
prototype
.
getValue
=
function
(
min
,
max
,
count
,
oCFVO
)
{
CColorScale
.
prototype
.
getValue
=
function
(
min
,
max
,
values
,
oCFVO
)
{
var
res
=
min
;
var
res
=
min
;
if
(
oCFVO
)
{
if
(
oCFVO
)
{
// ToDo Formula
// ToDo Formula
...
@@ -273,7 +273,12 @@
...
@@ -273,7 +273,12 @@
res
=
min
+
Math
.
floor
((
max
-
min
)
*
parseFloat
(
oCFVO
.
Val
)
/
100
);
res
=
min
+
Math
.
floor
((
max
-
min
)
*
parseFloat
(
oCFVO
.
Val
)
/
100
);
break
;
break
;
case
AscCommonExcel
.
ECfvoType
.
Percentile
:
case
AscCommonExcel
.
ECfvoType
.
Percentile
:
res
=
min
+
Math
.
floor
(
count
*
parseFloat
(
oCFVO
.
Val
)
/
100
);
res
=
AscCommonExcel
.
getPercentile
(
values
,
parseFloat
(
oCFVO
.
Val
)
/
100.0
);
if
(
AscCommonExcel
.
cElementType
.
number
===
res
.
type
)
{
res
=
res
.
getValue
();
}
else
{
res
=
min
;
}
break
;
break
;
}
}
}
}
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
91b7ef47
...
@@ -372,6 +372,27 @@ function (window, undefined) {
...
@@ -372,6 +372,27 @@ function (window, undefined) {
return
getLogGammaHelper
(
fZ
+
2
)
-
Math
.
log
(
fZ
+
1
)
-
Math
.
log
(
fZ
);
return
getLogGammaHelper
(
fZ
+
2
)
-
Math
.
log
(
fZ
+
1
)
-
Math
.
log
(
fZ
);
}
}
function
getPercentile
(
values
,
alpha
)
{
values
.
sort
(
fSortAscending
);
var
nSize
=
values
.
length
;
if
(
nSize
===
0
)
{
return
new
cError
(
cErrorType
.
not_available
);
}
else
{
if
(
nSize
===
1
)
{
return
new
cNumber
(
values
[
0
]);
}
else
{
var
nIndex
=
Math
.
floor
(
alpha
*
(
nSize
-
1
));
var
fDiff
=
alpha
*
(
nSize
-
1
)
-
Math
.
floor
(
alpha
*
(
nSize
-
1
));
if
(
fDiff
==
0.0
)
{
return
new
cNumber
(
values
[
nIndex
]);
}
else
{
return
new
cNumber
(
values
[
nIndex
]
+
fDiff
*
(
values
[
nIndex
+
1
]
-
values
[
nIndex
]));
}
}
}
}
function
cAVEDEV
()
{
function
cAVEDEV
()
{
// cBaseFunction.call( this, "AVEDEV" );
// cBaseFunction.call( this, "AVEDEV" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMin( 1 );
...
@@ -391,7 +412,7 @@ function cAVEDEV() {
...
@@ -391,7 +412,7 @@ function cAVEDEV() {
}
}
cAVEDEV
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
)
cAVEDEV
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
)
;
cAVEDEV
.
prototype
.
Calculate
=
function
(
arg
)
{
cAVEDEV
.
prototype
.
Calculate
=
function
(
arg
)
{
var
count
=
0
,
sum
=
new
cNumber
(
0
),
arrX
=
[];
var
count
=
0
,
sum
=
new
cNumber
(
0
),
arrX
=
[];
for
(
var
i
=
0
;
i
<
arg
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
arg
.
length
;
i
++
)
{
...
@@ -446,7 +467,7 @@ cAVEDEV.prototype.getInfo = function () {
...
@@ -446,7 +467,7 @@ cAVEDEV.prototype.getInfo = function () {
name
:
this
.
name
,
name
:
this
.
name
,
args
:
"
( argument-list )
"
args
:
"
( argument-list )
"
};
};
}
}
;
function
cAVERAGE
()
{
function
cAVERAGE
()
{
// cBaseFunction.call( this, "AVERAGE" );
// cBaseFunction.call( this, "AVERAGE" );
...
@@ -3664,26 +3685,7 @@ cPERCENTILE.prototype.Calculate = function ( arg ) {
...
@@ -3664,26 +3685,7 @@ cPERCENTILE.prototype.Calculate = function ( arg ) {
}
}
}
}
tA
.
sort
(
fSortAscending
);
return
getPercentile
(
tA
,
alpha
);
var
nSize
=
tA
.
length
;
if
(
tA
.
length
<
1
||
nSize
==
0
)
return
new
cError
(
cErrorType
.
not_available
);
else
{
if
(
nSize
==
1
)
return
new
cNumber
(
tA
[
0
]
);
else
{
var
nIndex
=
Math
.
floor
(
alpha
*
(
nSize
-
1
)
);
var
fDiff
=
alpha
*
(
nSize
-
1
)
-
Math
.
floor
(
alpha
*
(
nSize
-
1
)
);
if
(
fDiff
==
0.0
)
return
new
cNumber
(
tA
[
nIndex
]
);
else
{
return
new
cNumber
(
tA
[
nIndex
]
+
fDiff
*
(
tA
[
nIndex
+
1
]
-
tA
[
nIndex
])
);
}
}
}
}
}
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
];
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
];
...
@@ -5665,6 +5667,7 @@ cZTEST.prototype = Object.create( cBaseFunction.prototype );
...
@@ -5665,6 +5667,7 @@ cZTEST.prototype = Object.create( cBaseFunction.prototype );
window
[
'
AscCommonExcel
'
].
phi
=
phi
;
window
[
'
AscCommonExcel
'
].
phi
=
phi
;
window
[
'
AscCommonExcel
'
].
gauss
=
gauss
;
window
[
'
AscCommonExcel
'
].
gauss
=
gauss
;
window
[
'
AscCommonExcel
'
].
gaussinv
=
gaussinv
;
window
[
'
AscCommonExcel
'
].
gaussinv
=
gaussinv
;
window
[
'
AscCommonExcel
'
].
getPercentile
=
getPercentile
;
window
[
'
AscCommonExcel
'
].
cAVERAGE
=
cAVERAGE
;
window
[
'
AscCommonExcel
'
].
cAVERAGE
=
cAVERAGE
;
window
[
'
AscCommonExcel
'
].
cCOUNT
=
cCOUNT
;
window
[
'
AscCommonExcel
'
].
cCOUNT
=
cCOUNT
;
...
...
cell/model/Workbook.js
View file @
91b7ef47
...
@@ -3650,12 +3650,12 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3650,12 +3650,12 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
l
=
oRuleElement
.
aColors
.
length
;
l
=
oRuleElement
.
aColors
.
length
;
if
(
0
<
values
.
length
&&
2
<=
l
)
{
if
(
0
<
values
.
length
&&
2
<=
l
)
{
oGradient1
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
0
],
oRuleElement
.
aColors
[
1
]);
oGradient1
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
0
],
oRuleElement
.
aColors
[
1
]);
min
=
oRuleElement
.
getMin
(
min
,
max
,
nc
);
min
=
oRuleElement
.
getMin
(
min
,
max
,
values
);
max
=
oRuleElement
.
getMax
(
min
,
max
,
nc
);
max
=
oRuleElement
.
getMax
(
min
,
max
,
values
);
oGradient2
=
null
;
oGradient2
=
null
;
if
(
2
<
l
)
{
if
(
2
<
l
)
{
oGradient2
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
1
],
oRuleElement
.
aColors
[
2
]);
oGradient2
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
1
],
oRuleElement
.
aColors
[
2
]);
mid
=
oRuleElement
.
getMid
(
min
,
max
,
nc
);
mid
=
oRuleElement
.
getMid
(
min
,
max
,
values
);
oGradient1
.
init
(
min
,
mid
);
oGradient1
.
init
(
min
,
mid
);
oGradient2
.
init
(
mid
,
max
);
oGradient2
.
init
(
mid
,
max
);
...
@@ -6306,6 +6306,14 @@ Cell.prototype.setFormulaCA = function(ca){
...
@@ -6306,6 +6306,14 @@ Cell.prototype.setFormulaCA = function(ca){
};
};
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
function
CellAndValue
(
c
,
v
)
{
this
.
c
=
c
;
this
.
v
=
v
;
}
CellAndValue
.
prototype
.
valueOf
=
function
()
{
return
this
.
v
;
};
/**
/**
* @constructor
* @constructor
*/
*/
...
@@ -6594,7 +6602,7 @@ Range.prototype._getRangeType=function(oBBox){
...
@@ -6594,7 +6602,7 @@ Range.prototype._getRangeType=function(oBBox){
Range
.
prototype
.
_getValues
=
function
(
withEmpty
)
{
Range
.
prototype
.
_getValues
=
function
(
withEmpty
)
{
var
res
=
[];
var
res
=
[];
var
fAction
=
function
(
c
)
{
var
fAction
=
function
(
c
)
{
res
.
push
(
{
c
:
c
,
v
:
c
.
getValueWithoutFormat
()}
);
res
.
push
(
new
CellAndValue
(
c
,
c
.
getValueWithoutFormat
())
);
};
};
if
(
withEmpty
)
{
if
(
withEmpty
)
{
this
.
_setProperty
(
null
,
null
,
fAction
);
this
.
_setProperty
(
null
,
null
,
fAction
);
...
@@ -6607,7 +6615,7 @@ Range.prototype._getValuesAndMap = function (withEmpty) {
...
@@ -6607,7 +6615,7 @@ Range.prototype._getValuesAndMap = function (withEmpty) {
var
v
,
arrRes
=
[],
mapRes
=
{};
var
v
,
arrRes
=
[],
mapRes
=
{};
var
fAction
=
function
(
c
)
{
var
fAction
=
function
(
c
)
{
v
=
c
.
getValueWithoutFormat
();
v
=
c
.
getValueWithoutFormat
();
arrRes
.
push
(
{
c
:
c
,
v
:
v
}
);
arrRes
.
push
(
new
CellAndValue
(
c
,
v
)
);
mapRes
[
v
.
toLowerCase
()]
=
true
;
mapRes
[
v
.
toLowerCase
()]
=
true
;
};
};
if
(
withEmpty
)
{
if
(
withEmpty
)
{
...
...
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