本文整理汇总了Java中org.jfree.data.statistics.HistogramDataset.addSeries方法的典型用法代码示例。如果您正苦于以下问题:Java HistogramDataset.addSeries方法的具体用法?Java HistogramDataset.addSeries怎么用?Java HistogramDataset.addSeries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.statistics.HistogramDataset
的用法示例。
在下文中一共展示了HistogramDataset.addSeries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: histogramChart
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Création et affichage d'un histogramme avec JFreeChart
* @param listIn
*/
public static void histogramChart(List<Double> listIn, String listName) {
double tabIn[] = new double[listIn.size()];
for (int i = 0; i < listIn.size(); i++) {
tabIn[i] = listIn.get(i);
}
// Création des datasets
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries(listName, tabIn, 200);
// Création de l'histogramme
JFreeChart chart = ChartFactory.createHistogram("", null, null, dataset,
PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame = new ChartFrame("Spatial Data Quality", chart);
frame.pack();
frame.setVisible(true);
}
示例2: createDataset
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Creates dataset for histogram.
*
* @param table
* table with data
* @param column
* column of which you want the data
* @param bin
* for dividing the output in certain amount of parts
* @return dataset
*/
public static HistogramDataset createDataset(final Table table,
final String column, final int bin) {
HistogramDataset dataSet = new HistogramDataset();
// Convert table to usable form of data
double[] data = hist(table, column);
// Calculate maximum value that appears in data
// Calculate minimum value that appears in data
double max = data[0];
double min = data[0];
for (int i = 0; i < data.length; i++) {
if (data[i] > max) {
max = data[i];
}
if (data[i] < min) {
min = data[i];
}
}
dataSet.addSeries("Hist", data, bin, 0, max);
return dataSet;
}
示例3: testEquals
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
HistogramDataset d1 = new HistogramDataset();
d1.addSeries("Series 1", values, 5);
HistogramDataset d2 = new HistogramDataset();
d2.addSeries("Series 1", values, 5);
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2);
assertFalse(d1.equals(d2));
d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2);
assertTrue(d1.equals(d2));
}
示例4: testAddSeries2
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Another check for the addSeries() method.
*/
public void testAddSeries2() {
double[] values = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
HistogramDataset hd = new HistogramDataset();
hd.addSeries("S1", values, 5);
assertEquals(0.0, hd.getStartXValue(0, 0), EPSILON);
assertEquals(1.0, hd.getEndXValue(0, 0), EPSILON);
assertEquals(1.0, hd.getYValue(0, 0), EPSILON);
assertEquals(1.0, hd.getStartXValue(0, 1), EPSILON);
assertEquals(2.0, hd.getEndXValue(0, 1), EPSILON);
assertEquals(1.0, hd.getYValue(0, 1), EPSILON);
assertEquals(2.0, hd.getStartXValue(0, 2), EPSILON);
assertEquals(3.0, hd.getEndXValue(0, 2), EPSILON);
assertEquals(1.0, hd.getYValue(0, 2), EPSILON);
assertEquals(3.0, hd.getStartXValue(0, 3), EPSILON);
assertEquals(4.0, hd.getEndXValue(0, 3), EPSILON);
assertEquals(1.0, hd.getYValue(0, 3), EPSILON);
assertEquals(4.0, hd.getStartXValue(0, 4), EPSILON);
assertEquals(5.0, hd.getEndXValue(0, 4), EPSILON);
assertEquals(2.0, hd.getYValue(0, 4), EPSILON);
}
示例5: asChart
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/** Return the JFreeChart with this histogram, and as a side effect, show it in a JFrame
* that provides the means to edit the dimensions and also the plot properties via a popup menu. */
public JFreeChart asChart(final boolean show) {
double[] d = new double[this.size()];
int i = 0;
for (Number num : this.values()) d[i++] = num.doubleValue();
HistogramDataset hd = new HistogramDataset();
hd.setType(HistogramType.RELATIVE_FREQUENCY);
String title = "Histogram";
hd.addSeries(title, d, d.length);
JFreeChart chart = ChartFactory.createHistogram(title, "", "", hd,
PlotOrientation.VERTICAL, false, false, false);
setTheme(chart);
if (show) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(new ChartPanel(chart));
frame.pack();
frame.setVisible(true);
}
return chart;
}
示例6: getDataSet
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
private HistogramDataset getDataSet() {
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.FREQUENCY);
List<Double> values =
CollectionUtils.mapNullRemoves(
download.getAllValidConnections(),
new CollectionUtils.Function<BitTorrentConnection, Double>() {
public Double evaluate(BitTorrentConnection connection) {
BitField bitField = connection.getRemoteBitField();
if (bitField == null || !connection.isOpen()) {
return null;
}
return 100.0 * bitField.getAvailablePieceCount() / bitField.getPieceCount();
}
});
dataset.addSeries("Completion", CollectionUtils.toArray(values), 50, 0.0, 100.0);
return dataset;
}
示例7: createHistogramDataset
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Creates a {@link HistogramDataset} for this {@link Attribute}.
*
* @param exampleSet
* @return
*/
private HistogramDataset createHistogramDataset(final ExampleSet exampleSet) {
HistogramDataset dataset = new HistogramDataset();
double[] array = new double[exampleSet.size()];
int count = 0;
for (Example example : exampleSet) {
double value = example.getDataRow().get(getAttribute());
// don't use missing values because otherwise JFreeChart tries to plot them too which
// can lead to false histograms
if (!Double.isNaN(value)) {
array[count++] = value;
}
}
// add points to data set (if any)
if (count > 0) {
// truncate array if necessary
if (count < array.length) {
array = Arrays.copyOf(array, count);
}
dataset.addSeries(getAttribute().getName(), array, Math.min(array.length, MAX_BINS_HISTOGRAM));
}
return dataset;
}
示例8: createHistogramDataset
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Creates a {@link HistogramDataset} for this {@link Attribute}.
*
* @param exampleSet
* @return
*/
private HistogramDataset createHistogramDataset(ExampleSet exampleSet) {
HistogramDataset dataset = new HistogramDataset();
double[] array = new double[exampleSet.size()];
int count = 0;
for (Example example : exampleSet) {
double value = example.getDataRow().get(getAttribute());
// don't use missing values because otherwise JFreeChart tries to plot them too which
// can lead to false histograms
if (!Double.isNaN(value)) {
array[count++] = value;
}
}
// add points to data set (if any)
if (count > 0) {
// truncate array if necessary
if (count < array.length) {
array = Arrays.copyOf(array, count);
}
dataset.addSeries(getAttribute().getName(), array, Math.min(array.length, MAX_BINS_HISTOGRAM));
}
return dataset;
}
示例9: testEquals
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
final double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
final HistogramDataset d1 = new HistogramDataset();
d1.addSeries("Series 1", values, 5);
final HistogramDataset d2 = new HistogramDataset();
d2.addSeries("Series 1", values, 5);
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
}
示例10: testBins
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Some checks that the correct values are assigned to bins.
*/
public void testBins() {
double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
HistogramDataset hd = new HistogramDataset();
hd.addSeries("Series 1", values, 5);
assertEquals(hd.getYValue(0, 0), 3.0, EPSILON);
assertEquals(hd.getYValue(0, 1), 3.0, EPSILON);
assertEquals(hd.getYValue(0, 2), 2.0, EPSILON);
assertEquals(hd.getYValue(0, 3), 0.0, EPSILON);
assertEquals(hd.getYValue(0, 4), 1.0, EPSILON);
}
示例11: testEquals
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
HistogramDataset d1 = new HistogramDataset();
d1.addSeries("Series 1", values, 5);
HistogramDataset d2 = new HistogramDataset();
d2.addSeries("Series 1", values, 5);
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
}
示例12: testGetSeriesKey
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* A test for a bug reported in the forum where the series name isn't being
* returned correctly.
*/
public void testGetSeriesKey() {
double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
HistogramDataset d1 = new HistogramDataset();
d1.addSeries("Series 1", values, 5);
assertEquals("Series 1", d1.getSeriesKey(0));
}
示例13: testAddSeries
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Some checks for the addSeries() method.
*/
public void testAddSeries() {
double[] values = {-1.0, 0.0, 0.1, 0.9, 1.0, 1.1, 1.9, 2.0, 3.0};
HistogramDataset d = new HistogramDataset();
d.addSeries("S1", values, 2, 0.0, 2.0);
assertEquals(0.0, d.getStartXValue(0, 0), EPSILON);
assertEquals(1.0, d.getEndXValue(0, 0), EPSILON);
assertEquals(4.0, d.getYValue(0, 0), EPSILON);
assertEquals(1.0, d.getStartXValue(0, 1), EPSILON);
assertEquals(2.0, d.getEndXValue(0, 1), EPSILON);
assertEquals(5.0, d.getYValue(0, 1), EPSILON);
}
示例14: testBinBoundaries
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* This test is derived from a reported bug.
*/
public void testBinBoundaries() {
double[] values = { -5.000000000000286E-5 };
int bins = 1260;
double minimum = -0.06307522528160199;
double maximum = 0.06297522528160199;
HistogramDataset d = new HistogramDataset();
d.addSeries("S1", values, bins, minimum, maximum);
assertEquals(0.0, d.getYValue(0, 629), EPSILON);
assertEquals(1.0, d.getYValue(0, 630), EPSILON);
assertEquals(0.0, d.getYValue(0, 631), EPSILON);
assertTrue(values[0] > d.getStartXValue(0, 630));
assertTrue(values[0] < d.getEndXValue(0, 630));
}
示例15: test1553088
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
/**
* Some checks for bug 1553088. An IndexOutOfBoundsException is thrown
* when a data value is *very* close to the upper limit of the last bin.
*/
public void test1553088() {
double[] values = {-1.0, 0.0, -Double.MIN_VALUE, 3.0};
HistogramDataset d = new HistogramDataset();
d.addSeries("S1", values, 2, -1.0, 0.0);
assertEquals(-1.0, d.getStartXValue(0, 0), EPSILON);
assertEquals(-0.5, d.getEndXValue(0, 0), EPSILON);
assertEquals(1.0, d.getYValue(0, 0), EPSILON);
assertEquals(-0.5, d.getStartXValue(0, 1), EPSILON);
assertEquals(0.0, d.getEndXValue(0, 1), EPSILON);
assertEquals(3.0, d.getYValue(0, 1), EPSILON);
}