Hi
I need to plot barchart some Machine names - xaxis (String) against hours minutes which will be in format HH:MM in Y axis. Each Machine will have 2 time values . eg Machine 1 will have 09:22 and 01:11, so 2 bars will be required in 1 machine.
The time series is not useful as I am not plotting against any date . The exisitng defaultdata set is taking only int or double as input . Is there any way to mention HH:MM as input.
I am trying different features in API but not able achive my requirement and any hint / help will be of great help.
Thanks,
harishkar
HH:MM in Y axis Barchart Plotting
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: HH:MM in Y axis Barchart Plotting
Given a CategoryPlot, you can substitute a DateAxis for the factory's default ValueAxis and use a suitable DateFormat. You'll need to scale your data to represent milliseconds.
Code: Select all
DateAxis range = new DateAxis("HH:mm");
SimpleDateFormat f = new SimpleDateFormat("HH:mm");
f.setTimeZone(TimeZone.getTimeZone("GMT"));
range.setDateFormatOverride(f);
plot.setRangeAxis(range);
Re: HH:MM in Y axis Barchart Plotting
Thanks John. It does work perfectly as expected and I am able to plot the values successfully .
Also is there anyway we can show the HH:mm value as labels as we doing for numbers like
plot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
plot.getRenderer().setBaseItemLabelsVisible(true);
Thanks,
Harishkar
Also is there anyway we can show the HH:mm value as labels as we doing for numbers like
plot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
plot.getRenderer().setBaseItemLabelsVisible(true);
Thanks,
Harishkar
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: HH:MM in Y axis Barchart Plotting
In the constructor of StandardCategoryItemLabelGenerator(), you can supply a custom DateFormat.