背景:java开发的过程中,需要对数据进行可视化,这样方便客户理解此时的数据状态

语言:java,js,window7,echarts包文件

sample的例子下面的参照

https://www.echartsjs.com/examples/en/editor.html?c=line-sections

html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta name="viewport" charset="UTF-8"
content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title></title>
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<script th:src="@{jquery/js/jquery-3.2.0.min.js}" type="text/javascript"></script>
<script th:src="@{echarts/js/echarts.js}" type="text/javascript"></script>
<script th:src="@{js/testCharts.js}" type="text/javascript"></script> </head>
<body>
<div id="conditions"> <table>
<tr>
<td><label>検索条件:</label></td>
<td><input type="radio" name="month" id="month"
onclick="choseMonthOrDay(this)" /><label>月</label>
</td>
<td><input type="radio" name="month" id="month"
onclick="choseMonthOrDay(this)" /><label>年</label>
</td>
<td><input type="button" onclick="beforRet()"
style="background-color: #3987e4; width: 83px; height: 44px; border: 0;"
value="戻る"></input></td>
</tr>
</table>
</div> <div id="chart"></div>
<!-- <div id="chart"></div> -->
</body>
</html>

  

js

$(document).ready(function() {

//	$("#conditions").css("height", $(window).height()*0.1);
// $("#conditions").css("background-color", "#000000");
// alert($(window).width())
$("#chart").css("height", $(window).height()*0.8);
window.onresize = function() {
// $("#chart").css("height", $(window).height()*0.1);
$("#conditions").css("height", $(window).height()*0.8);
} var dataList
$.ajax({
url : "/testCharts/selectData",
type : 'post',
data : {
"habitSeq" : "2",
"value" : "01"
},
cache : false,
async : true,
success : function(data) {
dataList = JSON.parse(data);
chartsDisplay(dataList)
}
});
}) function chartsDisplay(dataList) { if (dataList.length != 0) {
var xAxisList = new Array();
var yAxisList = new Array();
for (var i = 0; i < dataList.length; i++) {
xAxisList[i] = (dataList[i]["maxInsDateTime"]);
yAxisList[i] = (dataList[i]["totalPrice"]);
}
var echart = echarts.init(document.getElementById('chart'));
var option = {
baseOption : {
title : {
text : '店舗売上状況',
subtext : '売上分析'
},
legend : {
data : [ '当月売上', '金額' ]
},
xAxis : {
data : xAxisList
// [ '周一', '周二', '周三', '周四', '周五', '周六', '周日' ]
},
yAxis : { },
tooltip : {
show : true,
formatter : '売上:{a}<br />日付:{b}<br />値:{c}'
},
series : [ {
name : '当月売上',
type : 'bar',
data : yAxisList ,// [ 200, 312, 431, 241, 175, 275,
// 369
// ],
markPoint : {
data : [ {
type : 'max',
name : '最大値'
}, {
type : 'min',
name : '最小値'
} ]
},
markLine : {
data : [ {
type : 'average',
name : '平均値',
itemStyle : {
normal : {
color : 'green'
}
}
} ]
}
}, {
name : '金額',
type : 'line',
data : yAxisList , // [ 321, 432, 543, 376, 286, 298,
// 400
// ],
markPoint : {
data : [ {
type : 'max',
name : '最大値'
}, {
type : 'min',
name : '最小値'
} ]
},
markLine : {
data : [ {
type : 'average',
name : '平均値',
itemStyle : {
normal : {
color : 'blue'
}
}
} ]
}
} ]
},
media : [ {
// 小与1000像素时候响应
query : {
maxWidth : 1000
},
option : {
title : {
show : true,
text : '测试一下'
}
}
} ]
};
// 每次窗口大小改变的时候都会触发onresize事件,这个时候我们将echarts对象的尺寸赋值给窗口的大小这个属性,从而实现图表对象与窗口对象的尺寸一致的情况
window.onresize = echart.resize*0.8;
echart.setOption(option);
} }

  

效果:

