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

vegas.render.StaticHTMLRenderer.scala Maven / Gradle / Ivy

package vegas.render

import vegas.DSL.{ExtendedUnitSpecBuilder, SpecBuilder}
import vegas.spec.Spec.ExtendedUnitSpec

/**
  * @author Aish Fenton.
  */
case class StaticHTMLRenderer(specJson: String) extends BaseHTMLRenderer {

  def importsHTML(additionalImports: String*) = (JSImports ++ additionalImports).map { s =>
    ""
  }.mkString("\n")

  def headerHTML(additionalImports: String*) =
    s"""
       |
       |  
       |    ${ importsHTML(additionalImports:_*) }
       |  
       |  
    """.stripMargin

  def plotHTML(name: String = this.defaultName) =
    s"""
       | 
| """.stripMargin val footerHTML = """ | | """.stripMargin def pageHTML(name: String = defaultName) = { headerHTML().trim + plotHTML(name) + footerHTML.trim } /** * Typically you'll want to use this method to render your chart. Returns a full page of HTML wrapped in an iFrame * for embedding within existing HTML pages (such as Jupyter). * XXX Also contains an ugly hack to resize iFrame height to fit chart, if anyone knows a better way open to suggestions * @param name The name of the chart to use as an HTML id. Defaults to a UUID. * @return HTML containing iFrame for embedding */ def frameHTML(name: String = defaultName) = { val frameName = "frame-" + name s""" | | """.stripMargin } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy