The script produced by CanvasGraphics2D uses "setTransform". This seems to make it impossible to use the "ctx.scale()" method to easily dynamically scale a graphic. If you try this, only a some of the graphic is scaled, but after the absolute "setTranform()" method call , "scale()" gets reset.
In general it would be nice if a script could be produced that could be easily manipulated by some other externally provided java script.
(yes, I did get my employer to buy the docs!)
CanvasGraphics2D setTransform
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: CanvasGraphics2D setTransform
Can you clarify exactly how you want to apply the scaling? We are using a test suite to ensure that the transformations on our Graphics2D implementations are giving the same results as the reference implementation, so I'd like to understand whether we have a bug for a particular combination of transforms or if the scaling you want to perform on the CanvasGraphics2D would break the behavior expected for Graphics2D.
Earlier I considered having the script generated by CanvasGraphics2D use width ('w') and height ('h') variables and do all drawing relative to these values - this would at least give the possibility to resize the chart nicely. I didn't do that yet, since if you need to be able to scale the chart then the SVGGraphics2D class is probably a better solution.
Earlier I considered having the script generated by CanvasGraphics2D use width ('w') and height ('h') variables and do all drawing relative to these values - this would at least give the possibility to resize the chart nicely. I didn't do that yet, since if you need to be able to scale the chart then the SVGGraphics2D class is probably a better solution.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: CanvasGraphics2D setTransform
What I was hoping to do was to generate one SVG script, and then draw the graphic twice, once as a thumbnail, and then if this thumbnail was clicked to draw a full scale plot. The SVG files are quite large, and so creating two size versions would be inefficient.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: CanvasGraphics2D setTransform
You mean JavaScript rather than SVG, right? Anyway, I think you are correct that the script being output should preserve the incoming transform, so I will work on that.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program