added support for legend image; fixed date glitch in PHP