JFreeChart円グラフの注釈
-
05-07-2019 - |
質問
具体的には、Webで使用するためにpngファイルに出力されるJFreeChartの特定の場所にテキスト注釈を追加したいと考えています。円グラフに注釈を追加できるかどうか。注釈をXYPlotに正常に追加できましたが、PiePlotに注釈をオーバーレイまたは追加する方法がわかりません。
私の完全なタスクは、PiePlotを使用して一種の時計を作成することです。これまでのところ、すべてがうまく機能しましたが、今では、12時、3時、6時、および9時の位置にラベルを追加する必要があります。
アダム
解決 2
かなり激しい検索の後、これが現在可能であるとは思わない(JFreeChart 1.0.13)。 可能なオプションは次のとおりです。
XYPlotを使用して2つ目のグラフを作成し、必要な注釈を含む2つ目の画像を生成します。この画像をページにオーバーレイします。このオプションは、アップロードするグラフ画像の数が2倍になるため、良くありません。
画像をページの背景として設定し、画像上にテキストをHTMLします。メンテナンスが難しく、データ転送の頭痛の種になるため、悪い。
個人的には、タイトルの情報を伝える別の方法を見つけるつもりですが、次の人に調査結果を投稿したかったのです。 アダム
他のヒント
少し古い質問ですが、ここでは、極座標プロットを使用して同様のこと(1、2、3、...時の位置の注釈)を行いました。 ChoiceFormatterとNumberTickUnitを使用します:
final JFreeChart chart = ChartFactory.createPolarChart(
"HAPI Hourly Usage (UTC)", ds, true, true, false);
final PolarPlot plot = (PolarPlot) chart.getPlot();
// Create a ChoiceFormat to map the degrees to clock positions
double[] limits = new double[12];
String[] formats = new String[12];
limits[0] = 0;
formats[0] = "12";
// degrees = 360/12
for (int i = 1; i < limits.length; i++) {
limits[i] = degrees * (i);
formats[i] = Integer.toString(i);
}
ChoiceFormat clock = new ChoiceFormat(limits, formats);
TickUnit tickUnit = new NumberTickUnit(degrees, clock);
// now configure the plot
plot.setAngleTickUnit(tickUnit); // sets the ticks
plot.setAngleLabelsVisible(true); // makes the labels visible
plot.setAngleLabelPaint(Color.LIGHT_GRAY); // user choice
plot.setAngleGridlinesVisible(true); // must set this to display the
// labels
plot.setAngleGridlinePaint(Color.BLACK); // plot's background color
// (makes lines invisible)
plot.setRadiusGridlinesVisible(false); //turn off the radius value circles
ValueAxis axis = plot.getAxis();
axis.setTickLabelsVisible(false); //turn off the radius value labels
http://img522.imageshack.us/img522/6693/のようになりますhapihours.jpg
所属していません StackOverflow