I have 2 questions:
- How to set the date axis range in jfreechart? The starting date should be 6days before current day & end date should be current day. So that there would be only 7 values in x-axis (dateaxis).
I am trying the following code, but it is not working:
XYPlot plot = (XYPlot) jfreechart.getPlot();
dateaxis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy"));
plot.setRangeAxis(dateaxis);
- How to set specific color for the specific column of bar based on the state value? i.e, if i am adding "success" state on 6th sept & "failure" state on 7h sept & "success" state on 8th sept, then how do i represent them as green-red-green?
I am trying to add the the data in the following way. But colors are not actually changing based on state even if i override GradientPaint & setSeriesPaint function:
For the category named F7, i am adding the data in the following way.
defaultcategorydataset.addValue(6/8/2014 , "Successful", "F7");
defaultcategorydataset.addValue(7/8/2014 , "Failed", "F7");
defaultcategorydataset.addValue(8/8/2014 , "Successful", "F7");
defaultcategorydataset.addValue(9/8/2014 , "Failed", "F7");
defaultcategorydataset.addValue(10/8/2014 , "Successful", "F7");
defaultcategorydataset.addValue(11/8/2014 , "Successful", "F7");
Finally i am expecting the graph to be like this (In the screenshot F7 category is not properly represented according to the added value):