Echarts的赋值,设置数据
柱形图案例的赋值
相关文档参考:https://blog.csdn.net/yangsitong1314/article/details/76984616
<div class="map_bg">
<div class="map_center">
<div class="map_title1">选调生图书馆资料阅读统计图</div>
<div class="map_select">
<select id="library_num">
<option value="1">最近半年</option>
<option value="2">最近30天</option>
<option value="3">最近一周</option>
</select>
</div>
<div id="party_member" style="width: 500px;height:274px;"></div>
</div>
</div>
/*
* 选调生图书馆资料阅读统计图
*/
var party_member = echarts.init(document.getElementById('party_member'));
var posList = [ 'left', 'right', 'top', 'bottom', 'inside', 'insideTop',
'insideLeft', 'insideRight', 'insideBottom', 'insideTopLeft',
'insideTopRight', 'insideBottomLeft', 'insideBottomRight' ]; var app = [];
app.config = {
rotate : 90,
align : 'left',
verticalAlign : 'middle',
position : 'insideBottom',
distance : 15,
onChange : function() {
var labelOption = {
normal : {
rotate : app.config.rotate,
align : app.config.align,
verticalAlign : app.config.verticalAlign,
position : app.config.position,
distance : app.config.distance
}
};
myChart.setOption({
series : [ {
label : labelOption
}, {
label : labelOption
}, {
label : labelOption
}, {
label : labelOption
} ]
});
}
}; var labelOption = {
normal : {
show : true,
position : app.config.position,
distance : app.config.distance,
align : app.config.align,
verticalAlign : app.config.verticalAlign,
rotate : app.config.rotate,
formatter : '{c} {name|{a}}',
fontSize : 16,
rich : {
name : {
textBorderColor : '#fff'
}
}
}
}; var option3 = {
color : [ '#f7683c', '#fbb42a', '#3c82f7', '#36cd26' ],
tooltip : {
trigger : 'axis',
axisPointer : {
type : 'shadow'
}
},
legend : {
data : [ '公开课', '学习专题', '书库', '时事新闻' ]
},
toolbox : {
show : false
},
calculable : true,
xAxis : [ {
name : '月',
type : 'category',
axisTick : {
show : false
},
axisLabel :{
interval:0
},
data : [ '1月', '2月', '3月', '4月', '5月', '6月' ]
} ],
yAxis : [ {
name : '次数',
type : 'value',
axisTick : {
show : false,
},
splitLine : {//背景图的内置表格中“边框”的颜色线条 这个是y轴的辅助线
show : false
}
} ],
series : [ {
name : '公开课',
type : 'bar',
barGap : 0,
barWidth : 8,
data : [ 320, 132, 201, 334, 150, 220 ]
}, {
name : '学习专题',
type : 'bar',
barWidth : 8,
data : [ 220, 182, 151, 234, 290, 120 ]
}, {
name : '书库',
type : 'bar',
barWidth : 8,
data : [ 150, 232, 201, 154, 190, 90 ]
}, {
name : '时事新闻',
type : 'bar',
barWidth : 8,
data : [ 198, 177, 301, 199, 140, 160 ]
} ]
};
// 使用刚指定的配置项和数据显示图表。
party_member.setOption(option3); //以下代码是从后台获取到数据并赋值
var recentTime3 = $("#library_num").val(); //最近时间
$("#library_num").click(function() {
libraryReading(this.value);
});
libraryReading(recentTime3);
function libraryReading(recentTime) {
$.ajax({
type : "post",
url : "rest/admin/log/library_Reading",
data : {
"recentTime" : recentTime
},
cache : false, //禁用缓存
dataType : "json",
success : function(result) {
var xAxisNames = result.xAxisNames1;
console.log(result)
console.log(xAxisNames)
var xAxisUnit;
if (result.recentTime == 1) {
xAxisUnit = "月";
//xAxisNames=['1月', '2月','3月', '4月', '5月', '6月']
}
if (result.recentTime == 2) {
xAxisUnit = "周";
//xAxisNames=['第一周', '第二周','第三周', '第四周']
}
if (result.recentTime == 3) {
xAxisUnit = "天";
//xAxisNames=['周一', '周二','周三', '周四', '周五', '周六']
}
var linNum1 = result.array1;
var linNum2 = result.array2;
var linNum3 = result.array3;
var linNum4 = result.array4; /* $.each(result.array1,function(key,value){
linNames.push(value);
linNums.push(value);
}); */
//柱形图赋值
party_member.setOption({ //加载数据图表
xAxis : {
name : xAxisUnit,
data : xAxisNames,
axisLabel :{
interval:0
}
},
series : [ {
data : linNum1
}, {
data : linNum2
}, {
data : linNum3
}, {
data : linNum4
} ]
});
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert("查询失败");
}
});
}
Echarts的赋值,设置数据的更多相关文章
- ajax导致Echarts不显示饼图数据、柱状图数据只显示气泡的问题。
1.ajax导致Echarts不显示饼图数据.柱状图数据只显示气泡的问题. ajax的同步.这个同步的意思是当JS代码加载到当前ajax的时候会把页面里所有的代码停止加载,页面出去假死状态,当这个aj ...
- 动态更新echarts k线图数据 通过websocket取数据
1.加载插件,实例化chart.2.链接websocket3.接收数据,处理数据,调用chart的实例,不断更新数据<!DOCTYPE html><html><head ...
- Echarts 之三 —— 地市联动数据统计二
一.简介 除了是一个地图之外,我们也可以使用多地图进行地市.区县联动数据统计.需求如下:展示整改广东省的地图,并显示统计信息,当点击某一个地市的时候,就显示该地市的地图,并统计该地市区县的数据信息.二 ...
- Silverlight 中datagrid控件-- 通过设置数据虚拟化加速显示
定义依赖属性作为datagrid的数据源 protected static readonly DependencyProperty ViewLogsProperty = DependencyPrope ...
- I.MX6 Android Linux shell MMPF0100 i2c 设置数据
#!/system/bin/busybox ash # # I.MX6 Android Linux shell MMPF0100 i2c 设置数据 # 说明: # 本文主要记录通过shell脚本来设置 ...
- listview必须设置数据适配器才能显示出来
listview必须设置数据适配器才能显示出来,哪怕只设置一个空的数据适配器都行: lvTabDetail.setAdapter(new NewsListAdapter()); class NewsL ...
- echarts 移动端地图数据可视化教程
如上效果图: 以下未代码: <!doctype html> <html lang="en"> <head> <meta charset ...
- echarts.js多图表数据展示使用小结
echarts api文档: http://echarts.baidu.com/echarts2/doc/doc.html echarts demo示例: http://echarts.baidu.c ...
- SQL Fundamentals: 子查询 || 行列转换(PIVOT,UNPIVOT,DECODE),设置数据层次(LEVEL...CONNECT BY)
SQL Fundamentals || Oracle SQL语言 子查询(基础) 1.认识子查询 2.WHERE子句中使用子查询 3.在HAVING子句中使用子查询 4.在FROM子句中使用子查询 5 ...
- echarts 移动端地图数据可视化开发教程
如上效果图: 以下未代码: <!doctype html> <html lang="en"> <head> <meta charset ...
随机推荐
- 160704、commons-beanutils.jar常用方法
package com.test.beanutils; import java.lang.reflect.InvocationTargetException;import java.text.Pars ...
- ZOJ 1648 Circuit Board(计算几何)
Circuit Board Time Limit: 2 Seconds Memory Limit: 65536 KB On the circuit board, there are lots of c ...
- c# Log4net的结构
log4net 有四种主要的组件,分别是Logger(记录器), Repository(库), Appender(附着器)以及 Layout(布局).
- 使用CocoaPods配置管理开源项目
今天从GitHub下载了MMProcessHUB,想先看看demo,但是不巧的是作者是用CocoaPods配置的,需要安装CocoaPods,CocoaPods是一个第三方的类库管理工具.找了一篇很详 ...
- Byzantine failures
https://baike.baidu.com/item/拜占庭将军问题/265656?fr=aladdin 拜占庭将军问题(Byzantine failures),是由莱斯利·兰伯特提出的点对点通信 ...
- MyBatis 之动态SQL
1. 概述 动态 SQL 极大的简化了我们拼装SQL的操作; MyBatis 采用功能强大的基于 OGNL 的表达式来简化操作: if choose(when,otherwise) trim(wher ...
- Python3_实例汇总
1.Python数字求和 # -*- codingLuft-8 -*- #Filename: test.py #author by:Leq #用户输入数字 num1 = input("输入第 ...
- sql server always on 2014安装配置
SQL 2014 AlwaysOn 搭建 原文:SQL 2014 AlwaysOn 搭建 AlwaysOn底层依然采用Windows 故障转移群集的机制进行监测和转移,因此也需要先建立Window ...
- React官网首页demo(单文件实现版)
本博客实现React官网首页上展示的demo, 为了方便直接采用单文件的形式, 如果想完整集成 在自己的项目中, 可以参考React官网的安装指南, 安装Create React App. hello ...
- linux网络基础设置 以及 软件安装
ifconfig #查看所有已激活的网卡信息 临时配置 #yum install net-tools -y 默认ifconfig是没有安装的,可能需要安装 ifconfig eth0 #查看单独一块网 ...