如何从数据库中获取值并插入JFreeChart中的getItemShape()?

时间:2013-04-09 14:20:20

标签: java jsp jfreechart

我想将mealltvalue的值输入getItemShape()方法。 mealltvalue来自JSON对象,即它来自数据库。使用这个mealltvalue我必须使用if和else循环检查条件。

String mealsltvalue = jsonObject.getString("mealslot");

final  XYPlot xyplot = (XYPlot)chart.getPlot();
XYLineAndShapeRenderer renderer =  new XYLineAndShapeRenderer(true,true)
{
    Shape ellipse = new Ellipse2D.Double(-3.0,-3.0,8.0,8.0);
    Shape upTriangle = ShapeUtilities.createUpTriangle(4.0f);

    public Shape getItemShape(int row, int column)
    {           

        Double value = (Double)xyplot.getDataset(0).getY(row,column);


        if (mealsltvalue .equalsIgnoreCase("Before Meal"))
        {
            return ellipse;
        }
        else
        {
            return upTriangle;
        }       

    }
};
xyplot.setRenderer(renderer);  

0 个答案:

没有答案