Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2020-11-19 08:11:17 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
055d1a30326f1c5f32969ef302412d0cd4f23fdb
055d1a30
1 parent
84d5cc59
Fix Bar graph offset
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/chart/bar_chart.dart
pdf/test/widget_chart_test.dart
pdf/CHANGELOG.md
View file @
055d1a3
...
...
@@ -4,6 +4,7 @@
## 1.12.0
-
Add textDirection parameter to PageTheme
-
Fix Bar graph offset
## 1.11.2
...
...
pdf/lib/widgets/chart/bar_chart.dart
View file @
055d1a3
...
...
@@ -25,12 +25,14 @@ class BarDataSet extends Dataset {
this
.
borderColor
,
this
.
borderWidth
=
1.5
,
PdfColor
color
=
PdfColors
.
blue
,
this
.
drawBorder
=
true
,
bool
drawBorder
,
this
.
drawSurface
=
true
,
this
.
surfaceOpacity
=
1
,
this
.
width
=
10
,
this
.
offset
=
0
,
})
:
assert
(
drawBorder
||
drawSurface
),
})
:
drawBorder
=
drawBorder
??
borderColor
!=
null
&&
color
!=
borderColor
,
assert
((
drawBorder
??
borderColor
!=
null
&&
color
!=
borderColor
)
||
drawSurface
),
super
(
legend:
legend
,
color:
color
,
...
...
@@ -53,7 +55,7 @@ class BarDataSet extends Dataset {
final
double
y
=
(
grid
is
CartesianGrid
)
?
grid
.
xAxisOffset
:
0
;
final
PdfPoint
p
=
grid
.
toChart
(
value
.
point
);
context
.
canvas
.
drawRect
(
p
.
x
+
offset
-
width
/
2
,
y
,
width
,
p
.
y
);
context
.
canvas
.
drawRect
(
p
.
x
+
offset
-
width
/
2
,
y
,
width
,
p
.
y
-
y
);
}
@override
...
...
pdf/test/widget_chart_test.dart
View file @
055d1a3
...
...
@@ -170,6 +170,29 @@ void main() {
});
});
group
(
'BarChart test'
,
()
{
test
(
'Default BarChart'
,
()
{
pdf
.
addPage
(
Page
(
pageFormat:
PdfPageFormat
.
standard
.
landscape
,
build:
(
Context
context
)
=>
Chart
(
grid:
CartesianGrid
(
xAxis:
FixedAxis
<
int
>(<
int
>[
0
,
1
,
2
,
3
,
4
,
5
,
6
]),
yAxis:
FixedAxis
<
int
>(<
int
>[
0
,
3
,
6
,
9
],
divisions:
true
),
),
datasets:
<
Dataset
>[
BarDataSet
(
data:
const
<
LineChartValue
>[
LineChartValue
(
1
,
1
),
LineChartValue
(
2
,
3
),
LineChartValue
(
3
,
7
),
],
),
],
),
));
});
});
tearDownAll
(()
{
final
File
file
=
File
(
'widgets-chart.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
...
...
Please
register
or
login
to post a comment