Hi,
If my dataset has the values from 0 to 23412345623, then the labels ( indicating the numbers ) overlap with each other.
How can I go about it.
I tried creating my own unit using NumberTickUnit
TickUnitSource rangeUnits = units.add(new NumberTickUnit((maxValue - minValue) / 10)); // minValue is the minmum value and maxValue is the maxValue that appears in the graph.
rangeAxis.setStandardTickUnits(rangeUnits);
But then the not even a single label appeared in the y- axis. Can you please help me out in this.
Regards,
Overlapping labels of range axis
Hello,
This problem is back.
So I am appending the sample code where the tick labesl of y axis are overlpped.
Can you please let me know how can I go about soon since its urgent for me.
Regards,
Narayan
This problem is back.
So I am appending the sample code where the tick labesl of y axis are overlpped.
Code: Select all
package com.jpmchase.mm.application.emb.stats.test;
import java.awt.Color;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.data.time.Day;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
public class ChartHelper2 {
private TimeSeriesCollection createDataset(){
TimeSeriesCollection dataset = new TimeSeriesCollection();
TimeSeries time = new TimeSeries("", Day.class);
Day day;
try {
day = new Day(new SimpleDateFormat("ddMMyyyy").parse("01052007"));
time.add(day, 12);
day = new Day(new SimpleDateFormat("ddMMyyyy").parse("02052007"));
time.add(day,4);
day = new Day(new SimpleDateFormat("ddMMyyyy").parse("03052007"));
time.add(day, Long.parseLong("123456789012345"));
dataset.addSeries(time);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return dataset;
}
private JFreeChart createChart(TimeSeriesCollection dataset)
{
final JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Title", // Chart Title
"X - Axis", // X-Axis Label
"Y - Axis", // Y-Axis Label
dataset, // Dataset
true, // Show Legend
true, // Show Tooltip
false); // UR
chart.setBackgroundPaint(Color.white);
return chart;
}
public static void main(String [] args){
ChartHelper2 chartHelper = new ChartHelper2();
TimeSeriesCollection dataset = chartHelper.createDataset();
JFreeChart chart = chartHelper.createChart(dataset);
try {
ChartUtilities.writeChartAsPNG(new FileOutputStream("E:\\second.png"), chart, 650, 220);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Regards,
Narayan
Hi All,
It worked ...
I am getting the difference between the minimum and maximum values and deviding by 9 ( number of ticks I want in the range axix) and then setting the tick unit.
Cheers,
Narayan
It worked ...
I am getting the difference between the minimum and maximum values and deviding by 9 ( number of ticks I want in the range axix) and then setting the tick unit.
Code: Select all
double minValue = (double) rangeAxis.getRange().getLowerBound();
double maxValue = (double) rangeAxis.getRange().getUpperBound();
double difference = maxValue - minValue;
double tickDiff = difference / 9;
rangeAxis.setTickUnit(new NumberTickUnit(tickDiff));
Narayan