use of com.tencent.wstt.apt.chart.PieChart in project GT by Tencent.
the class PMAPView method createChartPanel.
/**
* 生成饼图
* @param parent
* @param data
*/
private void createChartPanel(Composite parent, Map<String, Integer> data) {
Composite composite = new Composite(parent, SWT.NO_BACKGROUND | SWT.EMBEDDED);
Frame frame = SWT_AWT.new_Frame(composite);
// 据说加入这个Panel可以无闪烁
Panel panel = new Panel(new BorderLayout()) {
private static final long serialVersionUID = 1L;
public void update(java.awt.Graphics g) {
/* Do not erase the background */
paint(g);
}
};
frame.add(panel);
JRootPane root = new JRootPane();
panel.add(root);
java.awt.Container contentPane = root.getContentPane();
PieChart chart = new PieChart();
int showItemNum = 0;
try {
showItemNum = Integer.parseInt(showDataItemCountText.getText());
} catch (NumberFormatException e) {
e.printStackTrace();
showItemNum = 10;
}
chart.setDataset(getPieChartDataFromMap(data, showItemNum));
contentPane.add(chart);
}