新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

关于java图表统计实现代码的信息

java 实现报表统计

java本身没有操作excel的工具,需要第三方的jar包,用jxl就可以,代码入下。

我们提供的服务有:成都做网站、网站设计、微信公众号开发、网站优化、网站认证、连江ssl等。为近千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的连江网站制作公司

jxl你上百度搜索后下载就可以,简单易用,不懂追问。

public boolean exportExcel(HttpServletResponse response,Listcityinfo list)

{

try

{

OutputStream os = response.getOutputStream();// 取得输出流

response.reset();// 清空输出流

response.setHeader("Content-disposition", "attachment; filename=fine.xls");// 设定输出文件头

response.setContentType("application/msexcel");// 定义输出类型

WritableWorkbook wbook = Workbook.createWorkbook(os); // 建立excel文件

String tmptitle = "标题"; // 标题

WritableSheet wsheet = wbook.createSheet("详细信息表", 0); // sheet名称

WritableSheet wsheet = wbook.createSheet("性别统计表", 1); // sheet名称

WritableSheet wsheet = wbook.createSheet("证件类型统计表", 2); // sheet名称

// 设置excel标题

WritableFont wfont = new WritableFont(WritableFont.ARIAL, 16,WritableFont.BOLD,

false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);

WritableCellFormat wcfFC = new WritableCellFormat(wfont);

wcfFC.setBackground(Colour.AQUA);

wsheet.addCell(new Label(1, 0, tmptitle, wcfFC));

wfont = new jxl.write.WritableFont(WritableFont.ARIAL, 14,WritableFont.BOLD,

false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);

wcfFC = new WritableCellFormat(wfont);

// 开始生成主体内容

wsheet.addCell(new Label(0, 2, "具体内容"));

for(int i=0;ilist.size();i++) br=""{

wsheet.addCell(new Label(0, i+3, "");

wsheet.addCell(new Label(1, i+3,"");

}

// 主体内容生成结束

wbook.write(); // 写入文件

wbook.close();

os.close(); // 关闭流

return true;

}

catch(Exception ex)

{

ex.printStackTrace();

return false;

}

}

Java中如何让使用Python的统计包绘图

看来是同道。你提到的这个问题很难。

java调用python容易。 java甚至可以直接调用python的类。python调用java更容易了。

不过GUI要想融合,据目前20年的技术来看,只有本土的可以。 比如以前的微软件ActiveX,不管你是什么语言开发的都可以在windows下用OLE方式嵌入。

java的制图功能,因为它的设计理念 ,它是封闭的。也就是说,除非你使用了它本地化的GUI方法,否则就不可能实现。

那么说,如果我一定要实现怎么办呢?只能走很长的弯路。方法还是有几个的。

方法1:

在java的panel里嵌入一个浏览器,然后在浏览器里显示统计图表。这个真是不要太容易了。 不管是你是python生成的本地图片,还是直接用javascript生成的图都可以嵌入进去。美观不用说

方法2:

绘图使用开源的,比如plt之类的。不过它被本地化成java版本的。然后用java调用python,再用python产生数据后,通过jython调用java本地化的绘图工具。

表面上看,这个东西就是没有价值的,为什么不直接用java调用绘图。关键在于python本身对于数据处理的优势太明显。轻松就可以完成复杂的数据结构处理。所以还是有价值的

方法3:

浮动窗口方式。这个就不说了。如果你的java是固定在窗口特定位置的。这个就容易了。怎么浮动窗口要根据操作系统而定。

方法4:简单方案

python生成图片后,输出成JPEG或者是PNG或者是GIF,然后让JAVA显示这个图片。这个可能是最最简单的。

方法5:windows专用,不知道可否使用

仅限于特定场景,在要显示图片的地方,显示一个品红色的纯色图。然后让python的图形输出转到directshow之类的API,直接写显卡。这样就可以显示动画效果。

java如何将数据库中的数据统计后用jfreechart显示出来(要具体代码)

其实挺简单的,注意我写的注释!

%@ page contentType="text/html;charset=GB2312" %

%@ page import="org.jfree.chart.JFreeChart,org.jfree.chart.ChartUtilities,

org.jfree.chart.ChartFactory,

org.jfree.chart.plot.PlotOrientation,

org.jfree.data.category.DefaultCategoryDataset"% //上面是需要添加的头文件

html

body

%

String dataName[]=new String[]{"0-30岁","30-50岁","50-70岁","70岁以上"};//显示数据系列

int dataValueCount[]={4,5,4,6};//数据系列对应的值

//以上两行可以从数据库里去取值,用循环写入数组

//------创建数据集,并设置值------

DefaultCategoryDataset categoryDataset = newDefaultCategoryDataset();//这个表示柱状图

for(int i=0;idataName.length;i++)

categoryDataset.addValue(dataValueCount[i],dataName[i],dataName[i]);//循环写入数据集

String titleString="用户年龄阶段分布统计图";//图的标题

JFreeChart chart = ChartFactory.createBarChart(titleString,"用户年龄阶段","数量",

categoryDataset,PlotOrientation.VERTICAL,true,true,false);//chart就是欲创建的图表

ChartUtilities.writeChartAsJPEG(response.getOutputStream(),chart,500,300);//这行的意思是输出成一个JPEG形式的文件显示

%

/body

/html

其实后面还有很多参数的,比如颜色,柱子的标题等等,太多属性了,这个你查看一下JFREECHART的文档就行了,比如下面这样,很容易吧。

Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 12);

/*

* VALUE_TEXT_ANTIALIAS_OFF表示将文字的抗锯齿关闭,

* 使用的关闭抗锯齿后,字体尽量选择12到14号的宋体字,这样文字最清晰好看

*/

// chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

chart.setTextAntiAlias(false);

chart.setBackgroundPaint(Color.white);

// create plot

CategoryPlot plot = chart.getCategoryPlot();

// 设置横虚线可见

plot.setRangeGridlinesVisible(true);

// 虚线色彩

plot.setRangeGridlinePaint(Color.gray);

// 数据轴精度

NumberAxis vn = (NumberAxis) plot.getRangeAxis();

// vn.setAutoRangeIncludesZero(true);

DecimalFormat df = new DecimalFormat("#0.00");

vn.setNumberFormatOverride(df); // 数据轴数据标签的显示格式

// x轴设置

CategoryAxis domainAxis = plot.getDomainAxis();

domainAxis.setLabelFont(labelFont);// 轴标题

domainAxis.setTickLabelFont(labelFont);// 轴数值

属性比较多,不可能全贴出来,也不必全用,设置一些实用的属性即可。

eclipse中用JAVA代码怎么画柱形图表

用jfreechart

jfreechart绘制柱状图

import java.io.File;

import java.io.IOException;

import org.jfree.chart.ChartFactory;

import org.jfree.chart.ChartUtilities;

import org.jfree.chart.JFreeChart;

import org.jfree.chart.plot.PlotOrientation;

import org.jfree.data.category.DefaultCategoryDataset;

/*

* 绘制柱状图

*你亮哥

* */

public class BarChart3DDemo

{

public static void main(String[] args)

{

try

{

//设置主题

ChartFactory.setChartTheme(Theme.getTheme());

//构造数据

DefaultCategoryDataset dataset = new DefaultCategoryDataset();

dataset.addValue(100, "JAVA","1");

dataset.addValue(200, "js","1");

dataset.addValue(200, "C++", "2");

dataset.addValue(300, "C", "3");

dataset.addValue(400, "HTML", "4");

dataset.addValue(400, "CSS", "5");

/*

* public static JFreeChart createBarChart3D(

* java.lang.String title, 设置图表的标题

* java.lang.String categoryAxisLabel, 设置分类轴的标示

* java.lang.String valueAxisLabel, 设置值轴的标示

* CategoryDataset dataset, 设置数据

* PlotOrientation orientation, 设置图表的方向

* boolean legend, 设置是否显示图例

* boolean tooltips,设置是否生成热点工具

* boolean urls) 设置是否显示url

*/

JFreeChart chart = ChartFactory.createBarChart3D("编程语言统计", "语言",

"学习人数", dataset, PlotOrientation.VERTICAL, true, false,

false);

//保存图表

ChartUtilities.saveChartAsPNG(new File("E:/chart/BarChart3D.png"), chart, 800, 500);

System.out.println("绘图完成");

}

catch (IOException e)

{

e.printStackTrace();

}

}

}

===================================================================================

//一条线 有点 有数

package Test;

import java.awt.Color;

import java.awt.Font;

import org.jfree.chart.ChartFactory;

import org.jfree.chart.ChartFrame;

import org.jfree.chart.JFreeChart;

import org.jfree.chart.axis.AxisSpace;

import org.jfree.chart.labels.ItemLabelAnchor;

import org.jfree.chart.labels.ItemLabelPosition;

import org.jfree.chart.labels.StandardXYItemLabelGenerator;

import org.jfree.chart.plot.XYPlot;

import org.jfree.chart.renderer.xy.XYItemRenderer;

import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;

import org.jfree.chart.title.TextTitle;

import org.jfree.data.time.Month;

import org.jfree.data.time.TimeSeries;

import org.jfree.data.time.TimeSeriesCollection;

import org.jfree.ui.RectangleInsets;

import org.jfree.ui.TextAnchor;

public class try123 {

public static void main(String[] args){

//首先构造数据

TimeSeries timeSeries = new TimeSeries("BMI", Month.class);

// 时间曲线数据集合

TimeSeriesCollection lineDataset = new TimeSeriesCollection();

// 构造数据集合

timeSeries.add(new Month(1, 2009), 45);

timeSeries.add(new Month(2, 2009), 46);

timeSeries.add(new Month(3, 2009), 1);

timeSeries.add(new Month(4, 2009), 500);

timeSeries.add(new Month(5, 2009), 43);

timeSeries.add(new Month(6, 2009), 324);

timeSeries.add(new Month(7, 2009), 632);

timeSeries.add(new Month(8, 2009), 34);

timeSeries.add(new Month(9, 2009), 12);

timeSeries.add(new Month(10, 2009), 543);

timeSeries.add(new Month(11, 2009), 32);

timeSeries.add(new Month(12, 2009), 225);

lineDataset.addSeries(timeSeries);

JFreeChart chart = ChartFactory.createTimeSeriesChart("", "date", "bmi", lineDataset, true, true, true);

//增加标题

chart.setTitle(new TextTitle("XXXBMI指数", new Font("隶书", Font.ITALIC, 15)));

chart.setAntiAlias(true);

XYPlot plot = (XYPlot) chart.getPlot();

plot.setAxisOffset(new RectangleInsets(10,10,10,10));//图片区与坐标轴的距离

plot.setOutlinePaint(Color.PINK);

plot.setInsets(new RectangleInsets(15,15,15,15));//坐标轴与最外延的距离

// plot.setOrientation(PlotOrientation.HORIZONTAL);//图形的方向,包括坐标轴。

AxisSpace as = new AxisSpace();

as.setLeft(25);

as.setRight(25);

plot.setFixedRangeAxisSpace(as);

chart.setPadding(new RectangleInsets(5,5,5,5));

chart.setNotify(true);

// 设置曲线是否显示数据点

XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)plot.getRenderer();

xylineandshaperenderer.setBaseShapesVisible(true);

// 设置曲线显示各数据点的值

XYItemRenderer xyitem = plot.getRenderer();

xyitem.setBaseItemLabelsVisible(true);

xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_LEFT));