利用js来画图形(例如:条状图,圆饼图等)的更多相关文章

  1. HighCharts之2D堆条状图

    HighCharts之2D堆条状图 1.HighCharts之2D堆条状图源码 StackedBar.html: <!DOCTYPE html> <html> <head ...

  2. HighCharts之2D条状图

    HighCharts之2D条状图 1.HighCharts之2D条状图源码 bar.html: <!DOCTYPE html> <html> <head> < ...

  3. Excel 2010高级应用-条状图(五)

    Excel 2010高级应用-条状图(五) 基本操作如下: 1.新建一个Excel空白文档,并命名条状图 2.单击"插入",找到条状图的样图 3.选择其中一种类型的条状图样图,在空 ...

  4. Flex实现双轴条状图

    1.问题背景 一般的,柱状图可以实现双轴图,但是如何实现双轴条状图? 2.实现实例 <?xml version="1.0" encoding="utf-8" ...

  5. python中matplotlib绘图封装类之折线图、条状图、圆饼图

    DrawHelper.py封装类源码: import matplotlib import matplotlib.pyplot as plt import numpy as np class DrawH ...

  6. Matplotlib基本图形之饼状图

    Matplotlib基本图形之饼状图 饼状图特点: 饼状图显示一个数据系列中各项大小与各项总和的比例饼状图的数据点显示为整个饼状图的百分比 示例代码 import os import time imp ...

  7. d3.js(v5.7)树状图

    一.新建画布 二.数据处理 三.绘制连接线 图示: 四.绘制节点.文字 图示: 五.总结 path元素:其实就是定义了绘图的坐标点,从哪开始,移动到哪,怎样移动(命令) 具体可百度(或许以后我会总结一 ...

  8. maplotlib python 玩具绘图 横向纵向条状图

    from matplotlib import font_manager#解决zh-han图形汉字乱码 my_font = font_manager.FontProperties(fname=" ...

  9. MS Chart 条状图【转】

    private void Form1_Load(object sender, EventArgs e) {            string sql1 = "select  类别,coun ...

随机推荐

  1. sass变量的作用域

    嵌套规则内定义的变量只能在嵌套规则内使用(局部变量),不在嵌套规则内定义的变量则可在任何地方使用(全局变量). <div class="test">111111111& ...

  2. 调用图灵API V2 遇到的坑

    1:遇到的第一个问题:跨域 解决办法: 第一种:使用query中的jsonp 可惜图灵要求post方法,而jsonp,只能使用get方法,才能跨域,失败 第二种:服务器添加header,可是我怎么去改 ...

  3. circus 做为批处理的守护进程

    circus 是集成了zeromq,使用python编写的一个进程以及socket 管理工具,使用circus 的进程管理,我们可以用来进行批任务的 处理,同时又能保证任务的准确 项目使用docker ...

  4. [RN] React Native 关闭所有黄色警告

    [RN] React Native 关闭所有黄色警告 console.ignoredYellowBox = ['Warning: BackAndroid is deprecated. Please u ...

  5. 在Matlab中画图输出

    在Matlab中画图后,可能会调整格式.输出存储时,格式会忽然消失. 可以修改右下边Export setup,将Font size设置成auto. 这样就保留了编辑效果.

  6. GoCN每日新闻(2019-10-03)

    GoCN每日新闻(2019-10-03) 国庆专辑:GopherChina祝大家国庆节快乐 GoCN每日新闻(2019-10-03) 1. 垃圾回收器如何监控你的应用程序 https://medium ...

  7. win10任务栏不显示垃圾的搜狗图标

    设置-->时间和语言-->拼写键盘和键入设置-->高级键盘设置-->语言栏选项-->语言栏-->勾选隐藏-->同时去掉在任务栏显示其他语言图标

  8. 配置Always On AG

    1.准备测试环境的服务器 在 Always On AG 中如果需要自动 Failover 至少需要集群中有 3 台服务器,但是我只是测试功能,因此只使用了两台服务器.并且本文不涉及任何 Pacemak ...

  9. Sql注入基本思路

    Sql注入基本思路 利用mysql自己动手 登录 使用show databases;查看数据库,sql注入主要用到的是information_schema这个库(mysql中大小写不敏感) infor ...

  10. 玩转@Git三剑客

    扫码时备注或说明中留下邮箱 付款后如未回复请至https://shop135452397.taobao.com/ 联系店主