Skip to content

Commit 3b9d79a

Browse files
authored
Add pdf example, add misc attributes (#16)
1 parent 7bdaa30 commit 3b9d79a

24 files changed

+914
-53
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- Supports various chart types: line charts, bar charts, stacked charts, and mixed charts
1010
- Fully customizable and extendable
1111
- Outputs pure SVG, allowing for:
12-
- Embedding in PDFs (ideal for reports)
12+
- Embedding in PDFs, [view example PDF report](./examples/output/report.pdf)
1313

1414
## Installation
1515

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

2424
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.
2525

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

38+
### Example Usage With mPDF
39+
[📄 View PDF document](./examples/output/report.pdf)
40+
[View source](./examples/pdf/mpdf.php)
3741

3842
### Simple Line Chart
3943
![alt text](./examples/output/line-chart.svg)

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"scripts": {
1818
"examples": [
1919
"cd examples && for example in *.php; do php \"$example\" > \"./output/$(basename \"${example%.php}.svg\")\"; done"
20+
],
21+
"pdf": [
22+
"cd examples/pdf && php mpdf.php >> ../output/report.pdf"
2023
]
2124
},
2225
"require-dev": {

examples/advanced-line-chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
new Point(y: 42.2, x: 1725331334 + 3600 + 3600 + 3600),
111111
],
112112
yAxis: 'celsius',
113-
lineColor: '#FF0000',
113+
color: '#FF0000',
114114
),
115115
new Line(
116116
[

examples/curved-line-chart.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
new Point(y: 25, x: 350),
2424
new Point(y: 35, x: 400),
2525
],
26-
lineColor: 'red',
26+
color: 'red',
2727
curve: 8
2828
),
2929

@@ -38,7 +38,7 @@
3838
new Point(y: 96, x: 350),
3939
new Point(y: 128, x: 400),
4040
],
41-
lineColor: 'blue',
41+
color: 'blue',
4242
curve: 6
4343
),
4444

@@ -54,7 +54,7 @@
5454
new Point(y: 5, x: 350),
5555
new Point(y: 0, x: 400),
5656
],
57-
lineColor: 'green',
57+
color: 'green',
5858
curve: 5
5959
),
6060

@@ -69,7 +69,7 @@
6969
new Point(y: 35, x: 350),
7070
new Point(y: 50, x: 400),
7171
],
72-
lineColor: 'purple',
72+
color: 'purple',
7373
curve: 7
7474
),
7575
]

examples/line-chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
new Point(y: 24, x: 200),
2727
new Point(y: 7, x: 300),
2828
],
29-
lineColor: 'blue'
29+
color: 'blue'
3030
),
3131
]
3232
),

examples/mixed-chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
new Point(y: 14000, x: 200),
6868
new Point(y: 7000, x: 300),
6969
],
70-
lineColor: 'blue'
70+
color: 'blue'
7171
),
7272
]
7373
),

examples/output/advanced-line-chart.svg

Lines changed: 2 additions & 2 deletions
Loading

examples/output/curved-line-chart.svg

Lines changed: 4 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)