Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
Showing results for 
Search instead for 
Did you mean: 

Inconsistent behavior when displaying chart in notebook



I'm trying to create some 3D charts. With the same code and same cluster, sometimes it can show, sometimes it cannot. Previously it cannot display, but last week I opened a notebook with failed run and found the result can be shown by itself (as the HTML is in the cell result). Now it doesn't work again. It just shows "script error" without displaying the chart. The script error should be some JS error. Any idea why? Thanks.

You can repro it by:

%pip install pyecharts
from pyecharts.globals import CurrentConfig, NotebookType
CurrentConfig.NOTEBOOK_TYPE = NotebookType.NTERACT

import random

from pyecharts import options as opts
from pyecharts.charts import Bar3D
from pyecharts.faker import Faker

data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
c = (
        [[d[1], d[0], d[2]] for d in data],
        xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
        yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),



Community Manager
Community Manager

Hi @BradCreating 3D charts can indeed be tricky, especially when dealing with JavaScript errors.

Let’s explore some potential reasons why you might encounter a “script error” when rendering 3D charts using pyecharts.

  1. Browser Compatibility:

    • Ensure that the browser you’re using to view the charts supports WebGL, which is essential for rendering 3D graphics.
    • Some browsers may have stricter security settings that prevent certain JavaScript features from executing. Try using a different browser or adjusting the security settings.
  2. Dependencies and Versions:

    • Verify that you have the correct versions of pyecharts, echarts, and other related libraries installed.
    • Sometimes, conflicts between different versions of JavaScript libraries can cause issues. Make sure all dependencies are compatible.
  3. Notebook Environment:

    • The behavior you described—where the chart sometimes displays and sometimes doesn’t—could be related to the notebook environment.
    • Check if there are any differences in the notebook state (e.g., kernel restarts, package updates) between successful and unsuccessful runs.
    • Ensure that the notebook kernel is consistent and that no conflicting processes interfere with the rendering.
  4. Caching and Cell Execution:

    • Notebooks often cache cell outputs. If you previously encountered an error and then re-executed the cell, the cached output might still be displayed.
    • Try clearing the cell output cache or restarting the notebook kernel to ensure a fresh execution.
  5. JavaScript Errors:

    • The “script error” message suggests a JavaScript issue. Inspect the browser console (usually accessible via F12 or right-clicking and selecting “Inspect”) to view detailed error messages.
    • Look for any specific error codes or descriptions related to echarts or pyecharts.
  6. Debugging Steps:

    • Temporarily remove parts of your code to isolate the issue. For example, comment out the c.render_notebook() line and see if the chart displays without it.
    • Gradually reintroduce components (such as the visual map or title options) to identify which part triggers the error.

Remember that 3D charts involve complex rendering, and small issues can lead to unexpected behavior. If you continue to face difficulties, consider reaching out to the pyecharts community or checking t...1.

Lastly, keep experimenting and don’t hesitate to explore alternative charting libraries if needed. Happy charting! 📊🌟



I don't understand why sometimes it works sometimes not. The code, cluster, browsers are the same. I asked in pyecharts community too. Unfortunately they said they don't have databricks notebook and cannot repro. This is not an issue in normal Juptyer notebook.


Is it possible somehow the iframe used in the cell removed sandboxing and caused this? 


Also, with same code, same browser, different workspaces, one works, other one not. 

In the notebook with "script error", if I "Export cell" and get its iframe html and use displayHTML to display it, it works, so this means the JS and HTML inside is ok, but seems something makes on JS fail when running in the notebook directly. 

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!