How to rotate categories in linechart. urgent!!!!
How to rotate categories in linechart. urgent!!!!
Hi
Can anyone please help me with these questions. I am trying to plot a line chart. Is there anyway we can rotate the values in horizontal axis so that if there are long values they don't overlap. Also, Is there a way we can show a tooltip if a user moves the mouse over the point plotted in the graph. I would really appreciate any responses.
Thanks
Praveena
Can anyone please help me with these questions. I am trying to plot a line chart. Is there anyway we can rotate the values in horizontal axis so that if there are long values they don't overlap. Also, Is there a way we can show a tooltip if a user moves the mouse over the point plotted in the graph. I would really appreciate any responses.
Thanks
Praveena
Re: How to rotate categories in linechart. urgent!!!!
Here's some code to rotate the category labels by 90 degrees:
LinePlot plot = (LinePlot)chart.getPlot();
...
HorizontalCategoryAxis axis = (HorizontalCategoryAxis)plot.getDomainAxis();
axis.setVerticalCategoryLabels(true);
The demo program has tooltips enabled for the line chart, so try it out and take a look through the source code...
Regards,
Dave Gilbert
LinePlot plot = (LinePlot)chart.getPlot();
...
HorizontalCategoryAxis axis = (HorizontalCategoryAxis)plot.getDomainAxis();
axis.setVerticalCategoryLabels(true);
The demo program has tooltips enabled for the line chart, so try it out and take a look through the source code...
Regards,
Dave Gilbert
Re: How to rotate categories in linechart. urgent!!!!
Thanks Dave
I tried to include the code you mentioned. I got a compilation error as follows.
LineChartServlet.java:69: Method getDomainAxis() not found in class com.jrefiner
y.chart.LinePlot.
HorizontalCategoryAxis axis = (HorizontalCategoryAxis)plot.getDo
mainAxis();
^
1 error
Could you please help me with this. Also could you be more specific where I can find the tool tips for lline chart.
I tried to include the code you mentioned. I got a compilation error as follows.
LineChartServlet.java:69: Method getDomainAxis() not found in class com.jrefiner
y.chart.LinePlot.
HorizontalCategoryAxis axis = (HorizontalCategoryAxis)plot.getDo
mainAxis();
^
1 error
Could you please help me with this. Also could you be more specific where I can find the tool tips for lline chart.
Re: How to rotate categories in linechart. urgent!!!!
At some point I changed the method getCategoryAxis() to getDomainAxis(), so if the latter isn't working try the former.
I'm going to spend some time documenting the tooltips code soon. Until then you would be best to look through the JFreeChartPanel source code, which draws charts with tooltips enabled by default.
Regards,
DG.
I'm going to spend some time documenting the tooltips code soon. Until then you would be best to look through the JFreeChartPanel source code, which draws charts with tooltips enabled by default.
Regards,
DG.
Re: How to rotate categories in linechart. urgent!!!!
getCategoryAxis() is working fine. I tried to use JFreeChartPanel to set the tooltip generation true. the code is as follows:
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
JFreeChart chart = createChart();
JFreeChartPanel JFCP= new JFreeChartPanel(chart);
int width = 0;
int height = 0;
try {
JFCP.setToolTipGeneration(true);
width=JFCP.DEFAULT_WIDTH;
height=JFCP.DEFAULT_HEIGHT;
width = Integer.parseInt( request.getParameter( "width" ) );
height = Integer.parseInt( request.getParameter( "height" ) );
}
catch (Exception e) {
}
OutputStream out = response.getOutputStream();
ChartUtilities.writeChartAsJPEG(out, JFCP.getChart(), width, height);
out.close();
}
The image is taking the default width from the JFreeChartPanel but it is not generating the tool tip. Am I missing something in here. Could you please help me out here.
Thanks
Praveena
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
JFreeChart chart = createChart();
JFreeChartPanel JFCP= new JFreeChartPanel(chart);
int width = 0;
int height = 0;
try {
JFCP.setToolTipGeneration(true);
width=JFCP.DEFAULT_WIDTH;
height=JFCP.DEFAULT_HEIGHT;
width = Integer.parseInt( request.getParameter( "width" ) );
height = Integer.parseInt( request.getParameter( "height" ) );
}
catch (Exception e) {
}
OutputStream out = response.getOutputStream();
ChartUtilities.writeChartAsJPEG(out, JFCP.getChart(), width, height);
out.close();
}
The image is taking the default width from the JFreeChartPanel but it is not generating the tool tip. Am I missing something in here. Could you please help me out here.
Thanks
Praveena
Re: How to rotate categories in linechart. urgent!!!!
The tooltips only work when you display the JFreeChartPanel in a client application. Since you are working with servlets, and your end-user is just looking at an image in a web browser, the tooltips mechanism isn't going to do anything for you.
Regards,
Dave Gilbert.
Regards,
Dave Gilbert.
Re: How to rotate categories in linechart. urgent!!!!
Is there any other way I can make the graph more informative. What I see now in the graph are lines with points on them. I can't figure the data by looking at the points. So is there a way I can come up with a meaningful scale on x and y-axis, or a grid etc...so that a user can make out the values by looking at the points.
Thanks
Praveena
Thanks
Praveena
Re: How to rotate categories in linechart. urgent!!!!
Hi,
I haven't done this yet but I intend to -- I think you can take the ToolTip info to get the boundary coordinates of each marker (for a line chart) or bar or pieslice, and then use it to create an html image map. You can then format the range and domain into some text and supply that to the ALT tag or maybe the onMouseOver tag. Maybe someone else has already done this and can comment. I will post my results when I get around to doing it.
regards,
Jim McLaughlin
I haven't done this yet but I intend to -- I think you can take the ToolTip info to get the boundary coordinates of each marker (for a line chart) or bar or pieslice, and then use it to create an html image map. You can then format the range and domain into some text and supply that to the ALT tag or maybe the onMouseOver tag. Maybe someone else has already done this and can comment. I will post my results when I get around to doing it.
regards,
Jim McLaughlin
Re: How to rotate categories in linechart. urgent!!!!
Jim,
That sounds great! Let me know if you have any suggestions for improving the tooltip implementation - what's there is a first cut, I'm sure it could be made better.
Regards,
DG.
That sounds great! Let me know if you have any suggestions for improving the tooltip implementation - what's there is a first cut, I'm sure it could be made better.
Regards,
DG.
Re: How to rotate categories in linechart. urgent!!!!
> So is there a way I can come up with a meaningful scale on x and y-axis, or a grid etc...so that a user can make out the values by looking at the points.
Perhaps you should post the code that you are using to create the chart. By default, your vertical axis should show the scale, and it should also have gridlines to help match the data points to the axis. You won't be able to tell the *exact* data values, but you should have an idea of what they are.
Regards,
DG.
Perhaps you should post the code that you are using to create the chart. By default, your vertical axis should show the scale, and it should also have gridlines to help match the data points to the axis. You won't be able to tell the *exact* data values, but you should have an idea of what they are.
Regards,
DG.
Re: How to rotate categories in linechart. urgent!!!!
Thanks Jim
Image maps are quite new to me and you need to help me on this. Could you please email me the code if you come up with something about the tool tip.
Thanks Dave
As you said there is a scale on vertical axis but with difference of five like (150,155,160,165 etc....) . That makes hard for me to read a value like 157 etc.. because it is in between two lines and I can hardly make the difference. Is there a way I can setup a scale with difference of one like(150,151,152,etc..). Also there is a grid with only horizontal lines, there are no vertical lines. Should I set something to get that done.
Thanks
Praveena
Image maps are quite new to me and you need to help me on this. Could you please email me the code if you come up with something about the tool tip.
Thanks Dave
As you said there is a scale on vertical axis but with difference of five like (150,155,160,165 etc....) . That makes hard for me to read a value like 157 etc.. because it is in between two lines and I can hardly make the difference. Is there a way I can setup a scale with difference of one like(150,151,152,etc..). Also there is a grid with only horizontal lines, there are no vertical lines. Should I set something to get that done.
Thanks
Praveena
Re: How to rotate categories in linechart. urgent!!!!
You can set your own tick values (rather that let the axis choose one automatically) with the setTickUnit(...) method in the NumberAxis class. The downside is that the tick labels might overlap each other.
There are no gridlines on category axes, only the numerical (and date) axes. Take a look at the categories you are using - a lot of people have been using the LinePlot class when they would be better off using XYPlot (especially where the "categories" are some measure of time like days, months etc.).
Regards,
DG.
There are no gridlines on category axes, only the numerical (and date) axes. Take a look at the categories you are using - a lot of people have been using the LinePlot class when they would be better off using XYPlot (especially where the "categories" are some measure of time like days, months etc.).
Regards,
DG.