Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Devaka Cooray
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Jeanne Boyarsky
Tim Cooke
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Bartenders:
Forum:
Other Open Source Projects
Cewolf Legend coming twice
Ranjeeth Padi
Greenhorn
Posts: 8
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
cewolf charts color
CeWolf - SeriesPaintProcessor
Setting up maximum range for X and Y axis in CeWolf Chart
de.flaures.cewolf.PreProcessorException Error.
cewolfexample (cewolf-1.1-ulf)
More...