0

具体的には、Web で使用するために png ファイルに出力されている JFreeChart の特定の場所にテキスト注釈を追加しようとしています。円グラフに注釈を追加できる/追加する方法。注釈を XYPlot に正常に追加できましたが、PiePlot にオーバーレイまたは追加する方法がわかりません。

私の完全なタスクは、PiePlot を使用して一種の時計を作成することです。これまでのところ、すべてうまく機能していますが、今度は 12 時、3 時、6 時、9 時の位置にラベルを追加する必要があり、完全に困惑しています。

アダム

4

2 に答える 2

2

少し古い質問ですが、極座標プロットを使用して同様のこと(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のようになります

于 2011-12-21T14:38:29.223 に答える
0

かなり精力的な検索の後、私はこれが現在可能であるとは思わない(JFreeChart1.0.13)。可能なオプションは次のとおりです。

XYPlotを使用して2番目のグラフを作成し、必要な注釈を付けた2番目の画像を生成します。この画像をページにオーバーレイします。このオプションは、アップロードするチャート画像の数を2倍にするため、不適切です。

画像をページの背景として設定し、画像の上にテキストをHTML表示します。メンテナンスが不可能で、データ転送の頭痛の種になるため、悪いです。

個人的には、タイトルの情報を伝える別の方法を探すつもりですが、次の人のために自分の発見を投稿したいと思いました。アダム

于 2009-07-30T15:18:42.957 に答える