Cannot convert undefined or null to object
Opened this issue · 7 comments
Hi,
I get the error "Cannot convert undefined or null to object" in the console with the simple following code:
package app
import org.scalajs.dom._
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import plotly._
import plotly.element._
object Application extends js.JSApp {
@JSExport
override def main(): Unit = {
val x = 0.0 to 10.0 by 0.1
val y1 = x.map(d => 2.0 * d + util.Random.nextGaussian())
val y2 = x.map(math.exp)
val data = Seq(
Scatter(
x, y1, name = "Approx twice"
),
Scatter(
x, y2, name = "Exp"
)
)
println("hello world")
window.onload = { (e: Event) => {
println("load")
Plotly.plot("div-plotly", data)
}
}
}
}
The error stack is:
plotly-1.2.0.min.js:32 Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at p (plotly-1.2.0.min.js:32)
at f (plotly-1.2.0.min.js:32)
at Object.P.plot (plotly-1.2.0.min.js:32)
at $c_Lplotly_Plotly$.plot__T__sc_Seq__V (Plotly.scala:33)
at Hello.scala:27
Do you know this error?
@francoiscabrol I have the same problem, were you able to fix it?
Hello?
I have cloned the project and built it and it fails in exactly the same way. Is this still being maintained? It looks really good, it would be a pity if it has been abandoned.
Rendering demos Line Charts
plotly-demo-fastopt.js:78719 Rendering demo basic-line-plot
plotly-demo-jsdeps.js:883 Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at a (plotly-demo-jsdeps.js:883)
at Object.r.cleanData (plotly-demo-jsdeps.js:884)
at Object.y.plot (plotly-demo-jsdeps.js:884)
at $c_Lplotly_Plotly$.plot__T__sc_Seq__V (plotly-demo-fastopt.js:6507)
at plotly-demo-fastopt.js:6769
at $c_sjsr_AnonFunction1.apply__O__O (plotly-demo-fastopt.js:36554)
at $c_sci_$colon$colon.$c_sci_List.foreach__F1__V (plotly-demo-fastopt.js:90711)
at plotly-demo-fastopt.js:6718
at $c_sjsr_AnonFunction1.apply__O__O (plotly-demo-fastopt.js:36554)
sorry I don't remember but I think I didn't find any way to get it work with this code.
The demo code is passing JSON to plotly that looks like:
[
{
"type" : "scatter",
"x" : [
1,
2,
3,
4
],
"y" : [
10,
15,
13,
17
],
"text" : null,
"mode" : null,
"marker" : null,
"line" : null,
"textposition" : null,
"textfont" : null,
"name" : null,
"connectgaps" : null,
"xaxis" : null,
"yaxis" : null,
"fill" : null,
"error_x" : null,
"error_y" : null,
"showlegend" : null
},
{
"type" : "scatter",
"x" : [
1,
2,
3,
4
],
"y" : [
16,
5,
11,
9
],
"text" : null,
"mode" : null,
"marker" : null,
"line" : null,
"textposition" : null,
"textfont" : null,
"name" : null,
"connectgaps" : null,
"xaxis" : null,
"yaxis" : null,
"fill" : null,
"error_x" : null,
"error_y" : null,
"showlegend" : null
}
]
plotly is choking on the marker
and line
fields. These are complex fields, rather than just strings, and if they are passed as {}
rather than null
plotly is happy. Unfortunately, my scala is not good enough to work how this JSON is being generated, perhaps the circe API has changed.
@alexarchambault @francoiscabrol This seems to have been broken since v0.1.0. I've generated a PR that fixes the JS renderer but the other renderers might be broken as well. It seems that this project is abandoned which is a pity because it seems to be pretty good. For other wanting to use it, clone my fork then sbt publishLocal and refer to version in 0.3.3-SNAPSHOT in your projects.
@evan-wehi The project isn't abandonned per se, I'm just focusing more on some other projects right now. I'll have a look at your PR.
@alexarchambault Great that you are now looking at! This is not an edge case, the js renderer is completely broken, I would guess because of a change in circe. My PR is probably not the right way to do it but I didn't understand the circe renderer API. As I mentioned, your API is great, I was able get my use case running in 1/3 code that D3 required and I got all the plotly niceness as well.