New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert undefined or null to object #13

Open
francoiscabrol opened this Issue Apr 24, 2017 · 7 comments

Comments

3 participants
@francoiscabrol

francoiscabrol commented Apr 24, 2017

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?

@evan-wehi

This comment has been minimized.

Show comment
Hide comment
@evan-wehi

evan-wehi Aug 28, 2017

@francoiscabrol I have the same problem, were you able to fix it?

evan-wehi commented Aug 28, 2017

@francoiscabrol I have the same problem, were you able to fix it?

@evan-wehi

This comment has been minimized.

Show comment
Hide comment
@evan-wehi

evan-wehi Aug 29, 2017

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)

evan-wehi commented Aug 29, 2017

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)
@francoiscabrol

This comment has been minimized.

Show comment
Hide comment
@francoiscabrol

francoiscabrol Aug 29, 2017

sorry I don't remember but I think I didn't find any way to get it work with this code.

francoiscabrol commented Aug 29, 2017

sorry I don't remember but I think I didn't find any way to get it work with this code.

@evan-wehi

This comment has been minimized.

Show comment
Hide comment
@evan-wehi

evan-wehi Sep 4, 2017

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.

evan-wehi commented Sep 4, 2017

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.

@evan-wehi

This comment has been minimized.

Show comment
Hide comment
@evan-wehi

evan-wehi Oct 22, 2017

@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 commented Oct 22, 2017

@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.

@alexarchambault

This comment has been minimized.

Show comment
Hide comment
@alexarchambault

alexarchambault Oct 23, 2017

Owner

@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.

Owner

alexarchambault commented Oct 23, 2017

@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.

@evan-wehi

This comment has been minimized.

Show comment
Hide comment
@evan-wehi

evan-wehi Oct 23, 2017

@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.

evan-wehi commented Oct 23, 2017

@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.

alexarchambault added a commit that referenced this issue Oct 24, 2017

Fix issue #13 (#16)
Fixes issue: "Cannot convert undefined or null to object #13"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment