Skip to content

Commit

Permalink
Add pdf example, add misc attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
maantje committed Jan 22, 2025
1 parent 7bdaa30 commit 19037b6
Show file tree
Hide file tree
Showing 24 changed files with 914 additions and 53 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- Supports various chart types: line charts, bar charts, stacked charts, and mixed charts
- Fully customizable and extendable
- Outputs pure SVG, allowing for:
- Embedding in PDFs (ideal for reports)
- Embedding in PDFs, [view example PDF report](./examples/output/report.pdf)

## Installation

Expand All @@ -23,6 +23,7 @@ composer require maantje/charts

Below are some examples of the types of charts you can create using this library. Click on the links to view the source code for each example.

- [Example usage with mPDF](#example-mpdf)
- [Simple Line Chart](#simple-line-chart)
- [Curved Line Chart](#curved-line-chart)
- [Step Line Chart](#step-line-chart)
Expand All @@ -34,6 +35,9 @@ Below are some examples of the types of charts you can create using this library
- [Mixed Chart](#mixed-chart)
- [Pie Chart](#pie-chart)

### Example mPDF
[View PDF](./examples/output/report.pdf)
[View source](./examples/pdf/mpdf.php)

### Simple Line Chart
![alt text](./examples/output/line-chart.svg)
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"scripts": {
"examples": [
"cd examples && for example in *.php; do php \"$example\" > \"./output/$(basename \"${example%.php}.svg\")\"; done"
],
"pdf": [
"cd examples/pdf && php mpdf.php >> ../output/report.pdf"
]
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced-line-chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
new Point(y: 42.2, x: 1725331334 + 3600 + 3600 + 3600),
],
yAxis: 'celsius',
lineColor: '#FF0000',
color: '#FF0000',
),
new Line(
[
Expand Down
8 changes: 4 additions & 4 deletions examples/curved-line-chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
new Point(y: 25, x: 350),
new Point(y: 35, x: 400),
],
lineColor: 'red',
color: 'red',
curve: 8
),

Expand All @@ -38,7 +38,7 @@
new Point(y: 96, x: 350),
new Point(y: 128, x: 400),
],
lineColor: 'blue',
color: 'blue',
curve: 6
),

Expand All @@ -54,7 +54,7 @@
new Point(y: 5, x: 350),
new Point(y: 0, x: 400),
],
lineColor: 'green',
color: 'green',
curve: 5
),

Expand All @@ -69,7 +69,7 @@
new Point(y: 35, x: 350),
new Point(y: 50, x: 400),
],
lineColor: 'purple',
color: 'purple',
curve: 7
),
]
Expand Down
2 changes: 1 addition & 1 deletion examples/line-chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
new Point(y: 24, x: 200),
new Point(y: 7, x: 300),
],
lineColor: 'blue'
color: 'blue'
),
]
),
Expand Down
2 changes: 1 addition & 1 deletion examples/mixed-chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
new Point(y: 14000, x: 200),
new Point(y: 7000, x: 300),
],
lineColor: 'blue'
color: 'blue'
),
]
),
Expand Down
4 changes: 2 additions & 2 deletions examples/output/advanced-line-chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions examples/output/curved-line-chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 19037b6

Please sign in to comment.