Dynamically setting width and height according to client screen resolution in jFreeChart.createBufferedImage(width,Height,info)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 09:26:27

问题


I have a problem regarding JfreeChart.createBufferedImage(width,Height,info) i am creating a jFreechart in java and showing it in JSF page like this JfreeChart.createBufferedImage(width,Height,info)

Right now i am passing width and height as hardcoded attributes but i want the width and height should dynamically set accoding the cleint screen resolution in JSF page.

Is there any way around to do it ?


回答1:


There isn't a straight forward way. If you aren't familiar with the JSF lifecycle I would check it out (balusc made a great article), but essentially the process would be this:

  1. Initial response is sent to client with javascript
  2. Javascript gets screen size and inserts them in hidden fields and submits a form
  3. Second response is your current page except with the numbers from the hidden fields.

You likely will want an ajax enabled framework that will let you poll so that when the window changes your chart can be regenerate appropriately.



来源:https://stackoverflow.com/questions/5727925/dynamically-setting-width-and-height-according-to-client-screen-resolution-in-jf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!