xyitem.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());

xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 14));

plot.setRenderer(xyitem);

//显示

ChartFrame frame = new ChartFrame("try1", chart);

frame.pack();

frame.setVisible(true);

}

}

java实现简单的图书销售统计系统,要用GUI 求java高手帮忙 谢谢啦

我看到数据好像是保存在文件中的,这样解析很不给力。

建议使用 access 数据库,小巧又好用。

其他的这几个功能也不难,楼主,你哪里不会,你的思路是什么,可以讲一讲,可以协助你完成。

如何使用java做统计图表

//参考地址去网站下js控件,下面是饼图的代码,下图是我的代码效果

function query1(housetype,redStatisticsList,text0,cashingSum,tranferSum){

!--红包发放数据--

var myrodiusred = echarts.init(document.getElementById('mainrodius'));//ID

var redHousehold = housetype;

var redMoney = redStatisticsList;

var allMoney = 0;//总金额

$.each(redStatisticsList,function(index,item){

allMoney =allMoney+ Number(item.value);

})

optionTwo = {

title : {

text: text0,

subtext: "总金额:"+allMoney+"\n\n提现总额:"+cashingSum+"\n\n到账总额:"+tranferSum,

x:'center'

},

tooltip : {

trigger: 'item',

formatter: "{a} br/{b} ({d}%)"

},

legend: {

orient: 'vertical',

left: 'left',

data: housetype

},

series : [

{

type: 'pie',

radius : '55%',

center: ['50%', '60%'],

data:redMoney,

itemStyle: {

emphasis: {

shadowBlur: 10,

shadowOffsetX: 0,

shadowColor: 'rgba(0, 0, 0, 0.5)'

}

}

}

]

};

myrodiusred.setOption(optionTwo);

}


网页名称:关于java图表统计实现代码的信息
网页链接:http://www.wjwzjz.com/article/hjhodj.html
在线咨询
服务热线
服务热线:028-86922220
TOP