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
76277a57
Commit
76277a57
authored
May 16, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support min, max, num, percent, percentile, 3 color conditional formatting
parent
70505698
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
11 deletions
+68
-11
cell/model/ConditionalFormatting.js
cell/model/ConditionalFormatting.js
+41
-0
cell/model/Serialize.js
cell/model/Serialize.js
+1
-0
cell/model/Workbook.js
cell/model/Workbook.js
+26
-11
No files found.
cell/model/ConditionalFormatting.js
View file @
76277a57
...
@@ -91,6 +91,42 @@
...
@@ -91,6 +91,42 @@
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
)
{
var
oCFVO
=
(
0
<
this
.
aCFVOs
.
length
)
?
this
.
aCFVOs
[
0
]
:
null
;
return
this
.
getValue
(
min
,
max
,
count
,
oCFVO
);
};
CColorScale
.
prototype
.
getMid
=
function
(
min
,
max
,
count
)
{
var
oCFVO
=
(
2
<
this
.
aCFVOs
.
length
?
this
.
aCFVOs
[
1
]
:
null
);
return
this
.
getValue
(
min
,
max
,
count
,
oCFVO
);
};
CColorScale
.
prototype
.
getMax
=
function
(
min
,
max
,
count
)
{
var
oCFVO
=
(
2
===
this
.
aCFVOs
.
length
)
?
this
.
aCFVOs
[
1
]
:
(
2
<
this
.
aCFVOs
.
length
?
this
.
aCFVOs
[
2
]
:
null
);
return
this
.
getValue
(
min
,
max
,
count
,
oCFVO
);
};
CColorScale
.
prototype
.
getValue
=
function
(
min
,
max
,
count
,
oCFVO
)
{
var
res
=
min
;
if
(
oCFVO
)
{
// ToDo Formula
switch
(
oCFVO
.
Type
)
{
case
AscCommonExcel
.
ECfvoType
.
Minimum
:
res
=
min
;
break
;
case
AscCommonExcel
.
ECfvoType
.
Maximum
:
res
=
max
;
break
;
case
AscCommonExcel
.
ECfvoType
.
Number
:
res
=
parseFloat
(
oCFVO
.
Val
);
break
;
case
AscCommonExcel
.
ECfvoType
.
Percent
:
res
=
min
+
Math
.
floor
((
max
-
min
)
*
parseFloat
(
oCFVO
.
Val
)
/
100
);
break
;
case
AscCommonExcel
.
ECfvoType
.
Percentile
:
res
=
min
+
Math
.
floor
(
count
*
parseFloat
(
oCFVO
.
Val
)
/
100
);
break
;
}
}
return
res
;
};
function
CDataBar
()
{
function
CDataBar
()
{
this
.
MaxLength
=
90
;
this
.
MaxLength
=
90
;
...
@@ -191,6 +227,11 @@
...
@@ -191,6 +227,11 @@
this
.
b2
=
this
.
c2
.
getB
();
this
.
b2
=
this
.
c2
.
getB
();
};
};
CGradient
.
prototype
.
calculateColor
=
function
(
indexColor
)
{
CGradient
.
prototype
.
calculateColor
=
function
(
indexColor
)
{
if
(
indexColor
<
this
.
min
)
{
indexColor
=
this
.
min
;
}
else
if
(
indexColor
>
this
.
max
)
{
indexColor
=
this
.
max
;
}
indexColor
=
((
indexColor
-
this
.
min
)
*
this
.
koef
)
>>
0
;
indexColor
=
((
indexColor
-
this
.
min
)
*
this
.
koef
)
>>
0
;
var
r
=
(
this
.
r1
+
((
FT_Common
.
IntToUInt
(
this
.
r2
-
this
.
r1
)
*
indexColor
)
>>
this
.
base_shift
))
&
0xFF
;
var
r
=
(
this
.
r1
+
((
FT_Common
.
IntToUInt
(
this
.
r2
-
this
.
r1
)
*
indexColor
)
>>
this
.
base_shift
))
&
0xFF
;
...
...
cell/model/Serialize.js
View file @
76277a57
...
@@ -8088,6 +8088,7 @@
...
@@ -8088,6 +8088,7 @@
window
[
"
Asc
"
].
EFontScheme
=
EFontScheme
;
window
[
"
Asc
"
].
EFontScheme
=
EFontScheme
;
window
[
"
Asc
"
].
EIconSetType
=
EIconSetType
;
window
[
"
Asc
"
].
EIconSetType
=
EIconSetType
;
window
[
"
Asc
"
].
ECfType
=
ECfType
;
window
[
"
Asc
"
].
ECfType
=
ECfType
;
window
[
"
AscCommonExcel
"
].
ECfvoType
=
ECfvoType
;
window
[
"
Asc
"
].
ESparklineType
=
ESparklineType
;
window
[
"
Asc
"
].
ESparklineType
=
ESparklineType
;
window
[
"
Asc
"
].
EDispBlanksAs
=
EDispBlanksAs
;
window
[
"
Asc
"
].
EDispBlanksAs
=
EDispBlanksAs
;
window
[
"
Asc
"
].
SparklineAxisMinMax
=
SparklineAxisMinMax
;
window
[
"
Asc
"
].
SparklineAxisMinMax
=
SparklineAxisMinMax
;
...
...
cell/model/Workbook.js
View file @
76277a57
...
@@ -3493,12 +3493,12 @@ Woorksheet.prototype._getValuesForConditionalFormatting = function(sqref, withEm
...
@@ -3493,12 +3493,12 @@ Woorksheet.prototype._getValuesForConditionalFormatting = function(sqref, withEm
return
res
;
return
res
;
};
};
Woorksheet
.
prototype
.
_updateConditionalFormatting
=
function
(
range
)
{
Woorksheet
.
prototype
.
_updateConditionalFormatting
=
function
(
range
)
{
var
oGradient
=
null
;
var
oGradient
1
,
oGradient2
;
var
aCFs
=
this
.
aConditionalFormatting
;
var
aCFs
=
this
.
aConditionalFormatting
;
var
aRules
,
oRule
;
var
aRules
,
oRule
;
var
oRuleElement
=
null
;
var
oRuleElement
=
null
;
var
o
;
var
o
;
var
i
,
j
,
cell
,
sqref
,
values
,
value
,
tmp
,
min
,
max
,
dxf
,
compareFunction
,
nc
;
var
i
,
j
,
l
,
cell
,
sqref
,
values
,
value
,
v
,
tmp
,
min
,
mid
,
max
,
dxf
,
compareFunction
,
nc
;
for
(
i
=
0
;
i
<
aCFs
.
length
;
++
i
)
{
for
(
i
=
0
;
i
<
aCFs
.
length
;
++
i
)
{
sqref
=
aCFs
[
i
].
sqref
;
sqref
=
aCFs
[
i
].
sqref
;
// ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
// ToDo убрать null === sqref когда научимся мультиселект обрабатывать (\\192.168.5.2\source\DOCUMENTS\XLSX\Matematika Quantum Sedekah.xlsx)
...
@@ -3521,32 +3521,47 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3521,32 +3521,47 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
if
(
!
(
oRuleElement
instanceof
AscCommonExcel
.
CColorScale
))
{
if
(
!
(
oRuleElement
instanceof
AscCommonExcel
.
CColorScale
))
{
break
;
break
;
}
}
nc
=
0
;
min
=
Number
.
MAX_VALUE
;
min
=
Number
.
MAX_VALUE
;
max
=
-
Number
.
MAX_VALUE
;
max
=
-
Number
.
MAX_VALUE
;
values
=
this
.
_getValuesForConditionalFormatting
(
sqref
,
false
);
values
=
this
.
_getValuesForConditionalFormatting
(
sqref
,
false
);
for
(
cell
=
0
;
cell
<
values
.
v
.
length
;
++
cell
)
{
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
value
=
values
[
cell
];
value
=
values
[
cell
];
if
(
CellValueType
.
Number
===
value
.
c
.
getType
()
&&
!
isNaN
(
tmp
=
parseFloat
(
value
.
v
)))
{
if
(
CellValueType
.
Number
===
value
.
c
.
getType
()
&&
!
isNaN
(
tmp
=
parseFloat
(
value
.
v
)))
{
value
.
v
=
tmp
;
value
.
v
=
tmp
;
min
=
Math
.
min
(
min
,
tmp
);
min
=
Math
.
min
(
min
,
tmp
);
max
=
Math
.
max
(
max
,
tmp
);
max
=
Math
.
max
(
max
,
tmp
);
++
nc
;
}
else
{
}
else
{
value
.
v
=
null
;
value
.
v
=
null
;
}
}
}
}
// ToDo CFVO Type (formula, max, min, num, percent, percentile) (page 2681)
// ToDo CFVO Type formula (page 2681)
// ToDo support 3 colors in rule
l
=
oRuleElement
.
aColors
.
length
;
if
(
0
<
values
.
length
&&
2
===
oRuleElement
.
aColors
.
length
)
{
if
(
0
<
values
.
length
&&
2
<=
l
)
{
oGradient
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
0
],
oRuleElement
.
aColors
[
1
]);
oGradient1
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
0
],
oRuleElement
.
aColors
[
1
]);
oGradient
.
init
(
min
,
max
);
min
=
oRuleElement
.
getMin
(
min
,
max
,
nc
);
max
=
oRuleElement
.
getMax
(
min
,
max
,
nc
);
oGradient2
=
null
;
if
(
2
<
l
)
{
oGradient2
=
new
AscCommonExcel
.
CGradient
(
oRuleElement
.
aColors
[
1
],
oRuleElement
.
aColors
[
2
]);
mid
=
oRuleElement
.
getMid
(
min
,
max
,
nc
);
oGradient1
.
init
(
min
,
mid
);
oGradient2
.
init
(
mid
,
max
);
}
else
{
oGradient1
.
init
(
min
,
max
);
}
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
for
(
cell
=
0
;
cell
<
values
.
length
;
++
cell
)
{
value
=
values
[
cell
];
value
=
values
[
cell
];
v
=
value
.
v
;
dxf
=
null
;
dxf
=
null
;
if
(
null
!==
v
alue
.
v
)
{
if
(
null
!==
v
)
{
dxf
=
new
AscCommonExcel
.
CellXfs
();
dxf
=
new
AscCommonExcel
.
CellXfs
();
dxf
.
fill
=
new
AscCommonExcel
.
Fill
({
bg
:
oGradient
.
calculateColor
(
value
.
v
)});
tmp
=
(
oGradient2
&&
v
>
oGradient1
.
max
)
?
oGradient2
:
oGradient1
;
dxf
.
fill
=
new
AscCommonExcel
.
Fill
({
bg
:
tmp
.
calculateColor
(
v
)});
}
}
value
.
c
.
setConditionalFormattingStyle
(
dxf
);
value
.
c
.
setConditionalFormattingStyle
(
dxf
);
}
}
...
@@ -3567,7 +3582,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
...
@@ -3567,7 +3582,7 @@ Woorksheet.prototype._updateConditionalFormatting = function(range) {
}
}
values
.
sort
((
function
(
condition
)
{
values
.
sort
((
function
(
condition
)
{
return
function
(
v1
,
v2
)
{
return
function
(
v1
,
v2
)
{
return
condition
*
(
v2
.
v
-
v1
.
v
);
return
condition
*
(
v2
.
v
-
v1
.
v
);
}
}
})(
oRule
.
bottom
?
-
1
:
1
));
})(
oRule
.
bottom
?
-
1
:
1
));
...
...
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