Time Series BAR Charts
Time Series BAR Charts
Currently the createTimeSeriesChart draws only an XY plot.
Is there a way I can get the "Time usage" but in a bar chart.
The advantage of the Time usage is that the dates are compressed with increase in the data.
Thanks
Is there a way I can get the "Time usage" but in a bar chart.
The advantage of the Time usage is that the dates are compressed with increase in the data.
Thanks
Re: Time Series BAR Charts
You can create an VerticalXYBarRenderer and add it to the plot.
TimeSeriesCollection dataset = new TimeSeriesCollection();
.
.
.
XYItemRenderer renderer = new VerticalXYBarRenderer(0.20);
XYPlot plot = new XYPlot(dataset, null, null, renderer);
TimeSeriesCollection dataset = new TimeSeriesCollection();
.
.
.
XYItemRenderer renderer = new VerticalXYBarRenderer(0.20);
XYPlot plot = new XYPlot(dataset, null, null, renderer);
Re: Time Series BAR Charts
Question on your recommendation .... how do I add my variables to the TimeSeriesCollection ?
I have the dates and some numbers for each date.
Thanks
I have the dates and some numbers for each date.
Thanks
Re: Time Series BAR Charts
Amit,
Create a BasicTimeSeries based on some unit of time (Second, Minute, Hour, Month, ...) and add your data points to it. Then add the BasicTimeSeries to your TimeSeriesCollection. I did something like this where I looped through the data and converted each date into a Second, then added it to the BasicTimeSeries. Then created the renderer like I described above and added my TimeSeriesCollection to it.
import com.jrefinery.data.Second;
.
.
.
TimeSeriesCollection availableDataset = new TimeSeriesCollection();
BasicTimeSeries available = new BasicTimeSeries("Available Licenses", Second.class);
available.add(mySecond, some_value);
availableDataset.addSeries(available);
Create a BasicTimeSeries based on some unit of time (Second, Minute, Hour, Month, ...) and add your data points to it. Then add the BasicTimeSeries to your TimeSeriesCollection. I did something like this where I looped through the data and converted each date into a Second, then added it to the BasicTimeSeries. Then created the renderer like I described above and added my TimeSeriesCollection to it.
import com.jrefinery.data.Second;
.
.
.
TimeSeriesCollection availableDataset = new TimeSeriesCollection();
BasicTimeSeries available = new BasicTimeSeries("Available Licenses", Second.class);
available.add(mySecond, some_value);
availableDataset.addSeries(available);
Re: Time Series BAR Charts
My case is os dates (YYYY-MM-DD) .... there is not date type for that.
In your case, you are converting the dates into seconds.
But there are 2 potential problems with that.
1. You lose the feel of date ... as you are recoding them to seconds.
2. If the seconds range from 0 to 60 (not sure of that though), then you have a limited amount of data to work with.
Thanks
In your case, you are converting the dates into seconds.
But there are 2 potential problems with that.
1. You lose the feel of date ... as you are recoding them to seconds.
2. If the seconds range from 0 to 60 (not sure of that though), then you have a limited amount of data to work with.
Thanks
Re: Time Series BAR Charts
The time period just has to be unique so that all your data points can be displayed. It doesn't have to do with the format of the date that appears. I chose Second because I knew I would never have more than one data item per second, but I could potentially have multiple data items per minute, so Minute would not work for me. If you only have one data entry per year, use Year. Does that make sense?
Re: Time Series BAR Charts
Thanks Justin, I was able to create the bar chart. But got into a new problem now, Is there a way I can paint the Bars differently. Ex all the Bars on weekends, should be of a different color.
Thanks
Thanks
Re: Time Series BAR Charts
Try
plot.setSeriesPaint(0, new Color(51, 153, 255));
or some other color and series number.
plot.setSeriesPaint(0, new Color(51, 153, 255));
or some other color and series number.
Re: Time Series BAR Charts
There is another problem that I am encountering now.
How do I plot time in case of StackedBar Charts ?
Or in case of Bar charts that have 6 bars (Categories) per day ?
Thanks
How do I plot time in case of StackedBar Charts ?
Or in case of Bar charts that have 6 bars (Categories) per day ?
Thanks