echarts饼图
1、添加点击事件并跳转到不同的页面
// 路径配置
require.config({
paths: {
echarts: 'http://echarts.baidu.com/build/dist/'
}
});
// 使用
var option;(设置全局变量)
require(
[
'echarts',
'echarts/chart/pie' // 使用柱状图就加载pie模块,按需加载
],
function (ec) {
// 基于准备好的dom,初始化echarts图表
var myChart = ec.init(document.getElementById('chartsmain1'));
var ecConfig = require('echarts/config');
myChart.on(ecConfig.EVENT.CLICK, eConsole);
option = {
title : {
text: '最常用社交媒体占比',
x:'center'
},
legend: {
orient : 'vertical',
x : 'left',
y:'bottom',
data:['QQ','微博','微信']
},
series : [
{
name:'访问来源',
type:'pie',
radius : '55%',
clickable : true,
center: ['50%','60%'],
data:[
{
value:335,
name:'QQ',
itemStyle:{
normal:{
color:'rgb(255,192,0)'
}
}
},
{
value:310,
name:'微博',
itemStyle:{
normal:{
color:'rgb(1,175,80)'
}
}
},
{
value:234,
name:'微信',
itemStyle:{
normal:{
color:'rgb(122,48,158)'
}
}
}
]
}
]
};
// 为echarts对象加载数据
myChart.setOption(option);
});
function eConsole(option) {
//获得option的值做出判断,添加链接
if(option.name=="QQ"){
window.open("http://www.runoob.com/")
}else if(option.name=="微博"){
window.open("http://www.weibo.com/")
}else{
window.open("http://www.baidu.com/")
}
}
注意:加红色的部分为饼图添加点击事件所需的代码
2、饼图颜色和折线图的线条颜色一一对应应当保持一致并不依赖默认颜色
饼图
data:[
{
value:335,
name:'QQ',
itemStyle:{
normal:{
color:'rgb(255,192,0)'
}
}
},
{
value:310,
name:'微博',
itemStyle:{
normal:{
color:'rgb(1,175,80)'
}
}
},
{
value:234,
name:'微信',
itemStyle:{
normal:{
color:'rgb(122,48,158)'
}
}
}
]
红色的部分是修改默认颜色为自定义颜色
折线
series : [
{
name:'QQ',
type:'line',
stack: '总量',
data:[120, 132, 101, 134, 90, 230, 210],
itemStyle:{
normal:{
color:'rgb(255,192,0)',
}
}
},
{
name:'微信',
type:'line',
stack: '总量',
data:[220, 182, 191, 234, 290, 330, 310],
itemStyle:{
normal:{
color:'rgb(122,48,158)',
}
}
},
{
name:'微博',
type:'line',
stack: '总量',
data:[150, 232, 201, 154, 190, 330, 410],
itemStyle:{
normal:{
color:'rgb(1,175,80)',
}
}
}
]
效果图
echarts饼图的更多相关文章
- ECharts饼图试玩
处理类似提交问卷的数据,要生成图表,用了ECharts,好方便的. 简陋效果: 1.表单存储 有单选和多选题,单选直接存储各选项数字值,1,2,3,4...中一个:多选用|分隔存储选项值,如1|3,2 ...
- 将数据动态加载到Echarts饼图中
需求描述 Echarts中的官方示例是将数据的设定写好在页面的配置项中的,但在实际的开发展示中,我们需要按照需求通过调用后台的接口获取数据,再将数据加载到特定的Echarts饼图中. 实现效果 实现步 ...
- Vue Echarts 饼图设置默认选中一个
Vue Echarts 饼图设置默认选中一个 myChart.setOption(data) // data伟echarts所需要传入的参数,就是配置参数最多的那个玩意 myChart.dispatc ...
- 百度ECHARTS 饼图使用心得 处理data属性
做过CRM系统的童鞋应该都或多或少接触过hicharts或者echarts等数据统计插件.用过这两款,个人感觉echarts的画面更好看.至于功能,只有适合自己的才是最好的. 今天来说说我使用echa ...
- echarts饼图--数据交互
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- echarts饼图不显示数据为0的数据
首先阐述下为什么会有这个需求,这个和echarts自身的显示效果有关. 如果你选择的展示图形为饼图,然后你的数据里有一条数据为0,那么展示的数据就为一条直线,看上去效果并不好, 会很突兀. 当然如果你 ...
- echarts饼图配置
js引用和配置div <div id="container" style="height: 100%"></div> <scrip ...
- Echarts饼图显示模板
图表类型,必要参数!如为空或不支持类型,则该系列数据不被显示.可选为: 'line'(折线图) | 'bar'(柱状图) | 'scatter'(散点图) | 'k'(K线图) 'pie'(饼图) | ...
- ECharts饼图制作分析
ECharts,缩写来自Enterprise Charts,商业级数据图表,一个纯Javascript的图表库,可以流畅的运行在PC和移动设备上,兼容当前绝大部分浏览器(IE6/7/8/9/10/11 ...
随机推荐
- [LeetCode] Nested List Weight Sum 嵌套链表权重和
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- [LeetCode] Wiggle Sort 摆动排序
Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] < ...
- 分享基于EF+MVC+Bootstrap的通用后台管理系统及架构
基于EF+MVC+Bootstrap构建通用后台管理系统,集成轻量级的缓存模块.日志模块.上传缩略图模块.通用配置及服务调用, 提供了OA.CRM.CMS的原型实例,适合快速构建中小型互联网及行业 ...
- 《MySQL 必知必会》读书总结
这是 <MySQL 必知必会> 的读书总结.也是自己整理的常用操作的参考手册. 使用 MySQL 连接到 MySQL shell>mysql -u root -p Enter pas ...
- ie11的DOM管理器报错
IE11 Windows7下F12 DOC资源管理器不能用Exception in window.onload: Error: An error has ocurredJSPlugin.3005--- ...
- MySQL字符串函数substring:字符串截取
MySQL 字符串截取函数:left(), right(), substring(), substring_index().还有 mid(), substr().其中,mid(), substr() ...
- caffe添加自己的层
首先修改src/caffe/proto/下的caffe.proto,修改好后需要编译 然后修改include/caffe/layers/logwxl_layer.hpp 然后修改src/caffe/l ...
- the user operation is waiting
eclipse在编辑完代码保存的时候,弹出一个进度框,等N长时间,标题是"user operation is waiting",里面显示的是building workspace的进 ...
- 【BZOJ-2653】middle 可持久化线段树 + 二分
2653: middle Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 1298 Solved: 734[Submit][Status][Discu ...
- CGI, FastCGI, WSGI, uWSGI, uwsgi简述
CGI 通用网关接口(Common Gateway Interface/CGI)是一种重要的互联网技术,可以让一个客户端,从网页浏览器向执行在网络服务器上的程序请求数据.CGI描述了服务器和请求处理程 ...