我在 main 中的代码如下所示:
ArrayList<Integer> temper = new ArrayList<>();
ArrayList<Float> time = new ArrayList<>();
while(rs.next()){
time.add(rs.getFloat("Time_ms"));
temper.add(rs.getInt("VarValue"));
}
timemax = Collections.max(time);
timemin = Collections.min(time);
tempermax = Collections.max(temper);
tempermin = Collections.min(temper);
我也有这个创建图表的类:
public NormalDistributionDemo(final String title) {
super(title);
Function2D normal = new NormalDistributionFunction2D(2, 8);
XYDataset dataset = DatasetUtilities.sampleFunction2D(normal,0, 5, 10, "Normal");
final JFreeChart chart = ChartFactory.createXYLineChart(
"AS Hellas Database",
"Date",
"Temperature",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
}
此代码工作正常,但我想获取从数据库中提取的值并将它们插入 x,y 轴。
我这样做:
Function2D normal = new NormalDistributionFunction2D(tempermin, tempermax);
XYDataset dataset = DatasetUtilities.sampleFunction2D(normal,timemin, timemax, 10,"Normal");
我得到这个错误:
Exception in thread "main" java.lang.IllegalArgumentException: Requires 'start' < 'end'.
at org.jfree.data.general.DatasetUtilities.sampleFunction2DToSeries(DatasetUtilities.java:542)
at org.jfree.data.general.DatasetUtilities.sampleFunction2D(DatasetUtilities.java:511)
at org.jfree.chart.demo.NormalDistributionDemo.<init> (NormalDistributionDemo.java:80)
at org.jfree.chart.demo.NormalDistributionDemo.main(NormalDistributionDemo.java:71)
有任何想法吗 ?