0

jfreechart 1.0.13

jfreechartのツールチップの位置に問題があります。私は次の設定でそれを構築します

 private static final GradientPaint GRADIENT_PAINT = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));

    private static final double ITEM_MARGIN = 0.2d;

    private static final double MAXIMUM_BAR_WIDTH = .04;

    private static final int MAXIMUM_CATEGORY_LABEL_WIDTH = 10;

    private static final int MAXIMUM_CATEGORY_LABEL_LINES = 2;

    private static final Paint BACKGROUND_COLOR = new Color(196, 196, 196);

 @Override
    protected BarRenderer configMainRenderer() {
        BarRenderer renderer = new BarRenderer();
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
        renderer.setShadowVisible(false);
        renderer.setDrawBarOutline(false);
        renderer.setDrawBarOutline(true);
        renderer.setMaximumBarWidth(MAXIMUM_BAR_WIDTH);
        renderer.setSeriesPaint(0, GRADIENT_PAINT);
        renderer.setItemMargin(ITEM_MARGIN);
        return renderer;
    }

 @Override
    protected NumberAxis configRangeAxis(IRangeAxis axis) {
        NumberAxis valueAxis = new NumberAxis(axis.getName());
        valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        return valueAxis;
    }

@Override
protected CategoryAxis configDomainAxis(String domainAxisName) {
    CategoryAxis domainAxis = new CategoryAxis(domainAxisName);
    domainAxis.setMaximumCategoryLabelWidthRatio(MAXIMUM_CATEGORY_LABEL_WIDTH);
    domainAxis.setMaximumCategoryLabelLines(MAXIMUM_CATEGORY_LABEL_LINES);
    domainAxis.setTickLabelFont(getDefaultDomainAxisFont());
    return domainAxis;
}

@Override
protected CategoryPlot plotSetup(Dataset dataset, CategoryAxis domainAxis, NumberAxis mainRangeAxis, BarRenderer mainRenderer) {
    CategoryDataset catDataset = (CategoryDataset)dataset;
    CategoryPlot plot = new CategoryPlot(catDataset, domainAxis, mainRangeAxis, mainRenderer);
    plot.setOrientation(getModel().getPlotOrientation());
    plot.setBackgroundPaint(BACKGROUND_COLOR);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    return plot;

次に、新しく作成したグラフをChartCompositeに表示します。

//creating composite for chart
        chartComposite = new ChartComposite(controlsComposite, SWT.NONE);
        chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
        chartComposite.setVisible(false);
        chartComposite.addChartMouseListener(this);
// update chartcomposite when necessary
        chartComposite.setVisible(true);
        chartComposite.setChart(chart);
        chartComposite.setHorizontalAxisTrace(true);
        chartComposite.forceRedraw();

その結果、正しいチャートが作成されましたが、すべてのツールチップがビュー/コンポジットの右側に移動しています。また、いくつかのチャート領域を選択しようとすると、「0」ポイントからではなく、シフトしたように見えます(添付の写真を参照)。

ここに画像の説明を入力してください ここに画像の説明を入力してください そのような行動についての提案を聞いてうれしいです

4

1 に答える 1

-1

ツールチップにもバグがありました。私が考え出した修正:

1) JFreeChart のソースで、ファイル ChartComposite.java を検索します。 2) 1200 行目 (約) で検索します。

    ChartEntity entity = entities.getEntity(
    e.x - insets.x /this.scaleX, 
    y.x - insets.y /this.scaleY);

次のようにスケールを削除します。

    ChartEntity entity = entities.getEntity(
    (e.x - insets.x), 
    (y.x - insets.y));

それが役に立てば幸い。

注意

于 2015-02-23T12:22:20.357 に答える