gpt4 book ai didi

java - IntervalBarRenderer : Displaying specific information inside the bar

转载 作者:行者123 更新时间:2023-11-30 07:56:32 24 4
gpt4 key购买 nike

DefaultIntervalCategoryDataset 中,我想在条内显示区间范围信息。我想舍弃下图圈出的信息,只显示区间值。

image

下面是代码。如何只显示区间值?

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);
}

}

最佳答案

这是默认 IntervalCategoryItemLabelGenerator 的一个特性. DEFAULT_LABEL_FORMAT_STRING指定以下 MesageFormat值(value)观:

`"({0}, {1}) = {3} - {4}"`

含义由createItemArray()定义.您可能想要这样的东西而不是默认值:

renderer.setBaseItemLabelGenerator(
new IntervalCategoryItemLabelGenerator(
"{2}", NumberFormat.getNumberInstance()));

image

关于java - IntervalBarRenderer : Displaying specific information inside the bar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42050871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com