Hi, Will String interpolation helps? http://docs.scala-lang.org/overviews/core/string-interpolation.html
And i think your approach is very valid. Best, moon On Wed, Jul 15, 2015 at 8:31 AM Wood, Dean Jr (GE Oil & Gas) < dean1.w...@ge.com> wrote: > Hi, > > I’m having some issues with getting a html file which plots a line graph > using D3 to plot using some scala variables. My html is rubbish so it might > be something straightforward. > > I have a simple package built with sbt containing the following: > package zep_plot > > import com.google.common.io.Files > > > package object zepplot{ > def plotter():Unit= { > val x1=Vector(0, 1, 2, 3, 4) > val y1=Vector(0, 1, 2, 3, 4) > val x2=Vector(0, 1, 2, 3, 4) > val y2=Vector(0, 1, 4, 9, 16) > val text1 = com.google.common.io.Files.toString(new > java.io.File("/Users/deanwood/Documents/scala/plot/src/main/scala/file1.html"), > com.google.common.base.Charsets.UTF_8) > val text2 = com.google.common.io.Files.toString(new > java.io.File("/Users/deanwood/Documents/scala/plot/src/main/scala/file2.html"), > com.google.common.base.Charsets.UTF_8) > println("%html"+ text1 + x1(0) +","+x1(1) +","+x1(2) +","+ x1(3) > +","+ x1(4) + "], y: ["+ y1(0) +","+y1(1) +","+y1(2) +","+ y1(3) +","+ > y1(4) + "] }, { label: \"Data Set 2\", x: ["+ x2(0) +","+x2(1) +","+x2(2) > +","+ x2(3) +","+ x2(4) + "], y: ["+ y2(0) +","+y2(1) +","+y2(2) +","+ > y2(3) +","+ y2(4) + text2) > } > } > > > I’ve broken the html file in two and tried to replace the part where I > inserted the data in the javascript with variables defined in scala on > zeppelin. I’ve attached the html below. > > The ultimate aim is to be able to provide some standard plots which will > dynamically take RDDs defined in zeppelin and plot them with enhanced plots > not currently provided by zeppelin. The aim is have an interim fix until > the mooted summer of code project hopefully enhances zeppelins plotting > capability. So, to make this interim solution work, how do I get scala > variables plotted in the javascript of a html file. I’d like the info on > how to use the variables as I want to do the same thing for a heat map and > a couple of other standard plots required for my project. I’ve attached the > example html files used in the scala package below. > > Thanks for any help. > > Dean > >