简体   繁体   中英

Altair library | Difficulty to save a Chart in .png, getting a .js error

I'm trying to save an Altair Chart in.png howether I get the error below. Could you please help me, I don't where this one come from. I don't understand what it is.

For information I manage to save the graph in.svg, .html and.json format, but not in.png. I already insall altair_saver that returns me Requirement already satisfied.

After following this documentation https://github.com/altair-viz/altair_saver/issues/13#issuecomment-672234434

I am getting this new error:

>>> plot.save('src/modality.png')
Error: CanvasRenderer is missing a valid canvas or context
    at Object.error (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/node_modules/vega-util/build/vega-util.js:39:11)
    at CanvasRenderer.resize (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/node_modules/vega-scenegraph/build/vega-scenegraph.js:3633:28)
    at CanvasRenderer.initialize (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/node_modules/vega-scenegraph/build/vega-scenegraph.js:3190:19)
    at CanvasRenderer.initialize (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/node_modules/vega-scenegraph/build/vega-scenegraph.js:3621:30)
    at initializeRenderer (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/build/vega-view.js:653:8)
    at renderHeadless (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/build/vega-view.js:776:12)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async View.renderToCanvas [as toCanvas] (/export/home/cgilles/.user_conda/miniconda/envs/test_altair/lib/node_modules/vega-cli/node_modules/vega-view/build/vega-view.js:811:15)

Someone knows why? Thank you

This indicates that NodeJS canvas is not properly installed or configured. This github thread mentions possible solutions: https://github.com/altair-viz/altair_saver/issues/13#issuecomment-672234434

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM