-
Notifications
You must be signed in to change notification settings - Fork 2.7k
PHPword: insert chart in template #1864
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
Closed
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
33f1619
[BUGFIX] allow to load unclean html without exception
kaystrobach b54200e
Merge branch 'develop' into patch-1
troosan 6e00210
stop building for 5.3, 5.4, 5.5 and 7.0
troosan 2968370
update dependencies to minimum php 5.6 dependencies
troosan 2a8a32e
add alias for 1.0-dev branch
troosan 5bc9250
Fix unit tests
troosan 06a9271
remove whitespaces
troosan 8d92409
Merge pull request #1032 from kaystrobach/patch-1
troosan b54f391
Merge pull request #1545 from troosan/stop_building_for_php5.3
troosan 847520f
Merge branch 'master' into develop_v1.0
troosan 9914f3d
Merge branch 'develop' into develop_v1.0
590a8b7
build with php nightly
711fcde
still allow php 7.4 to fail because of dompdf
bf52f2d
php 7.4 not yet available
6d50133
update 7.4 in travis build
087628d
update to phpunit 7.5
3b8d1cf
Add TemplateProcessor.setChart
dbarzin 90fef2c
Add TemplateProcessor.setChart
dbarzin 52b2175
small bugs in element chart
dbarzin ee83fed
Revert "small bugs in element chart"
dbarzin 3386548
Fix color change with multiple series
dbarzin f98db98
Revert "Fix color change with multiple series"
dbarzin c79653c
Change color assignment
dbarzin 75ef6bf
Revert "Change color assignment"
dbarzin e56a39a
fix bug in Word
dbarzin 67652f3
fix color bug in Charts
dbarzin 6700fc4
color rotate in Charts
dbarzin 762b1c7
Replace tabs by spaces
dbarzin 5b830c2
Merge branch 'develop' of https://github.com/troosan/PHPWord into tmp
77de606
Merge branch 'develop' into develop
troosan 79c5552
undo changes not relevant to PR
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <?php | ||
| use PhpOffice\PhpWord\Element\Chart; | ||
| use PhpOffice\PhpWord\Shared\Converter; | ||
|
|
||
| include_once 'Sample_Header.php'; | ||
|
|
||
| // Template processor instance creation | ||
| echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL; | ||
| $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_41_TemplateSetChart.docx'); | ||
|
|
||
| $chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column'); | ||
| $twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar', 'stacked_bar', 'percent_stacked_bar', 'stacked_column', 'percent_stacked_column'); | ||
| $threeSeries = array('bar', 'line'); | ||
|
|
||
| $categories = array('A', 'B', 'C', 'D', 'E'); | ||
| $series1 = array(1, 3, 2, 5, 4); | ||
| $series2 = array(3, 1, 7, 2, 6); | ||
| $series3 = array(8, 3, 2, 5, 4); | ||
|
|
||
| $i=0; | ||
| foreach ($chartTypes as $chartType) { | ||
| $chart = new Chart($chartType, $categories, $series1); | ||
|
|
||
| if (in_array($chartType, $twoSeries)) { | ||
| $chart->addSeries($categories, $series2); | ||
| } | ||
| if (in_array($chartType, $threeSeries)) { | ||
| $chart->addSeries($categories, $series3); | ||
| } | ||
|
|
||
| $chart->getStyle() | ||
| ->setWidth(Converter::inchToEmu(3)) | ||
| ->setHeight(Converter::inchToEmu(3)); | ||
|
|
||
| $templateProcessor->setChart("chart{$i}", $chart); | ||
| $i++; | ||
| } | ||
|
|
||
| echo date('H:i:s'), ' Saving the result document...', EOL; | ||
| $templateProcessor->saveAs('results/Sample_41_TemplateSetChart.docx'); | ||
|
|
||
| echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_41_TemplateSetChart.docx'); | ||
| if (!CLI) { | ||
| include_once 'Sample_Footer.php'; | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.