JFree图表选择点厚度

JFree图表选择点厚度

本文介绍了JFree图表选择点厚度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jfree图表以图形方式显示指标,现在我正在研究一种解决方案,该解决方案将XY折线图中的图形元素随机化以使图形看起来更平滑.问题是我不希望随机元素具有相同的厚度作为实际值,实际上我不需要任何与它们相关的厚度.有没有一种方法可以有选择地指定点的厚度.我目前正在使用XYLineAndShapeRenderer渲染点的厚度.

I am using jfree chart for graphically displaying metrics.Now I am working on a solution which randomizes graph elements in an XY line chart so that the graph looks smoother.The problem is I dont want the random elements to get the same thickness as the real values,in fact I dont wan't any thickness associated with them.Is there a way to selectively specify point thickness.I am currently using XYLineAndShapeRenderer to render the point thickness.

推荐答案

您可以覆盖 getItemShapeVisible() 并安排它返回false作为虚假点.您可以使用XYZDataset的实现将决策所需的额外信息存储在数据模型中.

You can override getItemShapeVisible() and arrange for it to return false for the spurious points. You can store the extra information required for the decision in your data model using an implementation of XYZDataset.

作为替代方案,在呈现数据之前,请考虑使数据平滑.此类过滤器通常会导致更少点,从而简化了渲染.

As an alternative, consider smoothing the data before rendering it. Such filters typically result in fewer points, which simplifies rendering.

无论哪种情况,请避免混淆或误导数据更改.显示了 TextTitle 此处,可以澄清结果.

In either case, avoid confusing or misleading changes to the data. A TextTitle, shown here, may clarify the result.

附录:getItemShapeVisible()告诉正在考虑的seriesitem.默认实现只是询问getSeriesShapesVisible().这是一个大纲:

Addendum: getItemShapeVisible() tells you what series and item is under consideration. The default implementation simply asks getSeriesShapesVisible(). Here's an outline:

private static class MyRenderer extends XYLineAndShapeRenderer {

    @Override
    public boolean getItemShapeVisible(int series, int item) {
        System.out.println(series + ":" + item);
        if (item % 2 == 0) return false;
        else return super.getItemShapeVisible(series, item);
    }
}

附录:这是安装方法:

XYPlot plot = chart.getXYPlot();
MyRenderer renderer = new MyRenderer();
plot.setRenderer(renderer);

这篇关于JFree图表选择点厚度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:36