Monday, 15 August 2011

java - Code difference between jfreechart XYLineAndShaperanderer, XYDotRenderer and XYSplineRenderer? -



java - Code difference between jfreechart XYLineAndShaperanderer, XYDotRenderer and XYSplineRenderer? -

i'm trying create simple xysplinerenderer, code work if write xydotrenderer = new xydotrenderer(); or xylineandshaperenderer = new xylineandshaperenderer(); can sameone tell wrong? i'm beginner in programming.

here code:

package kubas; import org.jfree.chart.*; import org.jfree.chart.axis.*; import org.jfree.chart.plot.*; import org.jfree.chart.renderer.xy.xysplinerenderer; import org.jfree.data.xy.*; import org.jfree.ui.applicationframe; public class spausdink { public static void main(string[] args) { xyseries series = new xyseries("xy grafikas"); series.add(1, 2); series.add(2, 4); series.add(3, 8); series.add(4, 16); series.add(5, 32); series.add(6, 64); series.add(7, 128); series.add(8, 256); series.add(9, 512); series.add(10, 1024); xyseriescollection dataset = new xyseriescollection(); dataset.addseries(series); applicationframe frame = new applicationframe("mano grafikas"); numberaxis xax = new numberaxis("x"); numberaxis yax = new numberaxis("y"); xysplinerenderer = new xysplinerenderer(); a.setprecision(10); xyplot xyplot = new xyplot(dataset, xax, yax, a); jfreechart chart = new jfreechart(xyplot); chartpanel chartpanel = new chartpanel(chart); frame.setcontentpane(chartpanel); frame.pack(); frame.setvisible(true); } }

edited message:

both codes work properly, created new project.

i'm not sure what's wrong, there's working illustration below. tend take little odd values precision; default 5. same code works xylineandshaperenderer or

xydotrenderer r = new xydotrenderer(); r.setdotwidth(5); r.setdotheight(5);

import java.awt.dimension; import java.awt.eventqueue; import javax.swing.jframe; import org.jfree.chart.*; import org.jfree.chart.axis.*; import org.jfree.chart.plot.*; import org.jfree.chart.renderer.xy.xysplinerenderer; import org.jfree.data.xy.*; public class test { public static final string title = "f(x) = 2^x"; public static void main(string[] args) { eventqueue.invokelater(new runnable() { @override public void run() { display(); } }); } private static void display() { xyseries series = new xyseries(title); (int = 0; <= 10; i++) { series.add(i, math.pow(2, i)); } xyseriescollection dataset = new xyseriescollection(); dataset.addseries(series); numberaxis domain = new numberaxis("x"); numberaxis range = new numberaxis("f(x)"); xysplinerenderer r = new xysplinerenderer(3); xyplot xyplot = new xyplot(dataset, domain, range, r); jfreechart chart = new jfreechart(xyplot); chartpanel chartpanel = new chartpanel(chart){ @override public dimension getpreferredsize() { homecoming new dimension(640, 480); } }; jframe frame = new jframe(title); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.add(chartpanel); frame.pack(); frame.setlocationrelativeto(null); frame.setvisible(true); } }

java charts jfreechart

No comments:

Post a Comment