JfreeChart集萃

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

远去的渡口的JfreeChart集萃作者:远去的渡口做最棒的软件开发交流社区第1/40页本书由JavaEye提供的电子书DIY功能自动生成于2010-11-25目录1.JfreeChart1.1JfreeChart折线图..................................................................31.2JfreeChart3D柱状图带基准线的....................................................161.3JfreeChart3D饼图总结............................................................201.4JfreeChart散点图,加了区域范围说明.................................................251.5JfreeChart热点map的应用..........................................................311.6JfreeChart如何处理乱码............................................................40页1.1JfreeChart折线图发表时间:2009-05-22在这个公司,用到了太多的JfreeChart,今天就对折线图作一个总结,希望对大家有点帮助,我这里直接是与业务逻辑相关的,业务需要的数据加载到数据集等,不过我会作一些注释的,呵,之前有网友建议写注释。折线图,大可分为两种,(1)X轴值类型为String的。2)常用的是X轴值是日期的,并且,有时需要满足这样的需求:1、时间要连续。2、时间可以设置固定的跨度,比如,2009-02-01,2009-02-04,2009-02-07……3、由于时间跨度较大,想要做到不同精度的图表,如时间为10天时,以日(yyyy-MM-dd)格式为精度,时间跨度为2个月时,以周(如2009年第3周)为精度,跨度为6个月时,以月(2009年8月)为精度.下面,针对比较复杂的(2)来讲解:1、取到业务逻辑需要的数据:(具体过程就不啰嗦了,就是查询数据库,得到想要的字段的值,加载到List里面)返回ListPressureBeanPressureBean的包含的属性:intuserId;StringbpDate;StringbpTime;intsyspress;//收缩压(mmHg)intdiapress;//舒张压(mmHg)2、加载数据集publicstaticTimeSeriesCollectioncreateTimeSeries(ListPressureBeanlist,intdayOrweekOrmonth,Loglog,Stringshou,Stringshu){TimeSeriesCollectiontimesers=newTimeSeriesCollection();页intmon=1;intday=1;intye=2000;intweek=1;//按天显示if(dayOrweekOrmonth==0){TimeSeriestimeseries=newTimeSeries(shou,org.jfree.data.time.Day.class);TimeSeriestimeseries1=newTimeSeries(c1,org.jfree.data.time.Day.class);TimeSeriestimeseriedia=newTimeSeries(shu,org.jfree.data.time.Day.class);TimeSeriestimeseriedia1=newTimeSeries(d1,org.jfree.data.time.Day.class);IteratorPressureBeanit=list.iterator();while(it.hasNext()){PressureBeanpres=it.next();Stringdate=pres.getBpDate();ye=Integer.parseInt(date.substring(0,4));mon=Integer.parseInt(date.substring(5,7));day=Integer.parseInt(date.substring(8,date.length()));Daydays=newDay(day,mon,ye);doublesys=pres.getSyspress();doubledia=pres.getDiapress();if(sys!=-1&&sys0){timeseries.add(days,sys);}else{timeseries1.add(days,null);}if(sys!=-1&&sys0){页timeseriedia.add(days,dia);}else{timeseriedia1.add(days,null);}}timesers.addSeries(timeseries);timesers.addSeries(timeseriedia);timesers.addSeries(timeseries1);timesers.addSeries(timeseriedia1);}elseif(dayOrweekOrmonth==1){//按周显示TimeSeriestimeseries=newTimeSeries(shou,org.jfree.data.time.Week.class);TimeSeriestimeseries1=newTimeSeries(c1,org.jfree.data.time.Week.class);TimeSeriestimeseriedia=newTimeSeries(shu,org.jfree.data.time.Week.class);TimeSeriestimeseriedia1=newTimeSeries(d1,org.jfree.data.time.Week.class);IteratorPressureBeanit=list.iterator();while(it.hasNext()){PressureBeanpres=it.next();Stringdate=pres.getBpDate();String[]spls=date.split(-);if(spls.length==2){ye=Integer.parseInt(spls[0]);mon=Integer.parseInt(spls[1]);}else{log.error(thedateofweeksiswrong);}Weekdays=newWeek(mon,ye);页doublesys=pres.getSyspress();doubledia=pres.getDiapress();if(sys!=-1&&sys0){timeseries.add(days,sys);}else{timeseries1.add(days,null);}if(sys!=-1&&sys0){timeseriedia.add(days,dia);}else{timeseriedia1.add(days,null);}}timesers.addSeries(timeseries);timesers.addSeries(timeseriedia);timesers.addSeries(timeseries1);timesers.addSeries(timeseriedia1);}else{//按月显示TimeSeriestimeseries=newTimeSeries(shou,org.jfree.data.time.Month.class);TimeSeriestimeseries1=newTimeSeries(c1,org.jfree.data.time.Month.class);TimeSeriestimeseriedia=newTimeSeries(shu,org.jfree.data.time.Month.class);TimeSeriestimeseriedia1=newTimeSeries(s,org.jfree.data.time.Month.class);IteratorPressureBeanit=list.iterator();while(it.hasNext()){PressureBeanpres=it.next();Stringdate=pres.getBpDate();页String[]spls=date.split(-);if(spls.length==2){ye=Integer.parseInt(spls[0]);mon=Integer.parseInt(spls[1]);}else{log.error(thedateofweeksiswrong);}Monthdays=newMonth(mon,ye);doublesys=pres.getSyspress();doubledia=pres.getDiapress();if(sys!=-1&&sys0){timeseries.add(days,sys);}else{timeseries1.add(days,null);}if(sys!=-1&&sys0){timeseriedia.add(days,dia);}else{timeseriedia1.add(days,null);}}timesers.addSeries(timeseries);timesers.addSeries(timeseriedia);timesers.addSeries(timeseries1);timesers.addSeries(timeseriedia1);}returntimesers;}页3、画折线图,两个数据集,收缩压和舒张压,并且,这两条曲线还各自包含一个区域范围,并不单单是一条基准线,而是一个基准范围privatestaticJFreeChartcreateChartPress(XYDatasetxydataset,intweekOrmonth,Stringtitle,Stringy,Stringindex,Stringweek,Stringyear,intsearchby,Stringmonth,Stringnodatamess,Listlist,Loglog,Stringbp_shou,Stringbp_shuzhang){//有可能用户在后面的版本中故意输入不正常数值,但是为了保证图片画图的完整,这里先计算//用户血压值的最大值。doublemaxpress=0;doubleaddmax=50;doublemin=40;if(list!=null&&list.size()0){IteratorPressureB

1 / 40
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功