/**
* Builds and returns JFreeChart.
* @return
*/
public JFreeChart build(){
XYSeriesCollection collection = new XYSeriesCollection();
for(XYSeries s : seriesMap.values()){
collection.addSeries(s);
}
JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection, PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
Range rangeBounds = collection.getRangeBounds(true);
double upper = Math.min(rangeBounds.getUpperBound(), rangeBounds.getLowerBound()*5);
if(upper == 0.0){ upper = 10000; }
if(rangeBounds.getLowerBound() == upper){
yAxis.setRangeWithMargins(rangeBounds.getLowerBound()-rangeBounds.getLowerBound()*.1,upper+upper*.1);
}