HanSolo / charts

A JavaFX library that contains different kind of charts
Apache License 2.0
657 stars 78 forks source link

renderToImage(w,h) #118

Open maxandersen opened 9 months ago

maxandersen commented 9 months ago

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.

HanSolo commented 9 months ago

You mean returning the png?

maxandersen commented 9 months ago

Yes. As Image or whatever intermediate representation is available.

HanSolo commented 9 months ago

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

maxandersen commented 9 months ago

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.

HanSolo commented 9 months ago

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

HanSolo commented 9 months ago

Implemented the method in commit hash e18cdbb455a65f678629474c1704a0173bff8bf0