need help with XYZDataSet

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
miladirooni
Posts: 24
Joined: Fri Sep 04, 2009 10:28 am
antibot: No, of course not.

need help with XYZDataSet

Post by miladirooni » Tue Jun 22, 2010 12:53 pm

Hi everyone,

I am trying to do some plot using XYZ Dataset but Im stuck. i am reading data from a file here is my code:

Code: Select all

public static XYZDataset createDataset() {

        JpowderInternalframe inFocus = Jpowder.internalFrameInFocus;

        DefaultXYZDataset dataset = new DefaultXYZDataset();


        for (int i = 0; i < inFocus.getXYPlot().getDatasetCount(); i++) {

            XYDataset ds = inFocus.getXYPlot().getDataset(i);
            double[][] data = new double[3][ds.getItemCount(i)];
            for (int j = 0; j < ds.getItemCount(i); j++) {

                data[0][j] = (Double) inFocus.getPowderDataSet().elementAt(i).getX().get(j);//x
                data[1][j] = Jpowder_Reader.getLocalData().get(i).get(1);//x reading from Jpowder File
                data[2][j] = (Double) inFocus.getPowderDataSet().elementAt(i).getY().get(j);//Colour

            }
            dataset.addSeries("Serie " + i, data);

        }

        return dataset;
    }
However I am getting gap between each series. what I am trying to do is to get first series extend from 0 to 10 and the
second series to be extended from 10 to 20.

Image

Anyone has any Idea to over come this problem.

Cheers

miladirooni
Posts: 24
Joined: Fri Sep 04, 2009 10:28 am
antibot: No, of course not.

Re: need help with XYZDataSet

Post by miladirooni » Thu Jun 24, 2010 1:22 pm

any idea is welcome.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: need help with XYZDataSet

Post by paradoxoff » Tue Jun 29, 2010 7:34 am

You haven´t specified the renderer you are using but I guess it is an XYBlockRenderer.
Call

Code: Select all

renderer.setBlockHeight(10);
Then, in order to cover the space between 0 and 10, you need to make sure that the block is not centered at an y value of 0 but starts at a y valkue of 0.
To achieve that, call

Code: Select all

renderer.setBlockAnchor(RectangleAnchor.BOTTOM);

miladirooni
Posts: 24
Joined: Fri Sep 04, 2009 10:28 am
antibot: No, of course not.

Re: need help with XYZDataSet

Post by miladirooni » Wed Jun 30, 2010 9:57 am

Sweet Tanx

Locked