There are two parts to the request:
I need a general-purpose wrapper that can target a D3 chart and cleanly and simply save the chart to a PNG or JPEG (user option). The emphasis should be on simplicity, and the fewest needs for external libraries, canvas, or other hacks. The point here is to get something I can use in production but that also helps me understand how it's done.
The chart should be saved in its current state. In other words, if the user has clicked a chart button that changes the colors, scales, or applies other transformations, those visual changes should be reflected in the saved image. If there is a mouseover key tip on the chart, it should also be captured. In other words, the entire SVG space should be captured to an image file of the same dimensions.
Because there is no user interface, the web folder/filename should be taken as a parameter to the function so that I can know where the images are created.
The goal in this context is that I would like to build a D3 chart, then have a cron job create an image file from the chart every 15 minutes when the MySQL data is updated.
FOR EXTRA CREDIT
It would be really call if your function would let me pass a third parameter - a scale size - that would capture an image from the D3 chart that is scaled up/down for better/less size and resolution. I may have a D3 chart that is 400x200 on the screen, it would be really neat if I could tell your function to produce an image file that is 800x400 for example.