答えて
いくつかの基本的なグラフを作成する方法の例を示しているorg.jfree.chart.demo
パッケージ。クラス名をクリックするとソースが表示されます。 org.jfree.chart.ChartFactory
の方法は、より多くを構築する方法を示す。クラスorg.jfree.chart.ChartUtilities
には、チャートをいくつかの形式でストリーミングするメソッドが含まれています。対応するresponse.setContentType()
は、任意のサーブレットコンテナから動作します。
これはテラインコグニタであれば、私は†The JFreeChart Developer Guideをお勧めします。
†免責事項:Object Refinery Limitedに所属していません。満足している顧客と非常に小さな貢献者です。
優れた提案。 +1 – Leigh
私はtrashgodの提案を使用して、CF7の非常に初歩的な例を作成しました。あなたは明らかに多くの場合を行うことができます。 APIを確認したり、デベロッパーガイドを購入したりするだけです。
インストール: は、最新のはJFreeChartをダウンロードしてください。次のjarを{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. まだダイヤルチャートがサポートされていないチャートタイプを取得中:ダイヤルエラー
- 2. JfreeChartのマウスイベント
- 3. Jfreechartの点線
- 4. JFreeChartのグラフプロット
- 5. JfreeChartのカスタムデータポイントラベル
- 6. JFreeChart DialPlotのGradientBackground
- 7. JFreeChartのギャップ
- 8. JFreeChartラベルの幅
- 9. JFreeChartの棒チャートバーユニット
- 10. jfreechartのohlcグラフ
- 11. Jfreechartの3Dチャート
- 12. JFreeChartのohlcチャート
- 13. BoxAndWhiskerChartのPlotOrientation JFreeChart
- 14. ScatterPlotDemo-JfreeChart
- 15. JFreechartフィリングセクタシリーズ
- 16. XYプロットのJFreechartカラースクエアグリッド
- 17. JFreeChartのドラッグアンドドロップ機能
- 18. JFreeChartの基本ヒストグラム
- 19. X軸のJFreeChartテーブル?
- 20. Jfreechart動的チャート
- 21. スパンはJFreeChart
- 22. JFreeChart&Lazy loading
- 23. JFreechart with below table
- 24. JFreechart XYPlotオーバーラップデータアーティファクト
- 25. はJFreeChartラインチャート
- 26. JFreeChart最大ズームアウト
- 27. はJFreeChartなTimeSeries
- 28. Java jfreechart stick scatterplot?
- 29. 動的Jfreechart
- 30. JFreechart LookUpPaintScaleカラーグラデーション
?この点について、ColdFusionは他のどのサーバーともどのように異なるのですか? – trashgod
ちょうど興味深いですが、JFreeChartでなければなりませんか? ACFの下でダイヤルチャートを作成することができるので、webcharts3D www.coldfusionjedi.com/index.cfm/2008/1/18/Coolest-CFCHART-Trick-Ever – Leigh
@Leigh:私はCF7サーバでこのインスタンスのために立ち往生しています。CF7に付属しているWebChartsのバージョンは、ゲージではなくダイヤルしかサポートしていません。 – lidbanger