0

jfreechartライブラリを使用してシリーズチャートを描画しています。y軸の値、x軸の時間、および3つのカテゴリをシリーズとして取得しました。すべて正常ですが、範囲軸では正常に機能していますが、ドメイン軸をズームインできません。これは可能ですか?

次のコード行は、私のコードのシナリオを見つけるのに役立つ場合があります。

final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setDomainZoomable(true);
chartPanel.setRangeZoomable(true);
this.add(chartPanel, BorderLayout.CENTER);

//set plot specifications 
final CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(new Color(0xffffe0));
plot.setDomainGridlinesVisible(true);
plot.setDomainGridlinePaint(Color.lightGray);
plot.setRangeGridlinePaint(Color.lightGray);

//CUSTOMIZE DOMAIN AXIS
final CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis();

//customize domain label position
domainAxis.setCategoryLabelPositions(
       CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
);
4

1 に答える 1

1

CategoryPlotドメイン範囲でのズームをサポートしていないを使用しているようです

ここに画像の説明を入力してください

XYPlotチャートファクトリを使用している場合、ドメイン軸のズームを許可するには、に切り替えます。コードは次のとおりです。

JFreeChart chart = ChartFactory.createXYLineChart(...);

CategoryPlotプロットを何かにキャストできる場合は、問題が発生しています。私がチェックLineChartDemo3 したところ、このコードはエラーを引き起こします(java.lang.ClassCastException):

try {
        final CategoryPlot cplot = (CategoryPlot) chart.getPlot();
    } catch (Exception e) {
        e.printStackTrace();
    }
于 2012-06-26T15:23:39.753 に答える