jfreechart: Gantt Chart Task Label Font Size

给你一囗甜甜゛ 提交于 2019-12-04 06:41:30

问题


I put my Gantt Chart (ChartPanel) in a JScrollPane,and create a button named [zoom in].
The function for the button [zoom in] is:
When I click [zoom in] button, the width of chart panel will be doubled.

newSize = originalChartWidth * 2;
chartPanel.setPreferredSize(new java.awt.Dimension(newSize, 1000)); 

After click [zoom in] button, the scroll bar of JScrollPane will be appeared.
Then the user can scroll to watch the whole chart after zoom in.

But there is a problem, When I double the chart panel width, The Task Label Font will be enlarged too.

Before zoom in

After zoom in (The font will be deformed and hard to read)

Is there any way to keep the original font after I double the chart panel width?


回答1:


Absent a complete example, this appears to be an artifact of adding a ChartPanel directly to a JscrollPane. Instead, use a SlidingGanttCategoryDataset which permits the use of setFirstCategoryIndex() in response to a scrollbar state change. SlidingGanttDatasetDemo1 is a complete example.




回答2:


I got the answer to solve my problem.

Call ChartPanel.setMinimumDrawWidth/Height with small value and ChartPanel.setMaximumDrawWidth/Height with large values than exceed the screen size of your monitor. Then, the ChartPanel will be scaled without being distorted.

Please refer to: How to aviod axis label and legend scaling



来源:https://stackoverflow.com/questions/27773120/jfreechart-gantt-chart-task-label-font-size

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