Empty plot when enabling json data_transformer
See original GitHub issueBelow is my code, I get an empty plot. I am using JupyterLab
import altair as alt
import pandas as pd
alt.data_transformers.enable("json")
size = 10
df = pd.DataFrame(
{"key": np.random.choice(list("ABC"), size), "val": np.random.rand(size)}
)
alt.Chart(df).mark_point().encode(y="key:N")
My versions are: altair: 3.2.0 jupyterlab: 1.0.4
I tried looking through the page response when inspecting the network activity on Chrome, I am seeing a forbidden error.
<div class="error">
<h1>403 : Forbidden</h1>
<p>The error was:</p>
<div class="traceback-wrapper">
<pre class="traceback"> is not a file</pre>
</div>
</div>
Below is the to_dict() from the altair object.
{'config': {'view': {'width': 400, 'height': 300}, 'mark': {'tooltip': None}},
'data': {'url': 'altair-data-e47f5911f8d2367541736476ae610606.json',
'format': {'type': 'json'}},
'mark': 'point',
'encoding': {'y': {'type': 'nominal', 'field': 'key'}},
'$schema': 'https://vega.github.io/schema/vega-lite/v3.4.0.json'}
and the datafile exists in the local path
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Empty downloaded chart when alt.data_transformers.enable ...
The JSON data transformer causes the chart to not be self-contained, and this is by design. The output will work as long as...
Read more >Altair plot is empty when alt.data_transformers.enable('json ...
It appears that the notebook then fails to read data from the json file and empty plot is displayed in the output cell....
Read more >Using JSON data transformer for large dataset - Google Groups
I am plotting a large dataset, so I am trying to use the JSON data transformer: alt.data_transformers.enable('json').
Read more >Data is getting embedded via a local json file - altair
alt.data_transformers.enable('json'). If you want to restore the default data transformer which embeds data directly into the chart, run
Read more >Configuring the JSON data transforms settings column on the ...
Pega Platform displays the Settings tab on the data transform rule form for the JSON data model format. Use the Settings tab to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This looks like the same issue as reported in https://github.com/jupyterlab/jupyterlab/issues/7017, which has been fixed as of JupyterLab version 1.1.0. Based on this, I believe that updating Jupyterlab will fix your issue.
I also have the same behavior as the above two posts, using versions:
While passing a pandas DataFrame works, using any of the two transformers does not. Neither does manually saving to CSV and refering to that filename.
UPDATE: To expand on the experiment with manual CSV saving, here are a couple of URLs I tried, some of which worked. In this case, I did not enable any
data_transformer
and saved the file tofoobar.csv
next to the notebook files, which is also from where I started JupyterLab.Here, the latter two are the URLs which I get whith right-click on the CSV file and then either “Copy download link” or “Copy shareable link”.
To conclude, the URL that works is the “download link” with the query parameter removed.