C2DH / journal-of-digital-history

frontend app for our Digital Journal
GNU General Public License v3.0
19 stars 4 forks source link

Plotly visualisation not displayed -Mime type application/vnd.plotly.v1+json #541

Closed eliselavy closed 7 months ago

eliselavy commented 1 year ago

Plotly visualisation is supported since here: https://github.com/C2DH/journal-of-digital-history/issues/481

No problem with this example: https://github.com/C2DH/jdh-notebook/blob/master/examples/plotly.ipynb https://journalofdigitalhistory.org/en/notebook-viewer/JTJGcHJveHktZ2l0aHVidXNlcmNvbnRlbnQlMkZDMkRIJTJGamRoLW5vdGVib29rJTJGbWFzdGVyJTJGZXhhbXBsZXMlMkZwbG90bHkuaXB5bmI=

But in theses articles : visualisation not displayed

http://10.240.4.179/en/article/aADj3Ljjqti2?idx=41&layer=narrative&lh=643&pidx=41&pl=hermeneutics&y=70#anchor-figure-3 Github repo: https://github.com/jdh-observer/aADj3Ljjqti2/blob/main/articleMaine.ipynb

/en/article/plotly.js:1 
Uncaught SyntaxError: Unexpected token '<'

VM123:2 
Uncaught TypeError: Cannot read properties of undefined (reading 'newPlot')
    at <anonymous>:2:248
    at Object.execCb (require.min.js:29:311)
    at $.check (require.min.js:18:423)
    at $.<anonymous> (require.min.js:23:9)
    at require.min.js:8:102
    at require.min.js:23:369
    at v (require.min.js:7:173)
    at $.emit (require.min.js:23:340)
    at $.check (require.min.js:19:403)
    at $.enable (require.min.js:23:238)
eliselavy commented 1 year ago

Before:

  "outputs": [
    {
     "data": {
      "text/html": [
       "        <script type=\"text/javascript\">\n",
       "        window.PlotlyConfig = {MathJaxConfig: 'local'};\n",
       "        if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n",
       "        if (typeof require !== 'undefined') {\n",
       "        require.undef(\"plotly\");\n",
       "        define('plotly', function(require, exports, module) {\n",
       "            /**\n",
       "* plotly.js v1.58.4\n",
       "* Copyright 2012-2020, Plotly, Inc.\n",
       "* All rights reserved.\n",
       "* Licensed under the MIT license\n",
       "*/\n",

Now: plotly==5.9.0

Custom mimetypes used for display: application/vnd.plotly.v1+json - Plotly JSON Schema https://plotly.com/chart-studio-help/json-chart-schema/

 "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
eliselavy commented 1 year ago

@eliselavy investigate JupyterLab / Jupyter notebook

eliselavy commented 1 year ago

No difference of output between Lab and notebook. The notebook committed didn't contained: " require.undef(\"plotly\");\n", " define('plotly', function(require, exports, module) {\n", " /*\n", " plotly.js v2.18.0\n",

Committed not trusted? Need to check if related to nbconvert

eliselavy commented 1 year ago

Add in the technical review check for the external library: https://github.com/C2DH/journal-of-digital-history-backend/issues/172#issuecomment-1564170838