Skip to content

Commit

Permalink
Scheme colors support added to parts where was missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Kacerovsky committed Aug 28, 2017
1 parent 38bef52 commit 65a0cca
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions dist/pptxgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ var PptxGenJS = function(){
var cellValign = (cellOpts.valign) ? ' anchor="'+ cellOpts.valign.replace(/^c$/i,'ctr').replace(/^m$/i,'ctr').replace('center','ctr').replace('middle','ctr').replace('top','t').replace('btm','b').replace('bottom','b') +'"' : '';
var cellColspan = (cellOpts.colspan) ? ' gridSpan="'+ cellOpts.colspan +'"' : '';
var cellRowspan = (cellOpts.rowspan) ? ' rowSpan="'+ cellOpts.rowspan +'"' : '';
var cellFill = ((cell.optImp && cell.optImp.fill) || cellOpts.fill ) ? ' <a:solidFill><a:srgbClr val="'+ ((cell.optImp && cell.optImp.fill) || cellOpts.fill.replace('#','')) +'"/></a:solidFill>' : '';
var cellFill = ((cell.optImp && cell.optImp.fill) || cellOpts.fill ) ? ' <a:solidFill>' + createColorElement((cell.optImp && cell.optImp.fill) || cellOpts.fill.replace('#','')) +'</a:solidFill>' : '';
var cellMargin = ( cellOpts.margin == 0 || cellOpts.margin ? cellOpts.margin : (cellOpts.marginPt || DEF_CELL_MARGIN_PT) );
if ( !Array.isArray(cellMargin) && typeof cellMargin === 'number' ) cellMargin = [cellMargin,cellMargin,cellMargin,cellMargin];
cellMargin = ' marL="'+ cellMargin[3]*ONEPT +'" marR="'+ cellMargin[1]*ONEPT +'" marT="'+ cellMargin[0]*ONEPT +'" marB="'+ cellMargin[2]*ONEPT +'"';
Expand All @@ -783,15 +783,15 @@ var PptxGenJS = function(){

// 5: Borders: Add any borders
if ( cellOpts.border && typeof cellOpts.border === 'string' ) {
strXml += ' <a:lnL w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:srgbClr val="'+ cellOpts.border +'"/></a:solidFill></a:lnL>';
strXml += ' <a:lnR w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:srgbClr val="'+ cellOpts.border +'"/></a:solidFill></a:lnR>';
strXml += ' <a:lnT w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:srgbClr val="'+ cellOpts.border +'"/></a:solidFill></a:lnT>';
strXml += ' <a:lnB w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:srgbClr val="'+ cellOpts.border +'"/></a:solidFill></a:lnB>';
strXml += ' <a:lnL w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill>' + createColorElement(cellOpts.border) + '</a:solidFill></a:lnL>';
strXml += ' <a:lnR w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill>' + createColorElement(cellOpts.border) + '</a:solidFill></a:lnR>';
strXml += ' <a:lnT w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill>' + createColorElement(cellOpts.border) + '</a:solidFill></a:lnT>';
strXml += ' <a:lnB w="'+ ONEPT +'" cap="flat" cmpd="sng" algn="ctr"><a:solidFill>' + createColorElement(cellOpts.border) + '</a:solidFill></a:lnB>';
}
else if ( cellOpts.border && Array.isArray(cellOpts.border) ) {
$.each([ {idx:3,name:'lnL'}, {idx:1,name:'lnR'}, {idx:0,name:'lnT'}, {idx:2,name:'lnB'} ], function(i,obj){
if ( cellOpts.border[obj.idx] ) {
var strC = '<a:solidFill><a:srgbClr val="'+ ((cellOpts.border[obj.idx].color) ? cellOpts.border[obj.idx].color : '666666') +'"/></a:solidFill>';
var strC = '<a:solidFill>' + createColorElement((cellOpts.border[obj.idx].color) ? cellOpts.border[obj.idx].color : '666666') + '</a:solidFill>';
var intW = (cellOpts.border[obj.idx] && (cellOpts.border[obj.idx].pt || cellOpts.border[obj.idx].pt == 0)) ? (ONEPT * Number(cellOpts.border[obj.idx].pt)) : ONEPT;
strXml += '<a:'+ obj.name +' w="'+ intW +'" cap="flat" cmpd="sng" algn="ctr">'+ strC +'</a:'+ obj.name +'>';
}
Expand All @@ -800,7 +800,7 @@ var PptxGenJS = function(){
}
else if ( cellOpts.border && typeof cellOpts.border === 'object' ) {
var intW = (cellOpts.border && (cellOpts.border.pt || cellOpts.border.pt == 0) ) ? (ONEPT * Number(cellOpts.border.pt)) : ONEPT;
var strClr = '<a:solidFill><a:srgbClr val="'+ ((cellOpts.border.color) ? cellOpts.border.color.replace('#','') : '666666') +'"/></a:solidFill>';
var strClr = '<a:solidFill>' + createColorElement((cellOpts.border.color) ? cellOpts.border.color.replace('#','') : '666666') + '</a:solidFill>';
var strAttr = '<a:prstDash val="';
strAttr += ((cellOpts.border.type && cellOpts.border.type.toLowerCase().indexOf('dash') > -1) ? "sysDash" : "solid" );
strAttr += '"/><a:round/><a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>';
Expand Down Expand Up @@ -901,8 +901,7 @@ var PptxGenJS = function(){
strSlideXml += '<a:'+ slideItemObj.options.shadow.type +'Shdw sx="100000" sy="100000" kx="0" ky="0" ';
strSlideXml += ' algn="bl" rotWithShape="0" blurRad="'+ slideItemObj.options.shadow.blur +'" ';
strSlideXml += ' dist="'+ slideItemObj.options.shadow.offset +'" dir="'+ slideItemObj.options.shadow.angle +'">';
strSlideXml += '<a:srgbClr val="'+ slideItemObj.options.shadow.color +'">';
strSlideXml += '<a:alpha val="'+ slideItemObj.options.shadow.opacity +'"/></a:srgbClr>'
strSlideXml += createColorElement(slideItemObj.options.shadow.color, '<a:alpha val="'+ slideItemObj.options.shadow.opacity +'"/>');
strSlideXml += '</a:outerShdw>';
strSlideXml += '</a:effectLst>';
}
Expand Down Expand Up @@ -1940,8 +1939,7 @@ var PptxGenJS = function(){
strXml += '<a:'+ type +'Shdw sx="100000" sy="100000" kx="0" ky="0" ';
strXml += ' algn="bl" rotWithShape="'+ (+rotateWithShape) +'" blurRad="'+ blur +'" ';
strXml += ' dist="'+ offset +'" dir="'+ angle +'">';
strXml += '<a:srgbClr val="'+ color +'">'; // TODO: should accept scheme colors implemented in Issue #135
strXml += '<a:alpha val="'+ opacity +'"/></a:srgbClr>'
strXml += createColorElement(color, '<a:alpha val="'+ opacity +'"/>');
strXml += '</a:'+ type +'Shdw>';

return strXml;
Expand Down Expand Up @@ -2008,7 +2006,7 @@ var PptxGenJS = function(){
strXml = '<'+ tagName + '>';
strXml += ' <c:spPr>';
strXml += ' <a:ln w="' + Math.round((glOpts.size || defaults.size) * ONEPT) +'" cap="flat">';
strXml += ' <a:solidFill><a:srgbClr val="' + (glOpts.color || defaults.color) + '"/></a:solidFill>'; // should accept scheme colors as implemented in PR 135
strXml += ' <a:solidFill>' + createColorElement(glOpts.color || defaults.color); // should accept scheme colors as implemented in PR 135
strXml += ' <a:prstDash val="' + (glOpts.style || defaults.style) + '"/><a:round/>';
strXml += ' </a:ln>';
strXml += ' </c:spPr>';
Expand Down Expand Up @@ -2241,8 +2239,8 @@ var PptxGenJS = function(){
strXml += ' <c:bubble3D val="0"/>';
strXml += ' <c:spPr>';
strXml += ' <a:solidFill>';
strXml += ' <a:srgbClr val="'+(colors[index % colors.length])+'"/>';
strXml += ' </a:solidFill>';
strXml += createColorElement(colors[index % colors.length]);
strXml += ' </a:solidFill>';
strXml += ' <a:effectLst>';
strXml += ' <a:outerShdw blurRad="38100" dist="23000" dir="5400000" algn="tl">';
strXml += ' <a:srgbClr val="000000">';
Expand Down Expand Up @@ -2345,7 +2343,7 @@ var PptxGenJS = function(){
strXml += ' <a:ln w="12700" cap="flat">';
if ( !!rel.opts.catAxisLineShow || typeof rel.opts.catAxisLineShow === 'undefined' ) {
strXml += '<a:solidFill>';
strXml += ' <a:srgbClr val="'+ (rel.opts.axisLineColor ? rel.opts.axisLineColor : DEF_CHART_GRIDLINE.color) +'"/>';
strXml += createColorElement(rel.opts.axisLineColor ? rel.opts.axisLineColor : DEF_CHART_GRIDLINE.color);
strXml += '</a:solidFill>';
}
else {
Expand Down Expand Up @@ -2404,7 +2402,7 @@ var PptxGenJS = function(){
strXml += ' <a:ln w="12700" cap="flat">';
if ( !!rel.opts.valAxisLineShow || typeof rel.opts.valAxisLineShow === 'undefined' ) {
strXml += '<a:solidFill>';
strXml += ' <a:srgbClr val="'+ (rel.opts.axisLineColor ? rel.opts.axisLineColor : DEF_CHART_GRIDLINE.color) +'"/>';
strXml += createColorElement(rel.opts.axisLineColor ? rel.opts.axisLineColor : DEF_CHART_GRIDLINE.color);
strXml += '</a:solidFill>';
}
else {
Expand Down Expand Up @@ -2647,13 +2645,13 @@ var PptxGenJS = function(){
sizeAttr = ' sz="' + opts.fontSize + '00"';
}
strXml += ' <a:defRPr b="0" i="0" strike="noStrike"'+ sizeAttr +' u="none">';
strXml += ' <a:solidFill><a:srgbClr val="'+ (opts.color || '000000') +'"/></a:solidFill>';
strXml += ' <a:solidFill>' + createColorElement(opts.color || '000000') + '</a:solidFill>';
strXml += ' <a:latin typeface="'+ (opts.fontFace || 'Arial') +'"/>';
strXml += ' </a:defRPr>';
strXml += ' </a:pPr>';
strXml += ' <a:r>';
strXml += ' <a:rPr b="0" i="0" strike="noStrike"'+ sizeAttr +' u="none">';
strXml += ' <a:solidFill><a:srgbClr val="'+ (opts.color || '000000') +'"/></a:solidFill>';
strXml += ' <a:solidFill>' + createColorElement(opts.color || '000000') + '</a:solidFill>';
strXml += ' <a:latin typeface="'+ (opts.fontFace || 'Arial') +'"/>';
strXml += ' </a:rPr>';
strXml += ' <a:t>'+ (decodeXmlEntities(opts.title) || '') +'</a:t>';
Expand Down

0 comments on commit 65a0cca

Please sign in to comment.