Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features to Enable Tornado Chart #140

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
grid and axis options
  • Loading branch information
clubajax committed Aug 10, 2017
commit a21e98de25e3e1a4ad1ae2fe8d0b72233aed5304
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ slide.addChart({TYPE}, {DATA}, {OPTIONS});
| `w` | number | inches | `50%` | width | 0-n OR 'n%'. (Ex: `{w:'50%'}` will make object 50% width of the Slide) |
| `h` | number | inches | `50%` | height | 0-n OR 'n%'. |
| `border` | object | | | chart border | object with `pt` and `color` values. Ex: `border:{pt:'1', color:'f1f1f1'}` |
| `chartColors` | array | | | data color | array of hex color codes. Ex: `['0088CC','FFCC00']` |
| `chartColors` | array | | | data color | array of hex color codes. Ex: `['0088CC','FFCC00']` |
| `invertedColors`| array | | | colors when value is < 0 | array of hex color codes. Ex: `['0088CC','FFCC00']` |
| `chartColorsOpacity` | number | percent | `100` | data color opacity percent | 1-100. Ex: `{ chartColorsOpacity:50 }` |
| `fill` | string | | | fill/background color | hex color code. Ex: `{ fill:'0088CC' }` |
| `legendPos` | string | | `r` | chart legend position | `b` (bottom), `tr` (top-right), `l` (left), `r` (right), `t` (top) |
Expand All @@ -350,10 +351,13 @@ slide.addChart({TYPE}, {DATA}, {OPTIONS});
| Option | Type | Unit | Default | Description | Possible Values |
| :--------------------- | :------ | :------ | :-------- | :---------------------- | :----------------------------------------- |
| `axisLabelFormatCode` | string | | | format to show axis value | format string. Ex: `{ axisLabelFormatCode:'#,##0' }` [MicroSoft Number Format Codes](https://support.office.com/en-us/article/Number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68) |
| `axisLineColor` | string | | `888888` | axis line color | format string. Ex: `{ axisLineColor:'00FFFF' }` |
| `axisLineShow` | boolean | | true | show/hide axis line | `true` or `false` |
| `catAxisLabelColor` | string | | `000000` | category-axis color | hex color code. Ex: `{ catAxisLabelColor:'0088CC' }` |
| `catAxisLabelFontFace` | string | | `Arial` | category-axis font face | font name. Ex: `{ titleFontFace:'Arial' }` |
| `catAxisLabelFontSize` | number | points | `18` | category-axis font size | 1-256. Ex: `{ titleFontSize:12 }` |
| `catAxisOrientation` | string | | `minMax` | category-axis orientation | `maxMin` (high->low) or `minMax` (low->high) |
| `gridLineColor` | string | | `888888` | grid-line color | hex color code. Ex: `{ catAxisLabelColor:'0088CC' }` |
| `majorUnit` | number | float | `1.0` | axis tick steps | Float or whole number. Ex: `{ majorUnit:0.2 }` |
| `valAxisLabelColor` | string | | `000000` | value-axis color | hex color code. Ex: `{ valAxisLabelColor:'0088CC' }` |
| `valAxisLabelFontFace` | string | | `Arial` | value-axis font face | font name. Ex: `{ titleFontFace:'Arial' }` |
Expand Down
17 changes: 14 additions & 3 deletions dist/pptxgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ var PptxGenJS = function(){

// B: "Category Axis"
{
console.log('rel.opts.tickLblPos', rel.opts.tickLblPos);
strXml += '<c:catAx>';
strXml += ' <c:axId val="2094734552"/>';
strXml += ' <c:scaling><c:orientation val="'+ (rel.opts.catAxisOrientation || (rel.opts.barDir == 'col' ? 'minMax' : 'minMax')) +'"/></c:scaling>';
Expand All @@ -1151,7 +1152,7 @@ var PptxGenJS = function(){
strXml += ' <c:numFmt formatCode="General" sourceLinked="0"/>';
strXml += ' <c:majorTickMark val="out"/>';
strXml += ' <c:minorTickMark val="none"/>';
strXml += ' <c:tickLblPos val="'+ (rel.opts.barDir == 'col' ? 'low' : 'nextTo') +'"/>';
strXml += ' <c:tickLblPos val="'+ (rel.opts.tickLblPos || rel.opts.barDir == 'col' ? 'low' : 'nextTo') +'"/>';
strXml += ' <c:spPr>';
strXml += ' <a:ln w="12700" cap="flat"><a:solidFill><a:srgbClr val="888888"/></a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>';
strXml += ' </c:spPr>';
Expand Down Expand Up @@ -1191,7 +1192,7 @@ var PptxGenJS = function(){
strXml += ' <c:majorGridlines>\
<c:spPr>\
<a:ln w="12700" cap="flat">\
<a:solidFill><a:srgbClr val="888888"/></a:solidFill>\
<a:solidFill><a:srgbClr val="'+(rel.opts.gridLineColor ? rel.opts.gridLineColor : "888888")+'"/></a:solidFill>\
<a:prstDash val="solid"/><a:round/>\
</a:ln>\
</c:spPr>\
Expand All @@ -1201,7 +1202,17 @@ var PptxGenJS = function(){
strXml += ' <c:minorTickMark val="none"/>';
strXml += ' <c:tickLblPos val="'+ (rel.opts.barDir == 'col' ? 'nextTo' : 'low') +'"/>';
strXml += ' <c:spPr>';
strXml += ' <a:ln w="12700" cap="flat"><a:solidFill><a:srgbClr val="888888"/></a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>';
strXml += ' <a:ln w="12700" cap="flat">';
if (rel.opts.axisLineShow) {
strXml += ' <a:solidFill>';
strXml += ' <a:srgbClr val="'+(rel.opts.axisLineColor ? rel.opts.axisLineColor : "888888")+'"/>';
strXml += ' </a:solidFill>';
} else {
strXml += ' <a:noFill/>';
}
strXml += ' <a:prstDash val="solid"/>';
strXml += ' <a:round/>';
strXml += ' </a:ln>';
strXml += ' </c:spPr>';
strXml += ' <c:txPr>';
strXml += ' <a:bodyPr rot="0"/>';
Expand Down
35 changes: 35 additions & 0 deletions examples/pptxgenjs-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,41 @@ function genSlides_Chart(pptx) {
majorUnit: 1
});
}

// SLIDE 11: Tornado chart
{
var slide = pptx.addNewSlide();
slide.addTable( [ [{ text:'Tornado Chart - Grid and Axis Formatting', options:gOptsTitle }] ], { x:0.5, y:0.13, w:12.5 } );

slide.addChart(
pptx.charts.BAR,
[
{
name: 'High',
labels: ['City A', 'City A', 'City C'],
values: [.20, .32, .41]
}, {
name: 'Low',
labels: ['City A', 'City A', 'City C'],
values: [-0.11, -0.22, -0.29]
}
], { x:0.5, y:0.5, w:'90%', h:'90%',
valAxisMaxVal:1,
barDir: 'bar',
axisLabelFormatCode: '#%',
gridLineColor: 'D8D8D8', // DOCTHIS - DO THIS ?
axisLineColor: 'D8D8D8', // DOCTHIS - DO THIS ?
axisLineShow: false,
barGrouping: 'stacked',
tickLblPos: 'low', // DOCTHIS
valueBarColors: true, // DOCTHIS
//dataLabelPosition: 'outEnd',
chartColors: ['0077BF','4E9D2D','ECAA00','5FC4E3','DE4216','154384', '7D666A','A3C961','EF907B','9BA0A3'],
invertedColors: [ '0065A2', '428526', 'C99100', '51A7C1', 'BD3813', '123970', '6A575A', '8BAB52', 'CB7A69', '84888B' ], // DOCTHIS
barGapWidthPct: 25,
majorUnit: 0.2
});
}
}

function genSlides_Media(pptx) {
Expand Down