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
5ca5094c
Commit
5ca5094c
authored
Jul 08, 2016
by
Sergey Luzyanin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/4.0.1' into develop
parents
b7549732
a7f33a1f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
238 additions
and
38 deletions
+238
-38
cell/apiBuilder.js
cell/apiBuilder.js
+187
-0
word/apiBuilder.js
word/apiBuilder.js
+51
-38
No files found.
cell/apiBuilder.js
View file @
5ca5094c
...
...
@@ -164,6 +164,7 @@
* @param {number} nFromRow
* @param {number} nToCol
* @param {number} nToRow
* @returns {ApiCahrt}
*/
ApiWorksheet
.
prototype
.
AddChart
=
function
(
sDataRange
,
bInRows
,
sType
,
nStyleIndex
,
nFromCol
,
nFromRow
,
nToCol
,
nToRow
)
{
...
...
@@ -293,6 +294,7 @@
if
(
AscFormat
.
isRealNumber
(
nStyleIndex
))
{
oChart
.
setStyle
(
nStyleIndex
);
}
return
new
ApiChart
(
oChart
);
};
/**
...
...
@@ -364,6 +366,185 @@
};
ApiChart
.
prototype
.
CreateTitle
=
function
(
sTitle
,
nFontSize
){
if
(
!
this
.
Chart
)
{
return
null
;
}
if
(
typeof
sTitle
===
"
string
"
&&
sTitle
.
length
>
0
){
var
oTitle
=
new
AscFormat
.
CTitle
();
oTitle
.
setTx
(
new
AscFormat
.
CChartText
());
oTitle
.
setOverlay
(
false
);
var
oTextBody
=
AscFormat
.
CreateTextBodyFromString
(
sTitle
,
this
.
Chart
.
getDrawingDocument
(),
oTitle
.
tx
);
if
(
AscFormat
.
isRealNumber
(
nFontSize
)){
oTextBody
.
content
.
Set_ApplyToAll
(
true
);
oTextBody
.
content
.
Paragraph_Add
(
new
ParaTextPr
({
FontSize
:
nFontSize
}));
oTextBody
.
content
.
Set_ApplyToAll
(
false
);
}
oTitle
.
tx
.
setRich
(
oTextBody
);
return
oTitle
;
}
return
null
;
};
/**
* Specifies a chart title
* @param {string} sTitle
* @param {number} nFontSize
*/
ApiChart
.
prototype
.
SetTitle
=
function
(
sTitle
,
nFontSize
)
{
if
(
this
.
Chart
)
{
this
.
Chart
.
chart
.
setTitle
(
this
.
CreateTitle
(
sTitle
,
nFontSize
));
}
};
/**
* Specifies a horizontal axis title
* @param {string} sTitle
* @param {number} nFontSize
* */
ApiChart
.
prototype
.
SetHorAxisTitle
=
function
(
sTitle
,
nFontSize
)
{
if
(
this
.
Chart
)
{
var
horAxis
=
this
.
Chart
.
chart
.
plotArea
.
getHorizontalAxis
();
if
(
horAxis
)
{
horAxis
.
setTitle
(
this
.
CreateTitle
(
sTitle
,
nFontSize
));
}
}
};
/**
* Specifies a vertical axis title
* @param {string} sTitle
* @param {number} nFontSize
* */
ApiChart
.
prototype
.
SetVerAxisTitle
=
function
(
sTitle
,
nFontSize
)
{
if
(
this
.
Chart
)
{
var
verAxis
=
this
.
Chart
.
chart
.
plotArea
.
getVerticalAxis
();
if
(
verAxis
)
{
if
(
typeof
sTitle
===
"
string
"
&&
sTitle
.
length
>
0
)
{
verAxis
.
setTitle
(
this
.
CreateTitle
(
sTitle
,
nFontSize
));
if
(
verAxis
.
title
){
var
_body_pr
=
new
AscFormat
.
CBodyPr
();
_body_pr
.
reset
();
if
(
!
verAxis
.
title
.
txPr
)
{
verAxis
.
title
.
setTxPr
(
AscFormat
.
CreateTextBodyFromString
(
""
,
this
.
Chart
.
getDrawingDocument
(),
verAxis
.
title
));
}
var
_text_body
=
verAxis
.
title
.
txPr
;
_text_body
.
setBodyPr
(
_body_pr
);
verAxis
.
title
.
setOverlay
(
false
);
}
}
else
{
verAxis
.
setTitle
(
null
);
}
}
}
};
/**
* Specifies a legend position
* @param {"left" | "top" | "right" | "bottom" | "none"} sLegendPos
* */
ApiChart
.
prototype
.
SetLegendPos
=
function
(
sLegendPos
)
{
if
(
this
.
Chart
&&
this
.
Chart
.
chart
)
{
if
(
sLegendPos
===
"
none
"
)
{
if
(
this
.
Chart
.
chart
.
legend
)
{
this
.
Chart
.
chart
.
setLegend
(
null
);
}
}
else
{
var
nLegendPos
=
null
;
switch
(
sLegendPos
)
{
case
"
left
"
:
{
nLegendPos
=
Asc
.
c_oAscChartLegendShowSettings
.
left
;
break
;
}
case
"
top
"
:
{
nLegendPos
=
Asc
.
c_oAscChartLegendShowSettings
.
top
;
break
;
}
case
"
right
"
:
{
nLegendPos
=
Asc
.
c_oAscChartLegendShowSettings
.
right
;
break
;
}
case
"
bottom
"
:
{
nLegendPos
=
Asc
.
c_oAscChartLegendShowSettings
.
bottom
;
break
;
}
}
if
(
null
!==
nLegendPos
)
{
if
(
!
this
.
Chart
.
chart
.
legend
)
{
this
.
Chart
.
chart
.
setLegend
(
new
AscFormat
.
CLegend
());
}
if
(
this
.
Chart
.
chart
.
legend
.
legendPos
!==
nLegendPos
)
this
.
Chart
.
chart
.
legend
.
setLegendPos
(
nLegendPos
);
if
(
this
.
Chart
.
chart
.
legend
.
overlay
!==
false
)
{
this
.
Chart
.
chart
.
legend
.
setOverlay
(
false
);
}
}
}
}
};
/**
* Spicifies a show options for data labels
* @param {boolean} bShowSerName
* @param {boolean} bShowCatName
* @param {boolean} bShowVal
* */
ApiChart
.
prototype
.
SetShowDataLabels
=
function
(
bShowSerName
,
bShowCatName
,
bShowVal
)
{
if
(
this
.
Chart
&&
this
.
Chart
.
chart
&&
this
.
Chart
.
chart
.
plotArea
&&
this
.
Chart
.
chart
.
plotArea
.
charts
[
0
])
{
var
oChart
=
this
.
Chart
.
chart
.
plotArea
.
charts
[
0
];
if
(
false
==
bShowSerName
&&
false
==
bShowCatName
&&
false
==
bShowVal
)
{
if
(
oChart
.
dLbls
)
{
oChart
.
setDLbls
(
null
);
}
}
if
(
!
oChart
.
dLbls
)
{
oChart
.
setDLbls
(
new
AscFormat
.
CDLbls
());
}
oChart
.
dLbls
.
setSeparator
(
"
,
"
);
oChart
.
dLbls
.
setShowSerName
(
true
==
bShowSerName
);
oChart
.
dLbls
.
setShowCatName
(
true
==
bShowCatName
);
oChart
.
dLbls
.
setShowVal
(
true
==
bShowVal
);
oChart
.
dLbls
.
setShowLegendKey
(
false
);
//oChart.dLbls.setShowPercent(false);
oChart
.
dLbls
.
setShowBubbleSize
(
false
);
}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Export
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -385,4 +566,10 @@
ApiRange
.
prototype
[
"
SetFontName
"
]
=
ApiRange
.
prototype
.
SetFontName
;
ApiRange
.
prototype
[
"
SetAlignVertical
"
]
=
ApiRange
.
prototype
.
SetAlignVertical
;
ApiRange
.
prototype
[
"
SetAlignHorizontal
"
]
=
ApiRange
.
prototype
.
SetAlignHorizontal
;
ApiChart
.
prototype
[
"
SetTitle
"
]
=
ApiChart
.
prototype
.
SetTitle
;
ApiChart
.
prototype
[
"
SetHorAxisTitle
"
]
=
ApiChart
.
prototype
.
SetHorAxisTitle
;
ApiChart
.
prototype
[
"
SetVerAxisTitle
"
]
=
ApiChart
.
prototype
.
SetVerAxisTitle
;
ApiChart
.
prototype
[
"
SetLegendPos
"
]
=
ApiChart
.
prototype
.
SetLegendPos
;
ApiChart
.
prototype
[
"
SetShowDataLabels
"
]
=
ApiChart
.
prototype
.
SetShowDataLabels
;
}(
window
,
null
));
word/apiBuilder.js
View file @
5ca5094c
...
...
@@ -613,9 +613,11 @@
* @param {Array} aCatNames
* @param {EMU} nWidth
* @param {EMU} nHeight
* @param {EMU} nHeight
* @param {number} nStyleIndex
* @returns {ApiChart}
* */
Api
.
prototype
.
CreateChart
=
function
(
sType
,
aSeries
,
aSeriesNames
,
aCatNames
,
nWidth
,
nHeight
)
Api
.
prototype
.
CreateChart
=
function
(
sType
,
aSeries
,
aSeriesNames
,
aCatNames
,
nWidth
,
nHeight
,
nStyleIndex
)
{
var
oDrawingDocument
=
private_GetDrawingDocument
();
var
oLogicDocument
=
private_GetLogicDocument
();
...
...
@@ -782,6 +784,9 @@
oChartSpace
.
setBDeleted
(
false
);
oChartSpace
.
extX
=
nW
;
oChartSpace
.
extY
=
nH
;
if
(
AscFormat
.
isRealNumber
(
nStyleIndex
)){
oChartSpace
.
setStyle
(
nStyleIndex
);
}
AscFormat
.
CheckSpPrXfrm
(
oChartSpace
);
oDrawing
.
setExtent
(
oChartSpace
.
spPr
.
xfrm
.
extX
,
oChartSpace
.
spPr
.
xfrm
.
extY
);
return
new
ApiChart
(
oChartSpace
);
...
...
@@ -3719,49 +3724,54 @@
};
ApiChart
.
prototype
.
CreateTitle
=
function
(
sTitle
,
nFontSize
){
if
(
!
this
.
Chart
)
{
return
null
;
}
if
(
typeof
sTitle
===
"
string
"
&&
sTitle
.
length
>
0
){
var
oTitle
=
new
AscFormat
.
CTitle
();
oTitle
.
setOverlay
(
false
);
oTitle
.
setTx
(
new
AscFormat
.
CChartText
());
var
oTextBody
=
AscFormat
.
CreateTextBodyFromString
(
sTitle
,
this
.
Chart
.
getDrawingDocument
(),
oTitle
.
tx
);
if
(
AscFormat
.
isRealNumber
(
nFontSize
)){
oTextBody
.
content
.
Set_ApplyToAll
(
true
);
oTextBody
.
content
.
Paragraph_Add
(
new
ParaTextPr
({
FontSize
:
nFontSize
}));
oTextBody
.
content
.
Set_ApplyToAll
(
false
);
}
oTitle
.
tx
.
setRich
(
oTextBody
);
return
oTitle
;
}
return
null
;
};
/**
* Specifies a chart title
* @param {string} sTitle
* */
ApiChart
.
prototype
.
SetTitle
=
function
(
sTitle
)
* @param {hps} nFontSize
*/
ApiChart
.
prototype
.
SetTitle
=
function
(
sTitle
,
nFontSize
)
{
if
(
this
.
Chart
)
{
if
(
typeof
sTitle
===
"
string
"
&&
sTitle
.
length
>
0
)
{
this
.
Chart
.
chart
.
setTitle
(
new
AscFormat
.
CTitle
());
this
.
Chart
.
chart
.
title
.
setTx
(
new
AscFormat
.
CChartText
());
this
.
Chart
.
chart
.
title
.
tx
.
setRich
(
AscFormat
.
CreateTextBodyFromString
(
sTitle
,
this
.
Chart
.
getDrawingDocument
(),
this
.
Chart
.
chart
.
title
.
tx
))
}
else
{
this
.
Chart
.
chart
.
setTitle
(
null
);
}
this
.
Chart
.
chart
.
setTitle
(
this
.
CreateTitle
(
sTitle
,
nFontSize
));
}
};
/**
* Specifies a horizontal axis title
* @param {string} sTitle
* @param {hps} nFontSize
* */
ApiChart
.
prototype
.
SetHorAxisTitle
=
function
(
sTitle
)
ApiChart
.
prototype
.
SetHorAxisTitle
=
function
(
sTitle
,
nFontSize
)
{
if
(
this
.
Chart
)
{
var
horAxis
=
this
.
Chart
.
chart
.
plotArea
.
getHorizontalAxis
();
if
(
horAxis
)
{
if
(
typeof
sTitle
===
"
string
"
&&
sTitle
.
length
>
0
)
{
horAxis
.
setTitle
(
new
AscFormat
.
CTitle
());
horAxis
.
title
.
setTx
(
new
AscFormat
.
CChartText
());
horAxis
.
title
.
tx
.
setRich
(
AscFormat
.
CreateTextBodyFromString
(
sTitle
,
this
.
Chart
.
getDrawingDocument
(),
horAxis
.
title
.
tx
));
horAxis
.
title
.
setOverlay
(
false
);
}
else
{
horAxis
.
setTitle
(
null
);
}
horAxis
.
setTitle
(
this
.
CreateTitle
(
sTitle
,
nFontSize
));
}
}
};
...
...
@@ -3769,8 +3779,9 @@
/**
* Specifies a vertical axis title
* @param {string} sTitle
* @param {hps} nFontSize
* */
ApiChart
.
prototype
.
SetVerAxisTitle
=
function
(
sTitle
)
ApiChart
.
prototype
.
SetVerAxisTitle
=
function
(
sTitle
,
nFontSize
)
{
if
(
this
.
Chart
)
{
...
...
@@ -3779,10 +3790,8 @@
{
if
(
typeof
sTitle
===
"
string
"
&&
sTitle
.
length
>
0
)
{
verAxis
.
setTitle
(
new
AscFormat
.
CTitle
());
verAxis
.
title
.
setTx
(
new
AscFormat
.
CChartText
());
verAxis
.
title
.
tx
.
setRich
(
AscFormat
.
CreateTextBodyFromString
(
sTitle
,
this
.
Chart
.
getDrawingDocument
(),
verAxis
.
title
.
tx
));
verAxis
.
setTitle
(
this
.
CreateTitle
(
sTitle
,
nFontSize
));
if
(
verAxis
.
title
){
var
_body_pr
=
new
AscFormat
.
CBodyPr
();
_body_pr
.
reset
();
if
(
!
verAxis
.
title
.
txPr
)
...
...
@@ -3793,6 +3802,7 @@
_text_body
.
setBodyPr
(
_body_pr
);
verAxis
.
title
.
setOverlay
(
false
);
}
}
else
{
verAxis
.
setTitle
(
null
);
...
...
@@ -3885,6 +3895,9 @@
oChart
.
dLbls
.
setShowSerName
(
true
==
bShowSerName
);
oChart
.
dLbls
.
setShowCatName
(
true
==
bShowCatName
);
oChart
.
dLbls
.
setShowVal
(
true
==
bShowVal
);
oChart
.
dLbls
.
setShowLegendKey
(
false
);
//oChart.dLbls.setShowPercent(false);
oChart
.
dLbls
.
setShowBubbleSize
(
false
);
}
};
...
...
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