Currently glyphs and markers are naively implemented like, e.g.:
@model class Line extends Glyph {
object x extends Spatial[Double]
object y extends Spatial[Double]
}
This suggests that the only possible values for x and y are of type Double. However, Strings are perfectly valid for categorical plots. Sometimes also widening is not possible, so Int, Short, etc. will be rejected as well (e.g. when using new typed data sources).
The natural approach is to introduce some type class encapsulating dimensions (say Dim) and define glyphs and markers as follows:
@model class Line[X:Dim, Y:Dim] extends Glyph {
object x extends Spatial[X]
object y extends Spatial[Y]
}
(for simplicity I didn't write full signatures including Default and Writes type classes). This implementation has the disadvantage that new Line().x(0).y(1) wouldn't be possible anymore, because Scala won't be able to infer X and Y type parameters (due to local type inference). One would have to write new Line[Double, Double]().x(0).y(1) which is pretty verbose and annoying. The only way to infer those parameters is to pass values for x and y in the constructor, i.e. new Line(0, 1). This will require us to add a series of constructors to each glyph (note that constructors aren't inheritable).
I consider the current situation a bug, because the only way to create a categorical plot (among other issues) is to use untyped data sources, which renders using Scala pretty useless.
Currently glyphs and markers are naively implemented like, e.g.:
This suggests that the only possible values for
x
andy
are of typeDouble
. However,String
s are perfectly valid for categorical plots. Sometimes also widening is not possible, soInt
,Short
, etc. will be rejected as well (e.g. when using new typed data sources).The natural approach is to introduce some type class encapsulating dimensions (say
Dim
) and define glyphs and markers as follows:(for simplicity I didn't write full signatures including
Default
andWrites
type classes). This implementation has the disadvantage thatnew Line().x(0).y(1)
wouldn't be possible anymore, because Scala won't be able to inferX
andY
type parameters (due to local type inference). One would have to writenew Line[Double, Double]().x(0).y(1)
which is pretty verbose and annoying. The only way to infer those parameters is to pass values forx
andy
in the constructor, i.e.new Line(0, 1)
. This will require us to add a series of constructors to each glyph (note that constructors aren't inheritable).I consider the current situation a bug, because the only way to create a categorical plot (among other issues) is to use untyped data sources, which renders using Scala pretty useless.