All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.liftmodules.widgets.sparklines.Sparklines.scala Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2007-2010 WorldWide Conferencing, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.liftmodules {
package widgets {
package sparklines {

import _root_.scala.xml._
import _root_.net.liftweb.util.Helpers._
import _root_.net.liftweb.common.{Box, Full, Empty}
import _root_.net.liftweb.http.S._
import _root_.net.liftweb.http.LiftRules
import _root_.net.liftweb.http.{LiftResponse, JsonResponse}
import _root_.net.liftweb.http.js._
import _root_.net.liftweb.http.js.jquery._
import JsCmds._
import JE._
import JqJsCmds._
import JqJE._

/**
 * Facilitates Sparklines from http://www.willarson.com/code/sparklines/sparklines.html
 * integration into Lift applications.
 *
 */
object Sparklines {

  /**
   * Renders a sparkline graph when the page loads
   *
   * @param id - the id of the canvas HTML element
   * @param graphStyle - the style of the chart (LINE, BAR)
   * @param data - the amplitudes to be rendered
   * @param opts - Sparklines options. See http://www.willarson.com/code/sparklines/sparklines.html
   */
  def onLoad(id: String, graphStyle: SparklineStyle.Value, data: JsArray, opts: JsObj) : NodeSeq = {