java - How to draw a spiderchart above a existing JfreeChart -
i have 1 jfree chart can generate everytime run code. want override few more spider graphs on same chart. please me how
above need add 1 more spider chart using jfree.
here code doing chart.
package com.rectrix.exide.pdfbox; import java.awt.basicstroke; import java.awt.color; import java.awt.dimension; import java.awt.font; import java.awt.gradientpaint; import java.awt.paint; import java.awt.paintcontext; import java.awt.rectangle; import java.awt.renderinghints; import java.awt.geom.affinetransform; import java.awt.geom.rectangle2d; import java.awt.image.colormodel; import javax.swing.jpanel; import org.jfree.chart.chartpanel; import org.jfree.chart.chartutilities; import org.jfree.chart.jfreechart; import org.jfree.chart.axis.numberaxis; import org.jfree.chart.labels.standardcategorytooltipgenerator; import org.jfree.chart.plot.spiderwebplot; import org.jfree.chart.title.legendtitle; import org.jfree.chart.title.texttitle; import org.jfree.data.category.categorydataset; import org.jfree.data.category.defaultcategorydataset; import org.jfree.ui.*; public class demochart extends applicationframe { public demochart(string s) { super(s); jpanel jpanel = createdemopanel(); jpanel.setpreferredsize(new dimension(500, 270)); setcontentpane(jpanel); } private static categorydataset createdataset() { string s1 = "first"; string s2 = "second"; string s3 = "third"; string s4 = "forth"; string s5 = "fivth"; string s6 = "sixth"; string s7 = "seventh"; string s8 = "eighth"; string s9 = "ninth"; string s10 = "tenth"; defaultcategorydataset defaultcategorydataset = new defaultcategorydataset(); int count = 5; int value = 0; //string keyrow="s"; (int i=1;i<=10;i++){ value = i*4; comparable colkey = 0; string keyrow = "s"+i; for(int j=1;j<=count;j++){ colkey = j; defaultcategorydataset.addvalue(value, keyrow, colkey); } } return defaultcategorydataset; } public static jfreechart createchart1(categorydataset categorydataset,double d) { spiderwebplot plot = new spiderwebplot(categorydataset); color bckcolor1 = color.decode("#4282ce"); //light blue paint p = new gradientpaint(0, 1, bckcolor1, 0, 1, bckcolor1); plot.setseriespaint(p); jfreechart chart = new jfreechart("", plot); return chart; } public static jpanel createdemopanel() { jfreechart jfreechart = createchart1(createdataset(), 10d); return new chartpanel(jfreechart); } public static void main(string args[]) { demochart spiderwebchartdemo1 = new demochart("jfreechart: spiderwebchartdemo1.java"); spiderwebchartdemo1.pack(); refineryutilities.centerframeonscreen(spiderwebchartdemo1); spiderwebchartdemo1.setvisible(true); } }
please me possible need send build tomorrow thank u in advance helping , taking efforts see this.
i want override few more spider graphs on same chart.
it may examine how spider web plot used display multivariate data. simplified example below compares 2 observations
, each having 5 variables
named a .. e
, random values in range 1 .. 3
. chance, values variable b
coincide; rest differ. can adjust value of observations
see effect, result becomes progressively more muddled number of observations grows. may want alter series visibility, suggested here, or consider these alternatives.
import java.awt.eventqueue; import java.util.random; import javax.swing.jpanel; import org.jfree.chart.chartpanel; import org.jfree.chart.jfreechart; import org.jfree.chart.plot.spiderwebplot; import org.jfree.data.category.categorydataset; import org.jfree.data.category.defaultcategorydataset; import org.jfree.ui.applicationframe; /** @see https://stackoverflow.com/a/32885067/230513 */ public class spiderchart extends applicationframe { private static final int observations = 2; private static final int variables = 5; private static final random r = new random(); public spiderchart(string s) { super(s); add(createdemopanel()); } private static categorydataset createdataset() { defaultcategorydataset dataset = new defaultcategorydataset(); (int = 1; <= observations; i++) { string rowkey = "observation " + i; (int j = 1; j <= variables; j++) { comparable colkey = character.valueof((char)(j+64)); dataset.addvalue(r.nextint(3) + 1, rowkey, colkey); } } return dataset; } public static jfreechart createchart(categorydataset dataset) { spiderwebplot plot = new spiderwebplot(dataset); jfreechart chart = new jfreechart("test", plot); return chart; } public static jpanel createdemopanel() { jfreechart jfreechart = createchart(createdataset()); return new chartpanel(jfreechart); } public static void main(string args[]) { eventqueue.invokelater(() -> { spiderchart demo = new spiderchart("spiderwebchart"); demo.pack(); demo.setdefaultcloseoperation(exit_on_close); demo.setvisible(true); }); } }
Comments
Post a Comment