本文整理匯總了Java中org.jfree.chart.ChartFactory.createBarChart3D方法的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory.createBarChart3D方法的具體用法?Java ChartFactory.createBarChart3D怎麽用?Java ChartFactory.createBarChart3D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.ChartFactory
的用法示例。
在下文中一共展示了ChartFactory.createBarChart3D方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createBarChart3D
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Create a horizontal bar chart with sample data in the range -3 to +3.
*
* @return the chart.
*/
private static JFreeChart createBarChart3D() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-3), new Integer(-2)},
{new Integer(-1), new Integer(1)},
{new Integer(2), new Integer(3)}};
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
// create the chart...
return ChartFactory.createBarChart3D(
"Bar Chart 3D",
"Domain",
"Range",
dataset,
PlotOrientation.HORIZONTAL,
true, // include legend
true,
false
);
}
示例2: createBarChart3D
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* Create a horizontal bar chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createBarChart3D() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-3), new Integer(-2)},
{new Integer(-1), new Integer(1)},
{new Integer(2), new Integer(3)}};
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S",
"C", data);
// create the chart...
return ChartFactory.createBarChart3D("Bar Chart 3D", "Domain", "Range",
dataset, PlotOrientation.HORIZONTAL, true, true, true);
}
示例3: createBarChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
private static JFreeChart createBarChart(String title,String category,String value, CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title
category, // domain axis label
value, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // 圖標方向
true, // 是否顯示legend
true, // 是否顯示tooltips
false // 是否顯示URLs
);
CategoryPlot plot = chart.getCategoryPlot();//設置圖的高級屬性
plot.setBackgroundPaint(ChartColor.WHITE);
NumberAxis na= (NumberAxis)plot.getRangeAxis();
// na.setAutoTickUnitSelection(false);//設置小數點位數
na.setNumberFormatOverride(df);
// NumberTickUnit nt=new NumberTickUnit(1.22);
// na.setTickUnit(nt);
// plot.setRangeAxis(na);
BarRenderer3D renderer = new BarRenderer3D();//3D屬性修改
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
renderer.setItemLabelAnchorOffset(10);
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
renderer.setSeriesPaint(0,new Color(34,139,34));
renderer.setSeriesPaint(1,new Color(154,205,50));
renderer.setSeriesPaint(2,new Color(0,255,0));
renderer.setSeriesPaint(3,new Color(127,255,212));
plot.setRenderer(renderer);//將修改後的屬性值保存到圖中
return chart;
}
示例4: BarChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public BarChart() {
CategoryDataset dataset = getDataSet();
JFreeChart chart = ChartFactory.createBarChart3D(
"水果", // 圖表標題
"水果種類", // 目錄軸的顯示標簽
"數量", // 數值軸的顯示標簽
dataset, // 數據集
PlotOrientation.VERTICAL, // 圖表方向:水平、垂直
true, // 是否顯示圖例(對於簡單的柱狀圖必須是false)
false, // 是否生成工具
false // 是否生成URL鏈接
);
//從這裏開始
CategoryPlot plot = chart.getCategoryPlot();//獲取圖表區域對象
CategoryAxis domainAxis = plot.getDomainAxis(); //水平底部列表
domainAxis.setLabelFont(new Font("黑體", Font.BOLD, 14)); //水平底部標題
domainAxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12)); //垂直標題
ValueAxis rangeAxis = plot.getRangeAxis();//獲取柱狀
rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
chart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
chart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));//設置標題字體
//到這裏結束,雖然代碼有點多,但隻為一個目的,解決漢字亂碼問題
frame1 = new ChartPanel(chart, true); //這裏也可以用chartFrame,可以直接生成一個獨立的Frame
}
示例5: addChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
* It creates a chart for the given dataset and adds the chart to the panel.
*
* @param dataset The dataset that will provide the values for the chart.
*/
private void addChart() {
JFreeChart chart = ChartFactory.createBarChart3D(getTitle(),
null, "Time" + unitSuffix(),
dataset, PlotOrientation.VERTICAL,
true, true, false);
chart.addProgressListener(locker);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setToolTipGenerator(dataset);
mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart));
}
示例6: createChart
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
@Override
public JFreeChart createChart(Element element, ChartSource source) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
Attribute key = source.getAttributeProperty(BAR_ATTRIBUTE_KEY);
List<Attribute> attributes = source
.getPropertyAttributes(BAR_ATTRIBUTE_VALUE_PREFIX);
for (Element e : source.getElements()) {
Object keyValue = engine.getAttribute(e, key);
if (keyValue != null) {
for (Attribute attribute : attributes) {
Object value = engine.getAttribute(e, attribute);
if (value != null) {
double v = new EObject(value).doubleValue();
dataset.addValue(v, attribute.getName(), new EObject(
keyValue).stringValue());
}
}
}
}
JFreeChart chart = ChartFactory
.createBarChart3D(
element.getName(),
source.getProperty(BAR_CATEGORY_AXIS_LABEL),
source.getProperty(BAR_VALUE_AXIS_LABEL),
dataset,
(BAR_ORIENTATION_HORIZONTAL.equals(source
.getProperty(BAR_ORIENTATION))) ? PlotOrientation.HORIZONTAL
: PlotOrientation.VERTICAL, true, true, true);
GradientPaint gradientpaint0 = new GradientPaint(0.0F, 0.0F, new Color(
0, 0, 250), 0.0F, 0.0F, new Color(136, 136, 255));
BarRenderer3D r = (BarRenderer3D) chart.getCategoryPlot().getRenderer();
r.setSeriesPaint(0, gradientpaint0);
return chart;
}
示例7: init
import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void init() {
CategoryDataset dataset = getDataSet();
JFreeChart chart = ChartFactory.createBarChart3D("Number Ranking", // 圖表標題
"Book Types", // 目錄軸的顯示標簽
"The Number of Books", // 數值軸的顯示標簽
dataset, // 數據集
PlotOrientation.VERTICAL, // 圖表方向:水平、垂直
true, false, // 是否生成工具
false // 是否生成URL鏈接
);
// 從這裏開始
CategoryPlot plot = chart.getCategoryPlot();// 獲取圖表區域對象
BarRenderer3D renderer =new BarRenderer3D();
renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setItemLabelFont(new Font("黑體",Font.BOLD,14));//12號黑體加粗
renderer.setItemLabelPaint(Color.black);//字體為黑色
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_CENTER));
renderer.setItemLabelsVisible(true);
plot.setRenderer(renderer);
CategoryAxis domainAxis = plot.getDomainAxis(); // 水平底部列表
domainAxis.setLabelFont(new Font("黑體", Font.BOLD, 14)); // 水平底部標題
domainAxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12)); // 垂直標題
ValueAxis rangeAxis = plot.getRangeAxis();// 獲取柱狀
rangeAxis.setUpperMargin(0.1);
rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
chart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
chart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));// 設置標題字體
chartPane = new ChartPanel(chart, true);
// File dir = new File("images\\");
// if (!dir.exists()) {
// dir.mkdir();
// }
// String fName = String.valueOf(System.currentTimeMillis()) + "bar.png";
// File file = new File("images\\", fName);
// try {
// ChartUtilities.saveChartAsPNG(file, chart, 550, 400);
// } catch (IOException e) {
//
// e.printStackTrace();
// }
}