chartdirector draw air volume calculation and comparison chart of deriving word problem

( 1 ) ChartDirector Registration Issues

Because jfreechart do always feel a little fuzzy map, so using chartdirector be diagramming, but chartdirector if not registered, not registered will display the prompt at the bottom, you need to download the 5.1 cracked version, and add the following code in the program:

	Chart.setLicenseCode("SXZVFNRN9MZ9L8LGA0E2B1BB");

The final resulting picture effect is as follows:

( 2 ) ChartDirector image panel size adaptively

Since chartdirector drawn image area can not automatically according to the size automatic drawing area of the panel, it is necessary to add a graphics monitor panel, as follows:

	this.addComponentListener(new ComponentListener() {
			@Override
			public void componentShown(ComponentEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void componentResized(ComponentEvent e) {
				System.out.println(getWidth() + "--" + getHeight());

			
				createChart(viewer, data, getWidth(), getHeight());

			
			}

			@Override
			public void componentMoved(ComponentEvent e) {
				// TODO Auto-generated method stub

			}

			@Override
			public void componentHidden(ComponentEvent e) {
				// TODO Auto-generated method stub

			}
		});

3

When the pictures were derived using the image generation graphics and dialog generation is a common method, so if the dialog is too large, the resulting word insert a picture will be too large, if you want my word generated picture a little bit, you will need to re-emphasize that the small box to export.

( . 4 ) ChartDirector the image into word in

Since chartdirector the image is java.awt.Image image, and itext the image is com.lowagie.text.Image image, when export graphics, look slightly conversion, as follows:

	byte[] imbyte = chartpan.getViewer().getChart().makeChart(Chart.PNG);
				Image png = com.lowagie.text.Image.getInstance(imbyte);
				document.add(png);


Published 34 original articles · won praise 9 · views 90000 +

Guess you like

Origin blog.csdn.net/tianyatest/article/details/52077856