Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit 90489f8

Browse files
committed
Fix #10: Additional implicits for several svg functions
1 parent 4eedaab commit 90489f8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/scala/org/singlespaced/d3js/Ops.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ object Ops {
4444
@inline implicit def fromFunction1To3[Datum, M](value: Datum => M): js.Function3[Datum, Int, Int, M] =
4545
(d: Datum, i: Int, x: Int) => value.apply(d)
4646

47+
@inline implicit def fromFunction1To2[Datum, M](value: Datum => M): js.Function2[Datum, Int, M] =
48+
(d: Datum, i: Int) => value.apply(d)
49+
4750
@inline implicit def fromFunction2To3[Datum, M](value: (Datum, Int) => M): js.Function3[Datum, Int, Int, M] =
4851
(d: Datum, i: Int, x: Int) => value.apply(d, i)
4952

src/test/scala/org/singlespaced/d3js/SvgLineTest.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ object SvgLineTest extends TestSuite {
3232
assert( actual.length == 1)
3333
assert( actual.item(0).asInstanceOf[dom.Element].getAttribute("d") =="M1,1L4,4")
3434
}
35+
'd3_line_function1 {
36+
//arrange
37+
case class TestDatum(v:Int)
38+
val data=js.Array[TestDatum](TestDatum(1),TestDatum(4))
39+
val testee = d3.svg.line[TestDatum]
40+
//act
41+
val result=testee
42+
.x((d:TestDatum) => d.v.toDouble )
43+
.y((d:TestDatum) => d.v.toDouble )
44+
}
3545

3646

3747
}

0 commit comments

Comments
 (0)