使用JFreeChart散点图是否可以细分数据集的样式? [英] Using JFreeChart Scatter Plots is there a Way to Subdivide Styles for Data Sets?

查看:54
本文介绍了使用JFreeChart散点图是否可以细分数据集的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JFreeChart绘制具有数千个数据点的散点图.我通过将合适的XYLineAndShapeRendererper附加到每个数据集来控制每个ScatterPlotDataset的外观/样式;例如.数据集1中的点显示为圆形,数据集2中的点显示为正方形.我希望用户能够在每个数据集中为每个点动态分配一个子样式.例如.如果数据集是书籍,则用户可能希望将小说颜色设置为蓝色,将非小说类颜色设置为红色.有没有一种方法可以为每个子样式定义新的数据集呢?

I am using JFreeChart to render a scatter plot with a couple thousand data points. I control the appearance/style of each ScatterPlotDataset by attaching a suitable XYLineAndShapeRendererper to each data set; eg. points in data set 1 appear as circles and points in data set 2 appear as squares. I would like the user to be able to dynamically assign a sub-style per point in each data set; eg. if the data set were books then the user might wish to color fiction blue and nonfiction red. Is there a way to do this without defining a new data set for each sub style?

顺便说一句,我使用XYPlot进行购物,但如有必要,我可以切换到另一种图表类型.

Incidentally I am carting with XYPlot but I can switch to another chart type if necessary.

谢谢.

推荐答案

您可以考虑提到的方法第一DrawingSupplier实施为显示这里:

You might consider the approaches mentioned here. The first implements DrawingSupplier, as shown here:

class DefaultDrawingSupplier implements DrawingSupplier…

扩展了,如此处所示,以达到类似的效果.

The second extends DefaultDrawingSupplier, as shown here, to achieve a similar effect.

Paint[] paintArray = {…};
plot.setDrawingSupplier(new DefaultDrawingSupplier(
    paintArray, …
    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

当然,您始终可以覆盖getItemPaint(),如此处所示.

Of course, you can always override getItemPaint(), as shown here.

这篇关于使用JFreeChart散点图是否可以细分数据集的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