Contour chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
chinmay
Posts: 4
Joined: Wed Jul 16, 2008 5:47 pm

Contour chart

Post by chinmay » Thu Jul 17, 2008 5:27 pm

Hi,

Can you please suggest me how i draw Contour Chart in Jfree.
And, I have retrive almost 3 lacs record retrive from database and want to plot the Contour chart, can Jfree support it?
I have Xmm for x value, Ymm for y value, and sufrace Area data for z value. All values are in double.

these are some sample data of Xmm and ymm and surface area what i retrive from the database.
X(MM) Y(MM) surfaceArea
-85.4965 -85.4965 0
-85.1792 -85.4965 0
-84.862 -85.4965 0
-84.5447 -85.4965 0
-84.2275 -85.4965 0.12
-83.9103 -85.4965 0.12
-83.593 -85.4965 0.14
-83.2758 -85.4965 0


in coding that surfaceArea, now i am using--surfaceArea = Math.sqrt((Xmm*Xmm)+(Ymm*Ymm));

but suggest me what value i take for z (i.esurfaceArea = Math.sqrt((Xmm*Xmm)+(Ymm*Ymm)) or z =0(what ever vaue get from database)

I am doing this code for contour chart, please suggest me whether it is correct or not.
If it is wrong please tell me the code, how i plot that chart.
thanks in advance for replying....

List patternatorRadar= new BenchTestHandler().patternatorRadialDistribution(testId,chart[3]);
LOGGER.debug("PatternatorChartCmd .. " + patternatorRadar.size());

chartName = "Mean Contour Profile";
DefaultXYZDataset xyzdataset = new DefaultXYZDataset();
double[][] data = new double[3][patternatorRadar.size()];
if(patternatorRadar.size()!=0){
itr = patternatorRadar.iterator();

//while(itr.hasNext()){
for(int i=0;i<patternatorRadar.size();i++){
PatternatorChartEntity patternatorChartEntity = (PatternatorChartEntity) itr.next();
double Xmm;
double Ymm;
double surfaceArea;
try {
Xmm = Double.parseDouble(patternatorChartEntity.getXmm().toString());
Ymm = Double.parseDouble(patternatorChartEntity.getYmm().toString());
//surfaceArea = Double.parseDouble(patternatorChartEntity.getSurfaceArea().toString());
surfaceArea = Math.sqrt((Xmm*Xmm)+(Ymm*Ymm));
//LOGGER.debug("PatternatorChartCmd .. " + Xmm +","+ Ymm+","+surfaceArea);
} catch (NumberFormatException e) {
continue;
}
data[0]= Xmm;
data[1]= Ymm;
data[2]= surfaceArea;

xyzdataset.addSeries("Series"+i,data);

}

//path,dataset,title,x-axix
buildRadarLineChart(patternatorChartPath3,xyzdataset,"Radar chart");


private static void buildRadarLineChart (String path,XYZDataset dataset,String Title){
LOGGER.debug("Hi inside buildRadarLineChart");
NumberAxis xAxis = new NumberAxis("x Axis");
NumberAxis yAxis = new NumberAxis("y Axis");


XYBlockRenderer r = new XYBlockRenderer();
LookupPaintScale ps = new LookupPaintScale(0,101,Color.lightGray);
ps.add(0.0,Color.green);
ps.add(10,Color.blue);
LOGGER.debug("Hi inside buildRadarLineChart1");
r.setPaintScale(ps);
//r.setBlockHeight(0.75f);
//r.setBlockWidth(0.75f);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, r);
// plot.setRenderer(r);
// JFreeChart chart = new JFreeChart("Chart Title",JFreeChart.DEFAULT_TITLE_FONT,plot,true);
//chart.addLegend(new LegendTitle(r));
//chart.setBackgroundPaint(Color.white);
//return chart;
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinePaint(Color.blue);
plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
plot.setOutlinePaint(Color.blue);
JFreeChart chart = new JFreeChart(Title, plot);
LOGGER.debug("Hi inside buildRadarLineChart2");
chart.removeLegend();
//NumberAxis scaleAxis = new NumberAxis("Scale");
//scaleAxis.setAxisLinePaint(Color.red);
//scaleAxis.setTickMarkPaint(Color.red);
//scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7));
// PaintScaleLegend legend = new PaintScaleLegend(new LookupPaintScale(),scaleAxis);
//legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
// legend.setAxisOffset(5.0);
LOGGER.debug("Hi inside buildRadarLineChart3");
//legend.setMargin(new RectangleInsets(5, 5, 5, 5));
// legend.setFrame(new BlockBorder(Color.red));
// legend.setPadding(new RectangleInsets(10, 10, 10, 10));
// legend.setStripWidth(10);
// legend.setPosition(RectangleEdge.RIGHT);
// legend.setBackgroundPaint(new Color(120, 120, 180));
// chart.addSubtitle(legend);
//chart.setBackgroundPaint(new Color(180, 180, 250));
chart.setBackgroundPaint(Color.WHITE);
LOGGER.debug("Hi inside buildRadarLineChart4");

try {
ChartUtilities
.saveChartAsPNG(new File(Resource.getApplicationContext().getRealPath(path)),chart,700,500);
} catch (IOException e) {
LOGGER.debug(e.getMessage());
}
LOGGER.debug("Hi chartPath " + path);

}

Please reply me as soon as possible.

Thanks
chinmay

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Jul 17, 2008 9:19 pm

It's generally not worth posting big blobs of code unless they're stand-alone programs that I can run against the latest version of JFreeChart. I generally go through the forum questions pretty quickly, and trying to decipher code which is incomplete isn't worth the effort.

Just on the basis of your dataset description, you should have a look at the XYBlockRenderer.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

chinmay
Posts: 4
Joined: Wed Jul 16, 2008 5:47 pm

Contour chart

Post by chinmay » Sat Jul 19, 2008 1:47 pm

Thanks for reply,

Can you please give me some sample coding of XYRenderer ,or how i create the dataset of this chart.and how i give x,y,z value to create dataset.

thanks,
chinmay

Locked