문제

특히 저는 웹 사용을 위해 PNG 파일에 출력되는 JFreeChart에 특정 위치에 텍스트 주석을 추가하려고합니다. 주석이 파이 차트에 추가 될 수있는 방법/방법. XyPlots에 주석을 성공적으로 추가 할 수 있었지만 PiePlot에 오버레이 또는 하나를 추가하는 방법을 모릅니다.

나의 완전한 임무는 pieplot을 사용하여 일종의 시계를 만드는 것입니다. 지금까지 모든 것이 잘 작동했지만 이제는 12, 3, 6 및 9시 위치에 레이블을 추가하고 완전히 혼란스러워해야합니다.

아담

도움이 되었습니까?

해결책 2

상당히 격렬한 검색 후에 나는 이것이 현재 가능하다고 생각하지 않습니다 (Jfreechart 1.0.13). 가능한 옵션은 다음과 같습니다.

필요한 주석이있는 두 번째 이미지를 생성하기 위해 xyplot으로 두 번째 차트를 작성하십시오. 이 이미지를 페이지에서 오버레이합니다. 이 옵션은 업로드 할 차트 이미지 수를 두 배로 늘리기 때문에 나쁩니다.

이미지를 페이지에서 배경으로 설정하고 이미지 위의 텍스트를 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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top