Comments (6)
@alexleventer It is possible to create a bar chart. See examples/make_pptx.js
for a few examples. For your immediate purpose, use the more general slide.makeChart(..)
and set renderType: 'bar'
on the object you pass to it:
slide.addChart({
title: 'Sample bar chart',
renderType: 'bar',
data: [...]
}, null, doneCallback, errorCallback);
Thanks for catching the issue with the convenience methods. Will fix that and the docs, and these to the nascent test files
from officegen.
Thanks for the quick response @pietersv , do I first have to make the chart and then add chart?
from officegen.
Looks like NPM module is out of date w/ the repo
from officegen.
and the latest npm release includes setWidescreen
but this repo does not.
from officegen.
aha. there's an outstanding pull request. For now try npm install pietersv/officegen
to install directly from GitHub. Below is a complete example that should work.
var fs = require('fs');
var officegen = require('../');
var chartInfo = {
title: 'Sample bar chart',
renderType: 'bar',
xmlOptions: {
"c:title": {
"c:tx": {
"c:rich": {
"a:p": {
"a:r": {
"a:t": "Override title via XML"
}
}
}
}
}
},
data: [
{
name: 'europe',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [2.5, 2.6, 2.8],
color: 'ff0000'
},
{
name: 'namerica',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [2.5, 2.7, 2.9],
color: '00ff00'
},
{
name: 'asia',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [2.1, 2.2, 2.4],
color: '0000ff'
},
{
name: 'lamerica',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [0.3, 0.3, 0.3],
color: 'ffff00'
},
{
name: 'meast',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [0.2, 0.3, 0.3],
color: 'ff00ff'
},
{
name: 'africa',
labels: ['Y2003', 'Y2004', 'Y2005'],
values: [0.1, 0.1, 0.1],
color: '00ffff'
}
]
};
var chartIdx = 3;
var pptx = officegen('pptx');
pptx.setDocTitle('Sample PPTX Document');
var slide = pptx.makeNewSlide();
slide.name = 'OfficeChart slide';
slide.back = 'ffffff';
slide.addChart(
chartInfo,
null,
function () {
var FILENAME = "test-ppt-chart" + chartIdx + ".pptx";
var FILENAME_ALT = "test-ppt-chart-" + chartInfo.renderType + ".pptx";
var out = fs.createWriteStream('/tmp/' + FILENAME_ALT);
pptx.generate(out, {
'finalize': function (written) {
console.log("Done!")
},
'error': console.error
});
}, console.error);
from officegen.
@alexleventer Glad to hear that worked. I've just updated the fork https://github.com/pietersv/officegen as follows:
- Changed
slide.addChart( info, renderType, success, error)
toslide.addChart( info, success, error)
- Dropped convenience methods
addBarChart()
,addPieChart()
andaddColumnChart()
- Updated
README.md
,examples/make_pptx.js
andtest/test_pptx.js
accordingly
The gist is that the renderType (i.e. bar
, pie
, column
, group-bar
) was specified in two places, either within the chartInfo
object and/or the arguments to addChart()
. Have dropped the latter, so its only specified in the chartInfo
object now.
from officegen.
Related Issues (20)
- How to make a particular page Orientation to A3 / Landscape ? HOT 2
- How to add Sections in word file with Officegen ? and how to set font size and to make it bold for entire column in a table
- How to set the first line indentation for a paragraph in word?
- Can i remove Header and Footer from First page ( Title Page ) and some more queries
- Why does the table fill color not work?
- Cannot generate word file in render process for one Electron app
- How to add repeat header in table docx
- How to insert image into tableceil in docx
- how to open a word document ?
- Is addImage with svg supported for pptx file?
- How to assign color property to newline in table cell in word document ?
- 如何将word转换html,html里面的style css可以转换?
- Embedded File is still being accessed by createReadStream asynchronously even after deletion in officegen for Word Document
- Make the generated document read-only of password protected?
- Can I set a password to access Word
- How to add Number Bullet lists and Sub Number Bullet list
- How can i set auto-warp attribute to a column or cell in Excel file?
- Suggestion:Footer supports inserting tables
- May I ask if it is possible to add a background color to the Word document
- Can a transformation map be created with this library?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officegen.