bokeh / bokeh-scala

Scala bindings for Bokeh plotting library
MIT License
135 stars 16 forks source link

Plot with around 2000 points are very likely to freeze after one or two interaction #27

Open zpfxellose opened 8 years ago

zpfxellose commented 8 years ago

I made some plot with bokeh-scala. It looks very good, but when the plot have nearly 2000 points, the browser is very likely to freeze and crash after i zoom or move the plot. I don't know if it is the same with the python version... Hope we can find out the problem. Really looking to use the library.

mattpap commented 8 years ago

@zpfxellose, 2k is supposed to be very few points to draw for bokeh. Perhaps your're hitting a bug. Which version of bokeh-scala do you use? It would be great if you could show the code you use for plotting.

zpfxellose commented 8 years ago

@mattpap I am using 0.7

libraryDependencies += "io.continuum.bokeh" % "bokeh_2.11" % "0.7"

Here is the code I uesd to prepare the plot object

val xdr = new DataRange1d()
val ydr = new DataRange1d()

val plot = new Plot().x_range(xdr).y_range(ydr).tools(List(new BoxZoomTool, new ResetTool, new CrosshairTool())).width(1024).height(600)

val xaxis = if (xIsDatetime) new DatetimeAxis().plot(plot).location(Location.Below) else new LinearAxis().plot(plot).location(Location.Below)

val yaxis = if (yIslog) new LogAxis().plot(plot).location(Location.Left) else new LinearAxis().plot(plot).location(Location.Left)

val xgrid = new Grid().plot(plot).dimension(0).ticker(xaxis.ticker.value).grid_line_dash(DashPattern.Dashed)
val ygrid = new Grid().plot(plot).dimension(1).ticker(yaxis.ticker.value).grid_line_dash(DashPattern.Dashed)

plot.below <<= (xaxis :: _)
plot.left <<= (yaxis :: _)

plot.renderers := List(xaxis, yaxis, xgrid, ygrid)

Here is the code i used to generate line and circle:

object source extends ColumnDataSource {
      val x = column(l.map(_._1))
      val y = column(l.map(_._2))
}
import source.{x, y}
val circle = new Circle().x(x).y(y).size(5).fill_color(color).line_color(color)
val line = new Line().x(x).y(y).line_color(color)

plot.addGlyph(source, circle)
plot.addGlyph(source, line)

val tooltip = Tooltip("""@x{0.00}, @y{0.00}""")
val hover = new HoverTool().plot(plot).tooltips(tooltip)

plot.tools := plot.tools.value ::: hover :: Nil

also the LogAxis seems not working.