-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
FlotSerie does not provide for putting data on second y axis.
Proposed FlotSerie:
trait FlotSerie extends BaseFlotOptions
{
def data: List[(Double, Double)] = Nil
def label: Box[String] = Empty
def lines: Box[FlotLinesOptions] = Empty
def points: Box[FlotPointsOptions] = Empty
def bars: Box[FlotBarsOptions] = Empty
def color: Box[Either[String, Int]] = Empty
def shadowSize: Box[Int] = Empty
def buildOptions = {
List(label.map(v => ("label", Str(v))),
lines.map(v => ("lines", v.asJsObj)),
points.map(v => ("points", v.asJsObj)),
bars.map(v => ("bars", v.asJsObj)),
color.map {
case Left(c) => ("color", Str(c))
case Right(c) => ("color", Num(c))
},
shadowSize.map(s => ("shadowSize", Num(s)))
)
}
}
Then using it in Flot:
def renderOneSerie(data: FlotSerie, idPlaceholder: String, idSerie: Int): JsObj = {
val info: List[Box[(String, JsExp)]] =
Full(("data", JsVar("data_"+idPlaceholder + "_" + idSerie))) ::
data.buildOptions
JsObj(info.flatten(_.toList) :_*)
}
Enables user code such as:
series = new FlotSerie () {
override val label = Full(theDs.split("@")(0))
override val data = theDataMap(theDs)
val yaxis = Full (2)
override def buildOptions = {
yaxis.map( v => ("yaxis", Num(v))) ::
super.buildOptions
}
} :: series
Migrated from lift/framework#559