Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
17a271d6
Commit
17a271d6
authored
Aug 12, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abarth cr feedback and example test code
parent
e2ac4385
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
base.dart
packages/playfair/lib/src/base.dart
+6
-6
playfair_test.dart
packages/playfair/test/playfair_test.dart
+30
-3
No files found.
packages/playfair/lib/src/base.dart
View file @
17a271d6
...
...
@@ -10,7 +10,7 @@ class ChartData {
final
double
endX
;
final
double
startY
;
final
double
endY
;
final
List
<
sky
.
Point
>
dataSet
;
final
List
<
Point
>
dataSet
;
}
class
Chart
extends
LeafRenderObjectWrapper
{
...
...
@@ -58,7 +58,7 @@ class ChartPainter {
ChartData
data
;
Point
_convertPointToRectSpace
(
sky
.
Point
point
,
Rect
rect
)
{
Point
_convertPointToRectSpace
(
Point
point
,
Rect
rect
)
{
double
x
=
rect
.
left
+
((
point
.
x
-
data
.
startX
)
/
(
data
.
endX
-
data
.
startX
))
*
rect
.
width
;
double
y
=
rect
.
bottom
-
((
point
.
y
-
data
.
startY
)
/
(
data
.
endY
-
data
.
startY
))
*
rect
.
height
;
return
new
Point
(
x
,
y
);
...
...
@@ -68,13 +68,13 @@ class ChartPainter {
Paint
paint
=
new
Paint
()
..
strokeWidth
=
2.0
..
color
=
const
Color
(
0xFF000000
);
List
<
sky
.
Point
>
dataSet
=
data
.
dataSet
;
List
<
Point
>
dataSet
=
data
.
dataSet
;
assert
(
dataSet
!=
null
);
assert
(
dataSet
.
length
>
0
);
Path
path
=
new
Path
();
Point
start
=
_convertPointToRectSpace
(
data
.
dataSet
[
0
],
rect
);
path
.
moveTo
(
start
.
x
,
start
.
y
);
for
(
sky
.
Point
point
in
data
.
dataSet
)
{
for
(
Point
point
in
data
.
dataSet
)
{
Point
current
=
_convertPointToRectSpace
(
point
,
rect
);
canvas
.
drawCircle
(
current
,
3.0
,
paint
);
path
.
lineTo
(
current
.
x
,
current
.
y
);
...
...
@@ -85,8 +85,8 @@ class ChartPainter {
void
_paintScale
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
Paint
paint
=
new
Paint
()..
color
=
const
Color
(
0xFF000000
);
canvas
.
drawText
(
"
${data.startY}
"
,
rect
.
bottom
Righ
t
,
paint
);
canvas
.
drawText
(
"
${data.endY}
"
,
rect
.
top
Righ
t
,
paint
);
canvas
.
drawText
(
"
${data.startY}
"
,
rect
.
bottom
Lef
t
,
paint
);
canvas
.
drawText
(
"
${data.endY}
"
,
rect
.
top
Lef
t
,
paint
);
}
void
paint
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
...
...
packages/playfair/test/playfair_test.dart
View file @
17a271d6
...
...
@@ -4,10 +4,37 @@
library
playfair
.
test
;
//
import 'package:test/test.dart';
import
'package:test/test.dart'
;
// import 'package:playfair/playfair.dart';
import
'package:playfair/playfair.dart'
;
import
'test_painting_canvas.dart'
;
void
main
(
)
{
// TODO(jackson): Tests
test
(
'test_chart'
,
()
{
ChartData
data
=
new
ChartData
(
startX:
0.0
,
startY:
0.0
,
endX:
10.0
,
endY:
1.0
,
dataSet:
[
const
Point
(
0.0
,
0.0
),
const
Point
(
2.0
,
0.5
),
const
Point
(
5.0
,
0.2
),
const
Point
(
10.0
,
0.9
),
]
);
StringBuffer
buffer
=
new
StringBuffer
();
PaintingCanvas
canvas
=
new
TestPaintingCanvas
(
new
PictureRecorder
(),
const
Size
(
100.0
,
100.0
),
buffer
.
write
);
new
ChartPainter
(
data
).
paint
(
canvas
,
new
Rect
.
fromLTRB
(
0.0
,
0.0
,
100.0
,
100.0
));
// TODO(jackson): Update this to the correct value once Sky packages can test
// See https://github.com/domokit/sky_engine/issues/580
expect
(
buffer
.
toString
(),
equals
(
""
));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment