本文整理汇总了Java中org.jfree.data.general.DefaultPieDataset.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultPieDataset.setValue方法的具体用法?Java DefaultPieDataset.setValue怎么用?Java DefaultPieDataset.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.general.DefaultPieDataset
的用法示例。
在下文中一共展示了DefaultPieDataset.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChart
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
@Override
public JFreeChart createChart(Element element, ChartSource source) {
Attribute key = source.getAttributeProperty(PIE_ATTRIBUTE_KEY);
Attribute value = source.getAttributeProperty(PIE_ATTRIBUTE_VALUE);
if ((key == null) || (value == null))
throw new ChartNotSetupedException();
DefaultPieDataset dataset = new DefaultPieDataset();
for (Element element2 : source.getElements()) {
Object v1 = engine.getAttribute(element2, key);
Object v2 = engine.getAttribute(element2, value);
if ((v1 != null) && (v2 != null))
dataset.setValue(toString(v1), toDouble(v2));
}
return ChartFactory.createPieChart(element.getName(), dataset, true,
true, false);
}
示例2: testGetIndex
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Some checks for the getIndex() method.
*/
public void testGetIndex() {
DefaultPieDataset d = new DefaultPieDataset();
d.setValue("A", 1.0);
d.setValue("B", 2.0);
assertEquals(0, d.getIndex("A"));
assertEquals(1, d.getIndex("B"));
assertEquals(-1, d.getIndex("XX"));
boolean pass = false;
try {
d.getIndex(null);
}
catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
}
示例3: getChart
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Creates 3D pie chart with OS usage statistics.
*
* @return Filled 3D pie chart.
*/
public JFreeChart getChart() {
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Mac", 29);
data.setValue("Windows", 51);
data.setValue("Linux", 20);
JFreeChart chart = ChartFactory.createPieChart3D("", data);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
return chart;
}
示例4: setUp
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Common test setup.
*/
protected void setUp() {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(0.0));
data.setValue("C/C++", new Double(17.5));
// create the chart...
this.pieChart = ChartFactory.createPieChart(
"Pie Chart", // chart title
data, // data
true, // include legend
true,
false
);
}
示例5: createPieChart
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Creates a pie chart.
*
* @return the pie chart.
*/
private static JFreeChart createPieChart() {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(0.0));
data.setValue("C/C++", new Double(17.5));
// create the chart...
return ChartFactory.createPieChart("Pie Chart", // chart title
data, // data
true, // include legend
true,
false
);
}
示例6: createPieChart
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Creates a pie chart.
*
* @return The pie chart.
*/
private static JFreeChart createPieChart() {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Java", new Double(43.2));
data.setValue("Visual Basic", new Double(0.0));
data.setValue("C/C++", new Double(17.5));
// create the chart...
return ChartFactory.createPieChart("Pie Chart", // chart title
data, // data
true, // include legend
true,
false
);
}
示例7: testDrawWithNullLegendLabels
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Draws a pie chart where the label generator returns null.
*/
@Test
public void testDrawWithNullLegendLabels() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("L1", 12.0);
dataset.setValue("L2", 11.0);
JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true,
false, false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setLegendLabelGenerator(new NullLegendLabelGenerator());
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例8: createDefaultPieDataset
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
public static DefaultPieDataset createDefaultPieDataset(String[] categories, Object[] datas) {
DefaultPieDataset dataset = new DefaultPieDataset();
for (int i = 0; i < categories.length && categories != null; i++) {
String value = datas[i].toString();
if (isPercent(value)) {
value = value.substring(0, value.length() - 1);
}
if (isNumber(value)) {
dataset.setValue(categories[i], Double.valueOf(value));
}
}
return dataset;
}
示例9: testEquals
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* For datasets, the equals() method just checks keys and values.
*/
public void testEquals() {
DefaultCategoryDataset underlying = new DefaultCategoryDataset();
underlying.addValue(1.1, "R1", "C1");
underlying.addValue(2.2, "R1", "C2");
CategoryToPieDataset d1 = new CategoryToPieDataset(underlying,
TableOrder.BY_COLUMN, 1);
DefaultPieDataset d2 = new DefaultPieDataset();
d2.setValue("R1", 2.2);
assertTrue(d1.equals(d2));
}
示例10: getDataSet
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
private static DefaultPieDataset getDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("苹果", 100);
dataset.setValue("梨子", 200);
dataset.setValue("葡萄", 300);
dataset.setValue("香蕉", 400);
dataset.setValue("荔枝", 500);
return dataset;
}
示例11: createDataset
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Creates a sample dataset.
*
* Source: http://www.bbc.co.uk/news/business-15489523
*
* @return A sample dataset.
*/
private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Samsung", new Double(27.8));
dataset.setValue("Others", new Double(55.3));
dataset.setValue("Nokia", new Double(16.8));
dataset.setValue("Apple", new Double(17.1));
return dataset;
}
示例12: getChart
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Creates 3D pie chart form given list of {@link PollOption} objects.
*
* @param results List of {@link PollOption} objects.
* @return Filled 3D pie chart.
*/
public static JFreeChart getChart(List<PollOption> results) {
DefaultPieDataset result = new DefaultPieDataset();
for (PollOption r : results) {
result.setValue(r.getName(), r.getVotes());
}
JFreeChart chart = ChartFactory.createPieChart3D("", result);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
return chart;
}
示例13: testURL
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Test that the generated URL is as expected.
*/
public void testURL() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Alpha", new Double(5.0));
dataset.setValue("Beta", new Double(5.5));
StandardPieURLGenerator g1 = new StandardPieURLGenerator(
"chart.jsp", "category");
String url = g1.generateURL(dataset, "Beta", 0);
assertEquals("chart.jsp?category=Beta&pieIndex=0", url);
}
示例14: setUp
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Common test setup.
*/
protected void setUp() {
// create a dataset...
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Java", new Double(43.2));
dataset.setValue("Visual Basic", new Double(0.0));
dataset.setValue("C/C++", new Double(17.5));
this.pieChart = createPieChart3D(dataset);
}
示例15: testLimitPieDataset
import org.jfree.data.general.DefaultPieDataset; //导入方法依赖的package包/类
/**
* Some checks for the limitPieDataset() methods.
*/
public void testLimitPieDataset() {
// check that empty dataset is handled OK
DefaultPieDataset d1 = new DefaultPieDataset();
PieDataset d2 = DatasetUtilities.createConsolidatedPieDataset(
d1, "Other", 0.05
);
assertEquals(0, d2.getItemCount());
// check that minItem limit is observed
d1.setValue("Item 1", 1.0);
d1.setValue("Item 2", 49.50);
d1.setValue("Item 3", 49.50);
d2 = DatasetUtilities.createConsolidatedPieDataset(d1, "Other", 0.05);
assertEquals(3, d2.getItemCount());
assertEquals("Item 1", d2.getKey(0));
assertEquals("Item 2", d2.getKey(1));
assertEquals("Item 3", d2.getKey(2));
// check that minItem limit is observed
d1.setValue("Item 4", 1.0);
d2 = DatasetUtilities.createConsolidatedPieDataset(
d1, "Other", 0.05, 2
);
// and that simple aggregation works
assertEquals(3, d2.getItemCount());
assertEquals("Item 2", d2.getKey(0));
assertEquals("Item 3", d2.getKey(1));
assertEquals("Other", d2.getKey(2));
assertEquals(new Double(2.0), d2.getValue("Other"));
}