回答
org.jfree.chart.demo
具有如何构造的几个基本图表的例子的包装;点击课程名称查看源代码。 org.jfree.chart.ChartFactory
的方法展示了如何构建更多。类org.jfree.chart.ChartUtilities
包括以多种格式流化图表的方法。相应的response.setContentType()
适用于任何servlet容器。
如果这是未知领域,我建议The JFreeChart Developer Guide†。
†声明:与Object Refinery Limited无关;只是一个满意的客户和非常小的贡献者。
优秀的建议。 +1 – Leigh
使用垃圾建议,我为CF7创建了一个非常基本的例子。你可以明显做更多与它。只需查看api和/或购买开发者指南即可。
安装: 下载最新的JFreeChart。将以下罐子复制到{cf_root}\WEB-INF\lib
并重新启动CF. 请注意,jar版本号可能会有所不同。
- 了JFreeChart 1.0.13.jar
- jcommon-1.0.16.jar
样品:
<cfscript>
// my chart settings
chartTitle = "My Dial Chart";
arrowValue = 55;
dialMinimum = 0;
dialMaximum = 100;
chartWidth = 500;
chartHeight = 500;
// initialize basic components of the chart
// see jFreeChart API on how to customize the components settings further
DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
pointerValue = DefaultValueDataset.init(arrowValue);
dialPointer = createObject("java", "org.jfree.chart.plot.dial.DialPointer$Pointer").init();
dialFrame = createObject("java", "org.jfree.chart.plot.dial.StandardDialFrame").init();
dialBackground = createObject("java", "org.jfree.chart.plot.dial.DialBackground").init();
// tweak the default range to make it more appealing.
// see angle/extent: http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html
dialScale = createObject("java", "org.jfree.chart.plot.dial.StandardDialScale").init();
dialScale.setLowerBound(dialMinimum);
dialScale.setUpperBound(dialMaximum);
dialScale.setStartAngle(-150);
dialScale.setExtent(-240);
//initialize plot and apply settings
plot = createObject("java", "org.jfree.chart.plot.dial.DialPlot").init();
plot.setDialFrame(dialFrame);
plot.setBackground(dialBackground);
plot.setDataset(pointerValue);
plot.addScale(0, dialScale);
plot.addPointer(dialPointer);
// create chart and convert it to an image
chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
chartImage = chart.createBufferedImage(chartWidth, chartHeight);
ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
bytes = EncoderUtil.encode(chartImage, ImageFormat.PNG);
</cfscript>
<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
(这可能不应该是一个独立的答案,但另一个已经很长了,所以我将它分开发布,以保持组织和易于查找。)
如果你正在寻找什么jFreeChart调用MeterChart,这里是一个快速和肮脏的图表类型的例子。
MeterChart代码:
<cfscript>
// my chart settings
chartTitle = "My Meter Chart";
arrowValue = 55;
arrowUnits = "widgets";
chartWidth = 500;
chartHeight = 500;
// initialize meter ranges (LOW, MEDIUM, HIGH)
// note: quick and ugly code in dire need of improvement ...
low = createSolidMeterInterval("Low", 0, 40, createAwtColor(0, 255, 0, 120));
med = createSolidMeterInterval("Med", 40, 60, createAwtColor(255, 255, 0, 120));
high = createSolidMeterInterval("High", 60, 100, createAwtColor(255, 0, 0, 120));
// initialize arrow value
DefaultValueDataset = createObject("java", "org.jfree.data.general.DefaultValueDataset");
meterPointer = DefaultValueDataset.init(arrowValue);
//initialize plot and apply settings
plot = createObject("java", "org.jfree.chart.plot.MeterPlot").init();
plot.setDataset(meterPointer);
plot.setTickLabelsVisible(true);
plot.addInterval(low);
plot.addInterval(med);
plot.addInterval(high);
plot.setUnits(arrowUnits);
// create chart and convert it to an image
chart = createObject("java", "org.jfree.chart.JFreeChart").init(chartTitle, plot);
ChartUtilities = createObject("java", "org.jfree.chart.ChartUtilities");
ChartUtilities.applyCurrentTheme(chart);
// applyCurrentTheme seems to overwrite some settings, so we must reapply them
Color = createObject("java", "java.awt.Color");
plot.setBackgroundPaint(Color.GRAY);
plot.setNeedlePaint(Color.BLACK);
chartImage = chart.createBufferedImage(chartWidth, chartHeight);
ImageFormat = createObject("java", "org.jfree.chart.encoders.ImageFormat");
EncoderUtil = createObject("java", "org.jfree.chart.encoders.EncoderUtil");
bytes = EncoderUtil.encode(chartImage, ImageFormat.PNG);
</cfscript>
<!--- display in browser --->
<cfcontent type="image/png" variable="#bytes#">
辅助功能:
<cfscript>
// quick and ugly functions. could be improved ...
function createSolidMeterInterval(Title, fromValue, toValue, BgColor) {
var Range = createObject("java", "org.jfree.data.Range").init(arguments.fromValue, arguments.toValue);
var MeterInterval = createObject("java", "org.jfree.chart.plot.MeterInterval");
return MeterInterval.init(arguments.Title, Range // interval from/to range
, javacast("null", "") // outline color
, javacast("null", "") // outline stroke
, arguments.BgColor // background color
);
}
// using java.awt.Color is a pain due to all the javacasts ...
function createAwtColor(r, g, b, alpha) {
var color = createObject("java", "java.awt.Color");
return color.init(javacast("int", arguments.r)
, javacast("int", arguments.g)
, javacast("int", arguments.b)
, javacast("int", arguments.alpha) // transparency
);
}
</cfscript>
+1很好的例子。 – trashgod
- 1. NetBeans中的JFreeChart拨号JButton
- 2. 获取拨号在本机拨号android
- 3. 拨号位置量表图Plotly R
- 4. 虽然使拨号图表获取不支持的图表类型:拨号错误
- 5. 的JFreeChart到Primefaces图表
- 6. 星符号拨号样视图
- 7. NFC智能拨号拨打号码
- 8. 星号php拨号
- 9. JFreeChart中的利差图和图表
- 10. JFreeChart图表渲染问题
- 11. jfreechart,图表创建错误
- 12. 三维图表与Jfreechart
- 13. Jfreechart:显示多个图表
- 14. 半圆图表使用JFreeChart
- 15. JFreeChart - 图表固定宽度
- 16. JFreeChart图表质量更高
- 17. Android:拨号键盘前的意图
- 18. ACTION_CALL与特定拨号器的意图
- 19. 拨打号码
- 20. Android。从拨号
- 21. 反向拨号
- 22. 在拨入/拨出电话时自动打开拨号盘
- 23. 如何使用android的aChart引擎创建拨号图表?
- 24. 从列表视图中的号码使拨打电话
- 25. 的JFreeChart:图表的背景与黑色
- 26. 拨号在Android手机号码
- 27. 在Android中自动拨号号码
- 28. 出界拨号星号
- 29. Asterisk防止拨号方案连续重复的拨号方案
- 30. 与拉斐尔JS的拨号盘拨号
如何为这方面的任何其他图不同拨号图表? ColdFusion在这方面与其他服务器有什么不同? – trashgod
只是好奇,它必须是JFreeChart?因为您可以使用webcharts3D 在ACF下创建拨号图表@coldfusionjedi.com/index.cfm/2008/1/18/Coolest-CFCHART-Trick-Ever – Leigh
@Leigh:我被CF卡服务器卡住了这个实例。CF7附带的WebCharts版本只支持拨号,而不是标准。 – lidbanger