A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Products
»
Other Open Source Projects
Author
Cewolf Legend coming twice
Ranjeeth Padi
Greenhorn
Joined: May 02, 2011
Posts: 8
I like...
posted
May 13, 2011 03:29:23
0
Hi,
The legend is coming two times.
Also color of the line is mixed with two colors w.r.t the legend shown
Code:
1) DatasetProducer
package com.test.graph; import java.util.Date; import java.util.List; import java.util.Map; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import com.test.graph.DAO.InvokeQuery; import com.test.graph.bean.GraphBean; import de.laures.cewolf.DatasetProduceException; import de.laures.cewolf.DatasetProducer; import de.laures.cewolf.tooltips.XYToolTipGenerator; public class LineGraphDB implements DatasetProducer,XYToolTipGenerator{ public String getProducerId() { return "XYDataProducer"; } public boolean hasExpired(Map arg0, Date since) { return System.currentTimeMillis() - since.getTime() > 0L; } public Object produceDataset(Map arg0) throws DatasetProduceException { XYSeries series = new XYSeries("Bottom Text Here"); InvokeQuery iv = new InvokeQuery(); List<GraphBean> gbList = iv.getList(); for(GraphBean graphBean:gbList){ series.add(Double.parseDouble(graphBean.getX()),Double.parseDouble(graphBean.getY())); } XYSeriesCollection xyDataset = new XYSeriesCollection(series); xyDataset.addSeries(series); return xyDataset; } public String generateToolTip(XYDataset arg0, int arg1, int arg2) { return "(x="+arg0.getXValue(arg1, arg2)+",y="+arg0.getYValue(arg1, arg2)+")"; } }
2. 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.ChartPostProcessor"%> <%@page import="com.test.graph.chartprocessor.ColorProcessor"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Line Graph</title> </head> <% ChartPostProcessor postprocessor = new ColorProcessor(); pageContext.setAttribute("postprocessor", postprocessor); %> <body> <jsp:useBean id="lineGraph" class="com.test.graph.LineGraphDB" /> <cewolf:chart id="XYChart" title="XYChart" type="xy" xaxislabel="X-axis" yaxislabel="Y-axis"> <cewolf:data> <cewolf:producer id="lineGraph" /> </cewolf:data> <cewolf:chartpostprocessor id="postprocessor"> <cewolf:param name="bgColor" value="#FFFFFF"></cewolf:param> </cewolf:chartpostprocessor> </cewolf:chart> <cewolf:img chartid="XYChart" renderer="cewolf" width="500" height="400"> <cewolf:map tooltipgeneratorid="lineGraph" /> </cewolf:img> </body> </html>
3.ChartPostProcessor
package com.test.graph.chartprocessor; import java.awt.Color; import java.io.Serializable; import java.util.Map; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import de.laures.cewolf.ChartPostProcessor; public class ColorProcessor implements ChartPostProcessor,Serializable{ private static final long serialVersionUID = -8825255492688438972L; public void processChart(Object chart, @SuppressWarnings("rawtypes") Map arg1) { JFreeChart jchart = (JFreeChart)chart; XYPlot categoryplot = jchart.getXYPlot(); //Graph BackGround color categoryplot.setBackgroundPaint(Color.decode((String) arg1.get("bgColor"))); //Horizontal Line Color categoryplot.setRangeGridlinePaint(Color.black); //Vertical Line Color categoryplot.setDomainGridlinePaint(Color.black); //Line Color categoryplot.getRenderer().setSeriesPaint(0, Color.BLACK); //Removing decimal Value on y axis NumberAxis rangeAxis = (NumberAxis) categoryplot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) categoryplot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } }
cewolf;jsessionid=5B31974CB5A168AA39037666592BE31D.png
Picture
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Cewolf Legend coming twice
Similar Threads
Setting up maximum range for X and Y axis in CeWolf Chart
cewolf charts color
CeWolf - SeriesPaintProcessor
cewolfexample (cewolf-1.1-ulf)
de.flaures.cewolf.PreProcessorException Error.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter