Multiple Axis Problem
Birgi wrote:David,
Sorry for bothering you this much, but I still have a problem. My code for creating the chart is as follows;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).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);
Thanks a lot for your help.
Birgi
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
In your dataset, I think you have many series each with just one item. But what you want is one series with many items.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?
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


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
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
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
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


x axis values any possibility to hide
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
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
x-axis values want to hide
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
if i dont want to show x axis values how to hide
cheers
suresh
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

if i dont want to show x axis values how to hide
cheers
suresh