package com.test;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.ui.ApplicationFrame;
import java.awt.RenderingHints;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.FastScatterPlot;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class CreateChartServiceImpl extends ApplicationFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
/** A constant for the number of items in the sample dataset. */
private static final int COUNT = 100;
/** The data. */
private float[][] data = new float[2][COUNT];
/**
* Creates a new fast scatter plot demo.
*
* @param title the frame title.
*/
public CreateChartServiceImpl(final String title) {
super(title);
populateData();
final NumberAxis domainAxis = new NumberAxis("X");
domainAxis.setAutoRangeIncludesZero(false);
final NumberAxis rangeAxis = new NumberAxis("Y");
rangeAxis.setAutoRangeIncludesZero(false);
final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
final JFreeChart chart = new JFreeChart("123", plot);
// chart.setLegend(null);
// force aliasing of the rendered content..
chart.getRenderingHints().put
(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final ChartPanel panel = new ChartPanel(chart, true);
panel.setPreferredSize(new java.awt.Dimension(500, 500));
// panel.setHorizontalZoom(true);
// panel.setVerticalZoom(true);
panel.setMinimumDrawHeight(0);
panel.setMaximumDrawHeight(1000);
panel.setMinimumDrawWidth(0);
panel.setMaximumDrawWidth(1000);
setContentPane(panel);
}
private void populateData() {
int [] di=new int[50];
int c=0;//表示di求和
for(int i=0;i<di.length;i++ ){
di[i]=(int) (Math.random()*100);//随机生成0--100的数
c+=di[i];
}
int [] di2=new int[50];
int c2=0;//表示di求和
for(int i=0;i<di2.length;i++ ){
di2[i]=(int) (Math.random()*100);//随机生成0--100的数
c2+=di[i];
}
for (int i = 0; i < 50; i++) {
data[0][i]=di[i];//-----------------------------------------赋值坐标
data[1][i]=di2[i];
}
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(final String[] args) {
final CreateChartServiceImpl demo = new CreateChartServiceImpl("Fast Scatter Plot Demo");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
import org.jfree.chart.axis.NumberAxis;
import org.jfree.ui.ApplicationFrame;
import java.awt.RenderingHints;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.FastScatterPlot;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class CreateChartServiceImpl extends ApplicationFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
/** A constant for the number of items in the sample dataset. */
private static final int COUNT = 100;
/** The data. */
private float[][] data = new float[2][COUNT];
/**
* Creates a new fast scatter plot demo.
*
* @param title the frame title.
*/
public CreateChartServiceImpl(final String title) {
super(title);
populateData();
final NumberAxis domainAxis = new NumberAxis("X");
domainAxis.setAutoRangeIncludesZero(false);
final NumberAxis rangeAxis = new NumberAxis("Y");
rangeAxis.setAutoRangeIncludesZero(false);
final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
final JFreeChart chart = new JFreeChart("123", plot);
// chart.setLegend(null);
// force aliasing of the rendered content..
chart.getRenderingHints().put
(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final ChartPanel panel = new ChartPanel(chart, true);
panel.setPreferredSize(new java.awt.Dimension(500, 500));
// panel.setHorizontalZoom(true);
// panel.setVerticalZoom(true);
panel.setMinimumDrawHeight(0);
panel.setMaximumDrawHeight(1000);
panel.setMinimumDrawWidth(0);
panel.setMaximumDrawWidth(1000);
setContentPane(panel);
}
private void populateData() {
int [] di=new int[50];
int c=0;//表示di求和
for(int i=0;i<di.length;i++ ){
di[i]=(int) (Math.random()*100);//随机生成0--100的数
c+=di[i];
}
int [] di2=new int[50];
int c2=0;//表示di求和
for(int i=0;i<di2.length;i++ ){
di2[i]=(int) (Math.random()*100);//随机生成0--100的数
c2+=di[i];
}
for (int i = 0; i < 50; i++) {
data[0][i]=di[i];//-----------------------------------------赋值坐标
data[1][i]=di2[i];
}
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(final String[] args) {
final CreateChartServiceImpl demo = new CreateChartServiceImpl("Fast Scatter Plot Demo");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}