Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Chart:PostProcessor ---Plz help

2012-05-10
2013-01-13
  • I am trying to change the plot background color of the XY chart from grey to  blue..please help me soon
    I am using it in Struts1.2

    The JSP

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
        <%@taglib uri="http://cewolf.sourceforge.net/taglib/cewolf.tld"  prefix="cewolf"%>  
    <%@page import="de.laures.cewolf.taglib.*" %>
    <%@page import="de.laures.cewolf.taglib.util.*" %>
    <%@page import="de.laures.cewolf.jfree.*" %>
    <%@page import="org.jfree.chart.*" %>
    <%@page import="org.jfree.chart.JFreeChart" %>
    <%@page import="org.jfree.chart.plot.Plot" %>
    <%@page import="org.jfree.chart.plot.XYPlot" %>
    <%@page import="org.jfree.chart.renderer.category.*" %>
    <%@page import="org.jfree.chart.renderer.xy.*" %>
    <%@page import="org.jfree.data.*"%>
    <%@page import="org.jfree.data.category.CategoryDataset" %>
    <%@page import="org.jfree.data.time.*"%>
    <%@page import="org.jfree.data.xy.XYDataset" %>
    <%@page import="java.awt.Color" %>
    <%@page import="java.text.DateFormat" %>
    <%@page import="java.text.SimpleDateFormat" %>
    <%@page import="java.util.Date"%>
    <%@page import="java.util.HashMap"%>
    <%@page import="java.util.Map"%>
    <%@page import="de.laures.cewolf.*"%>

    <%@page import="de.laures.cewolf.links.XYItemLinkGenerator" %>
    <%@page import="de.laures.cewolf.tooltips.XYToolTipGenerator" %>
    <%@page import="diptesh.MyChartPostProcessor" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <jsp:useBean id="lineRenderer" class="de.laures.cewolf.cpp.LineRendererProcessor" />
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    MyChartPostProcessor graph=new MyChartPostProcessor();

    pageContext.setAttribute("postproducer",graph);
    %>
    <cewolf:chart id="timeChart" antialias="true" showlegend="true" xaxislabel="Year" yaxislabel="No of students" type="timeseries">
        <cewolf:colorpaint color="#EEEEFF"/>

        <cewolf:data>
            <cewolf:producer id="timeData"/>
        </cewolf:data>
     
        <cewolf:chartpostprocessor id="postproducer" />  
    </cewolf:chart>
    <cewolf:img chartid="timeChart" renderer="/cewolf" width="300" height="300">
    <cewolf:map tooltipgeneratorid="categoryToolTipGenerator"></cewolf:map>
    </cewolf:img>
    </body>
    </html>

    MyPostProcessor.java

    public class MyChartPostProcessor implements ChartPostProcessor
    {
    public void processChart(java.lang.Object object, java.util.Map map) {

    JFreeChart jfreechart = (JFreeChart) object;
    jfreechart.setBackgroundPaint(Color.BLUE);

    XYPlot categoryplot = (XYPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.BLUE);

    }
    }

    But nothing seems to change the color of the plot area…….