Urgent Help JFreeChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jesusmgmarin
Posts: 13
Joined: Thu Apr 20, 2006 2:24 pm
Location: Spain
Contact:

Urgent Help JFreeChart

Post by jesusmgmarin » Wed Jul 05, 2006 10:03 am

Hello I need modify a chart generate. I use jfreechart-1.0.0.jar.
I have crateed a graph with a series of values,
Image
but now I need to change my Y-axis, The graphs must show in depth. That is to say, in the Y-axis the Depth goes. The highest value of the Y-axis corresponds with value 0 and the values will grow downwards.

How can I do this??
I post my code for help:

Code: Select all

public JFreeChart XYLine2(String vInDep, String vDep){
     XYSeries series = new XYSeries("Leyenda de Línea");

     /*[b]arrayVars [/b]is a global variable that contains two columns and several rows. It contains the data to represent in the chart */
     for (int i=0; i<arrayVars.length; i++){
          if( (null != arrayVars[i][0]) && (null != arrayVars[i][1]) ){
               float x= Float.parseFloat(arrayVars[i][0]);
               float y= Float.parseFloat(arrayVars[i][1]);
               series.add(x,y);	
          }
     }
		
     XYDataset ColeccionDatos = new XYSeriesCollection(series);
	
     JFreeChart graph = ChartFactory.createXYLineChart(
          vDep+" vs "+vInDep,	//Tittle
          vInDep,		//X-axis
          vDep,		//Y-axis
          ColeccionDatos,	//Dataset
          PlotOrientation.HORIZONTAL,	//Orientation	
          false,     //Flag legend
          true,      //Flag tooltip
          false      //Flag URLs
     );
		
     return graph;
}

THANKS VERY MUCH;

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 » Wed Jul 05, 2006 1:13 pm

I think you just need something like:

Code: Select all

XYPlot plot = (XYPlot) graph.getPlot();
NumberAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setInverted(true);
David Gilbert
JFreeChart Project Leader

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

jesusmgmarin
Posts: 13
Joined: Thu Apr 20, 2006 2:24 pm
Location: Spain
Contact:

Post by jesusmgmarin » Wed Jul 05, 2006 6:25 pm

Ok, but This change the X axis, no? How can I change the Y Axis ??

jesusmgmarin
Posts: 13
Joined: Thu Apr 20, 2006 2:24 pm
Location: Spain
Contact:

Post by jesusmgmarin » Fri Jul 07, 2006 4:32 pm

jesusmgmarin wrote:Ok, but This change the X axis, no? How can I change the Y Axis ??
I have solved this:

Code: Select all

XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis();
rangeAxis.setInverted(true);
Thanks

Sir Henry
Posts: 7
Joined: Mon Jun 26, 2006 3:29 pm

Post by Sir Henry » Fri Jul 07, 2006 4:39 pm

Add a line:

Code: Select all

developer.setConfused(true);
:D (sorry I could not resist) :D
Cheers, Sir Henry

Locked