Multiple Axis Problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Birgi
Posts: 21
Joined: Mon Mar 14, 2005 9:09 pm

Post by Birgi » Wed Mar 23, 2005 6:37 pm

David,

I also tried to call the method setLinesVisible(true), but I still cannot see the lines. I still have the above chart and above code. Am I missing some point?

Thanks a lot

Birgi

Guest

Post by Guest » Wed Apr 06, 2005 11:24 pm

Birgi wrote:David,

Sorry for bothering you this much, but I still have a problem. My code for creating the chart is as follows;

Code: Select all

		chart = ChartFactory.createBarChart(
											 criteria + " Grafiği",		// chart title
											 "Ürünler", 				// domain axis label
											 criteria, 					// range axis label
											 dataset, 					// data
								ass			 PlotOrientation.VERTICAL, 
											 false, 					// include legend
											 true,						// tooltips?
											 false						// URLS?
											);
		chart.setBackgroundPaint(Color.lightGray);
		// creating the secondary chart & secondary axis
		CategoryPlot plot = chart.getCategoryPlot();
		NumberAxis axis2 = new NumberAxis("Satış Yüzdesi");
		plot.setRangeAxis(1, axis2);
		plot.setDataset(1, secondaryDataset);
		plot.setRenderer(1, new LineAndShapeRenderer()); 
		plot.mapDatasetToRangeAxis(1, 1);
Now the problem is, shapes for representing data points appear on the chart, but they are all on the same y-axis ( I mean on the same vertical line). I also cannot see any lines ( probably that's because of the data points).

Thanks a lot for your help.

Birgi

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 » Sat Apr 09, 2005 8:14 am

Birgi wrote:I also tried to call the method setLinesVisible(true), but I still cannot see the lines. I still have the above chart and above code. Am I missing some point?
In your dataset, I think you have many series each with just one item. But what you want is one series with many items.
David Gilbert
JFreeChart Project Leader

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

Guest

Post by Guest » Wed Apr 13, 2005 1:45 am

Image

i want to set the min value to start graph on y-axis.
here the

Code: Select all

public class ViewChartAction extends Action {

	public ActionForward execute(
			ActionMapping mapping, ActionForm form, HttpServletRequest req,
			HttpServletResponse res)
		throws Exception {

		try {
String period = req.getParameter("period");
			int id=0;
			id = Integer.parseInt(req.getParameter("id"));
CategoryDataset dataset = _getDataset(period,id);
	chart = ChartFactory.createLineChart(
									chartName, xName, yName, dataset,
									PlotOrientation.VERTICAL, true, false, false);
res.setContentType("image/jpeg");

			OutputStream out = res.getOutputStream();
        	ChartUtilities.writeChartAsJPEG(out, chart, 300, 250);
return mapping.findForward("/common/null.jsp");
		}
		catch (Exception e) {
			req.setAttribute(PageContext.EXCEPTION, e);

			return mapping.findForward("/common/error.jsp");
		}
	}

private CategoryDataset _getDataset(String period,int id) throws Exception {
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();

		String seriesName = "";
String yn= "name";

// getting values from database.
dataset.addValue(new Double(rs4.getString("Value")), seriesName, yn);


				}


		return dataset;


	}

}
-------------------
the graph comming as given the url above.

i want to start the graph from min value not from zero how to set the min value

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 Apr 13, 2005 7:05 am

You need something like:

Code: Select all

CategoryPlot plot = (CategoryPlot) chart.getPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
David Gilbert
JFreeChart Project Leader

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

sureshn

Post by sureshn » Wed Apr 13, 2005 11:35 pm

thats worked thanx

sureshn

x axis values any possibility to hide

Post by sureshn » Thu Apr 14, 2005 12:47 am

thanx david for your reply i have a small doubt
in my graph x axis have the values 1 to 52 , as per req i am doing graph small width and height so those no's are overlapping. can i hide that values.
cheers
nzsoori

Guest

Post by Guest » Wed Apr 20, 2005 10:08 pm

any suggestions for above question plz

sureshn

x-axis values want to hide

Post by sureshn » Fri Apr 22, 2005 6:04 am

hi david plz give a hand
in my graph x axis have the values 1 to 52 , as per req i am doing graph small width and height so those numbers are overlapping. can we hide that values.
when i tried like this yn=""
graph itself is not comming


DefaultCategoryDataset dataset = new DefaultCategoryDataset();

String seriesName = "";
String yn= "name";

// getting values from database.
dataset.addValue(new Double(rs4.getString("Value")), seriesName, yn);

so i figured same name,seriesname thays why :cry:
if i dont want to show x axis values how to hide

cheers
suresh

Locked