jfree图表在类别图上绘制图像 [英] jfree chart draw image on a category plot

查看:75
本文介绍了jfree图表在类别图上绘制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我有一个很奇怪的要求。我需要在类别图中的堆叠条形图旁边绘制箭头形的图像。根据某些预先定义的条件,箭头图像必须为红色或绿色。我只需要帮助找到一种使用jfree图表在绘图上的堆叠条形图之外绘制图像的方法。请帮助我,伙计们。坚持几天!!!!

Heyy folks I have a pretty strange requirement.I need to draw an arrow shaped image beside a stacked bar chart in a category plot .The arrow image has to be red or green depending on some pre defined condition.I just need help to find a method to draw an image outside the stacked bar on the plot using jfree chart.Please help me out with this guys .Being stuck with this for days !!!!

推荐答案

您可以实现 CategoryAnnotation 接口:

plot.addAnnotation(new CategoryAnnotation(){

   Image anImage = ImageIO.read(new File("anImage.jpg"));

   @Override
   public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis){

       int x = ...  // determine where you want to draw the image inside the dataArea rectangle
       int y = ...

       g2.drawImage(anImage, x, y, null);

   }
});

这篇关于jfree图表在类别图上绘制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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