2
DefaultIntervalCategoryDataset
には、区間の範囲情報をバーに表示します。次の図で囲まれた情報を破棄し、間隔の値を表示したいだけです。以下はIntervalBarRenderer:バーの内部に特定の情報を表示する
コードです。間隔値のみを表示する方法は?
public class IntervalBarChartTest0 extends ApplicationFrame {
public IntervalBarChartTest0(String title) {
super(title);
JPanel chartPanel = createDemoPanel();
chartPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(chartPanel);
}
private static DefaultIntervalCategoryDataset createDataset1() {
Number[] series1_Start = new Number[] {25,50};
Number[] series1_End = new Number[] {50,75};
Number[][] starts = new Number[][]{series1_Start};
Number[][] ends = new Number[][] {series1_End};
String[] categoryKeys = {"50th%ile", "90th%ile"};
String[] seriesKeys = {"Series1"};
DefaultIntervalCategoryDataset dataset= new DefaultIntervalCategoryDataset(seriesKeys,categoryKeys,starts, ends);
return dataset;
}
private static JFreeChart createChart(DefaultIntervalCategoryDataset dataset) {
CategoryAxis domainAxis = new CategoryAxis("Percentiles");
NumberAxis rangeAxis = new NumberAxis("ms1");
IntervalBarRenderer renderer = new IntervalBarRenderer();
rendererSettings(renderer);
CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis,renderer);
JFreeChart chart = new JFreeChart("Percentiles", plot);
ChartUtilities.applyCurrentTheme(chart);
return chart;
}
private static void rendererSettings(IntervalBarRenderer renderer){
renderer.setItemLabelFont(new Font("Verdana",Font.PLAIN,8));
renderer.setBaseItemLabelGenerator(new IntervalCategoryItemLabelGenerator());
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));
renderer.setItemMargin(0.1);
renderer.setBaseItemLabelsVisible(true);
}
public static JPanel createDemoPanel() {
JFreeChart chart = createChart(createDataset1());
return new ChartPanel(chart);
}
public static void main(String[] args) {
JFrame demo = new IntervalBarChartTest0(
"Testing");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}