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:21:36 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f69dfe319febf4f6382e9bf6cadb70846b36631c
f69dfe31
1 parent
055d1a30
Implement vertical bar chart
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
1 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/chart/bar_chart.dart
pdf/test/widget_chart_test.dart
test/golden/widgets-chart.pdf
pdf/CHANGELOG.md
View file @
f69dfe3
...
...
@@ -5,6 +5,7 @@
-
Add textDirection parameter to PageTheme
-
Fix Bar graph offset
-
Implement vertical bar chart
## 1.11.2
...
...
pdf/lib/widgets/chart/bar_chart.dart
View file @
f69dfe3
...
...
@@ -30,9 +30,11 @@ class BarDataSet extends Dataset {
this
.
surfaceOpacity
=
1
,
this
.
width
=
10
,
this
.
offset
=
0
,
this
.
axis
=
Axis
.
horizontal
,
})
:
drawBorder
=
drawBorder
??
borderColor
!=
null
&&
color
!=
borderColor
,
assert
((
drawBorder
??
borderColor
!=
null
&&
color
!=
borderColor
)
||
drawSurface
),
assert
(
axis
!=
null
),
super
(
legend:
legend
,
color:
color
,
...
...
@@ -51,11 +53,27 @@ class BarDataSet extends Dataset {
final
double
width
;
final
double
offset
;
final
Axis
axis
;
void
_drawSurface
(
Context
context
,
ChartGrid
grid
,
LineChartValue
value
)
{
switch
(
axis
)
{
case
Axis
.
horizontal
:
final
double
y
=
(
grid
is
CartesianGrid
)
?
grid
.
xAxisOffset
:
0
;
final
PdfPoint
p
=
grid
.
toChart
(
value
.
point
);
final
double
x
=
p
.
x
+
offset
-
width
/
2
;
final
double
height
=
p
.
y
-
y
;
context
.
canvas
.
drawRect
(
x
,
y
,
width
,
height
);
break
;
case
Axis
.
vertical
:
final
double
x
=
(
grid
is
CartesianGrid
)
?
grid
.
yAxisOffset
:
0
;
final
PdfPoint
p
=
grid
.
toChart
(
value
.
point
);
final
double
y
=
p
.
y
+
offset
-
width
/
2
;
final
double
height
=
p
.
x
-
x
;
context
.
canvas
.
drawRect
(
p
.
x
+
offset
-
width
/
2
,
y
,
width
,
p
.
y
-
y
);
context
.
canvas
.
drawRect
(
x
,
y
,
height
,
width
);
break
;
}
}
@override
...
...
pdf/test/widget_chart_test.dart
View file @
f69dfe3
...
...
@@ -191,6 +191,28 @@ void main() {
),
));
});
test
(
'Vertical 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
(
axis:
Axis
.
vertical
,
data:
const
<
LineChartValue
>[
LineChartValue
(
1
,
1
),
LineChartValue
(
2
,
3
),
LineChartValue
(
3
,
7
),
],
),
],
),
));
});
});
tearDownAll
(()
{
...
...
test/golden/widgets-chart.pdf
View file @
f69dfe3
No preview for this file type
Please
register
or
login
to post a comment