Help XYLineAndShapeRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Otacon94
Posts: 2
Joined: Thu Aug 24, 2017 7:16 pm
antibot: No, of course not.

Help XYLineAndShapeRenderer

Post by Otacon94 » Thu Aug 24, 2017 11:55 pm

Hi! I have a problem with my Java application. I use JFreeChart to display some statistics. I use the XYLineChart but I wanted to modify a little bit the size of the line and to add a shape to the points of the series. I thought to use the XYLineAndShapeRenderer but when I use it, when I enter the points with the mouse, I didn't have the ItemLabel (which I need to have) of the Point anymore. I even tried to set a BaseShape to the (default) XYItemRenderer of the XYLineChart but I was only able to modify the size of the line. I also tried to set the SeriesShape but again, no shape drawn :S HALP!
The followind screen shows the problem I have. These are the same chart, with the two renderer.
Image
Image

Otacon94
Posts: 2
Joined: Thu Aug 24, 2017 7:16 pm
antibot: No, of course not.

Re: Help XYLineAndShapeRenderer

Post by Otacon94 » Fri Aug 25, 2017 12:31 am

Just Solved! I just used this code:

Code: Select all

       XYToolTipGenerator toolTip =  new XYToolTipGenerator() {
		     public String generateToolTip(XYDataset dataset, int series, int item){
		         Number x1 = dataset.getX(series, item);
		         Number y1 = dataset.getY(series, item);
		         StringBuilder stringBuilder = new StringBuilder();
		         stringBuilder.append("("+x1+","+y1+")");
		         return stringBuilder.toString();
		     }
		 };
		
		XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
		renderer.setSeriesPaint(0, Color.ORANGE);
		renderer.setSeriesStroke(0, new BasicStroke(2.0f));
		renderer.setBaseToolTipGenerator(toolTip);
		
		gainPercentageChart.getXYPlot().setRenderer(renderer);

Locked