Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change FlotSerie to enable additional fields such as yaxis #559

Closed
indrajitr opened this issue Jun 21, 2010 · 2 comments
Closed

Change FlotSerie to enable additional fields such as yaxis #559

indrajitr opened this issue Jun 21, 2010 · 2 comments

Comments

@indrajitr
Copy link
Member

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

@github-importer
Copy link

Imported from Assembla: http://www.assembla.com/spaces/liftweb/tickets/559

@fmpwizard
Copy link
Member

Moved to liftmodules/widgets#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants