HanSolo/charts

renderToImage(w,h)

maxandersen opened this issue · 6 comments

newly added renderToImage(file,w,h) is nice but how about a renderToImage(w,h) ?

this is so the chart can just be shown in interactive shells/jupyter notebooks etc.

You mean returning the png?

Yes. As Image or whatever intermediate representation is available.

Any specific preferences to make it as easy as possible in shell?

Most java jupyter kernels will know how to render a BufferedImage to rendered bitmap this being able to get that with least amount of code is nice.

I.e. chart.render() with some defaults or chart.render(h,w)

For kernels that has chart knowledge they will look at the type and do instance of checks to find a suitable renderer and then it doesn't really matter how complicated it is as it will all be hidden from the user as they will just return chart.

Performance can matter too though - so I don't know what Javafx has internally - whether Image or some other intermediate representation. If it's not Image/BuffeedImage I would just return the cheapest one to get so not doing too expensive operations on every call.

BufferedImage is available via JavaFX/Swing bridge and would be easy to implement, will do that on my way back home today 👍🏻.

Implemented the method in commit hash e18cdbb