Plotly express and dash with facet_col

Hi,

Earlier i was using Plotly python and discovered plotly_express recently. I liked it very much and decided to switch. This is a beautiful tool.

I am trying to create a scatter plot using plotly_express.
When executed within jupyter notebook the plot is perfect and beautiful.

import plotly_express as px

px.scatter(edf.tail(5), x=‘timestamp’, y=‘watt’, size=‘current’, facet_col=‘channel’, color=‘temperature’)

When this same thing is served via Dash, there is error on the JavaScript “Error unrecognized date NaN”. Chart with no points are displayed and side color bar indicator is missing.

If facet_col is removed, error goes away and chart without column facet is displayed, still with missing color bar indicator on side.

There seems some interplay between date parsing and facet handling.

Sample data to reproduce the problem
|deviceId|channel|timestamp|voltage|current|watt|temperature|
|40|sen-pdu-i-606|2|2019-05-27T00:06:39.565062|9.087|30.824|280.097688|-5.513|
|43|sen-pdu-i-856|5|2019-05-26T08:13:28.390696|0.689|29.941|20.629349|3.968|
|35|sen-pdu-i-1|8|2019-05-24T16:17:41|46.035|2.404|110.668140|46.498|
|328|sen-pdu-i-517|2|2019-05-26T11:58:37.898283|5.599|30.552|171.060648|-0.715|
|24|sen-pdu-i-479|2|2019-05-27T06:40:48.657658|45.578|3.237|147.535986|-1.227|
|500|sen-pdu-i-288|6|2019-05-27T02:22:01.128498|23.740|29.320|696.056800|1.268|
|107|sen-pdu-i-8|6|2019-05-25T06:47:55.410920|-0.727|31.212|22.691124|10.250|

Version information:
plotly 3.10.0 py_0 plotly
plotly_express 0.3.1 py_0 plotly

On JavaScript console
Plotly.version “1.47.0”

Hi @readall, welcome to the forums! And glad to hear you’re enjoying plotly express!

My first guess is that the problem here is a mismatch in the plotly.js version between what your version of Plotly express is expecting (1.48.0) and what your version of Dash provides (maybe < 1.48). Dash 1.0.0 came out a couple of days ago, could you try upgrading that if you’re not on 1.0.0 already?

-Jon

Hi,

Sorry for delayed response.
I moved to dash==1.0.0 and still face the same issue.

As the date parsing fails in combination with facet_col option, the dates displayed are year 2000 which seems to come from some default values in JS files supplied by plotly.

Regards,

Hi,

Finally something has made it work.
I tried these few things and now it is working fine.

  1. Multiple times i removed and installed plotly 3.10.0 and 4.0.0a4.
  2. Finally reverting to plotly 3.10 as plotly_express does not like 4.0.xx
  3. I have changed dash code to explictly use 1.48.0 js.
  4. As default behavior dash continues to push 1.47.x which has this bug.

We can close this issue now.

1 Like