TimeSeries vs HistogramDataset

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
zmalex
Posts: 1
Joined: Sat Dec 24, 2011 10:30 pm
antibot: No, of course not.

TimeSeries vs HistogramDataset

Post by zmalex » Sat Dec 24, 2011 11:13 pm

I have some questions regarding TimeSeries and HistogramDataset

Background
I have timestamp data collected over three days which is in the "yyyy:MM:dd:HH:mm:ss" format. The data has peaks between 8-17 all three days and no entries at night time. The data is collected from several sources and thus has occurring duplicates for some timestamps. I would like to create a histogram with per hour or per minute bins.

Questions
1. Since duplicates are not accepted when adding to TimeSeries, what is the recommended approach where I can treat each timestamp second as its own bin and where adding to two identical timestamps increments that bin?

Currently I am not using Histogram and HistogramDataset. But...
2a. - What is the benefit (if any) of using HistogramDataSet compared to TimeSeries and TimeSeriesCollection?
2b. - How do I combine TimeSeries, TimeSeriesCollection and HistogramDataSet?
2c. - How do I convert a TimeSeriesCollection to a HistogramDataSet?

3. - How can I increment the bins with actual timestamp occurrences instead of putting in fake values for each bin? See code

4. - How do I set the grid line and text label colors? I have tried setting chart, plot and renderer without luck. See code.

Code: Select all


        //Creating the TimeSeries
	ts = new TimeSeries("");
	for( int i=0;i<date.length; i++ ) {
		ts.addOrUpdate( new Minute(date[i]), 20); //Here I put a fake value of 20. Instead I want the actual bin size. Also forced to use addOrUpdate to handle duplicates
	}

	tsc = new TimeSeriesCollection(ts);
	
        //TODO: Use HSD     
	//hsd = new HistogramDataset();
	//hsd.setType(HistogramType.RELATIVE_FREQUENCY);
	//hsd.addSeries("Histogram", ts.??? , 5, tsc.getDomainLowerBound(false), tsc.getDomainUpperBound(false)); // How to I convert ts data to double[] to fit hsd?
		
	    chart = ChartFactory.createHistogram(plotTitle, xaxis, yaxis, tsc, orientation, show, toolTips, urls);
	    chart.setBackgroundPaint(Color.BLACK);
	    XYPlot plot = (XYPlot) chart.getPlot();
	    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
	    plot.setBackgroundAlpha(0);
	    plot.getRenderer().setSeriesPaint(0, new Color(80, 170, 200));

//TODO: Set gridline color to RED
//	    plot.setDomainGridlinePaint(Color.RED); //Not ok
//	    plot.setDomainZeroBaselinePaint(Color.RED); //Not ok
//	    plot.setDomainMinorGridlinePaint(Color.RED); //Not ok
//	    plot.setDomainGridlinePaint(Color.RED); //Not ok
//        plot.setRangeGridlinePaint(Color.RED); //Not ok
//        plot.getRenderer().setSeriesOutlinePaint(0, Color.RED); //Not ok
//        plot.getRenderer().setSeriesItemLabelPaint(0,  Color.RED); //Not ok   

Here is the picture of how the histogram looks now.
Image

Thankful for any help!

Locked