分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

Js + echarts 漏斗图

发布时间:2023-09-06 02:11责任编辑:沈小雨关键词:暂无标签
var drawFunnelChart=function(chartId,titleText, dataArr,nameArr,gapArr,minValue){
???var option = {
???????title: {
???????????text: titleText,
???????????subtext: ‘‘
???????},
???????tooltip: {
???????????trigger: ‘item‘,
???????????formatter: "{a} <br/>{b} : {c}"
???????},
???????legend: {
???????????data: nameArr
???????},
???????calculable: true,
???????color: [‘#3C8DBC‘,‘#B1D1E4‘],
???????series: [
???????????{
???????????????name:‘漏斗图‘,      //多个对象叠加,生成一个图标多个label
???????????????type:‘funnel‘,
???????????????left: ‘20%‘,
???????????????top: 60,
???????????????//x2: 80,
???????????????bottom: 60,
???????????????width: ‘60%‘,
???????????????min: minValue,
???????????????/* max: maxValue,*/
???????????????minSize: ‘20%‘,
???????????????maxSize: "100%",
???????????????sort: ‘none‘,
???????????????//funnelAlign:‘center‘,
???????????????gap: 2,
???????????????label: {
???????????????????normal: {
???????????????????????show: true,
???????????????????????position: ‘center‘,
???????????????????????formatter: function(data){
???????????????????????????return data.value
???????????????????????},
???????????????????????rich: {
???????????????????????????a: {
???????????????????????????????color: ‘#999‘,
???????????????????????????????lineHeight: 18,
???????????????????????????????align: ‘center‘
???????????????????????????},
???????????????????????????hr: {
???????????????????????????????borderColor: ‘#aaa‘,
???????????????????????????????width: ‘100%‘,
???????????????????????????????borderWidth: 0.5,
???????????????????????????????height: 0
???????????????????????????},
???????????????????????????b: {
???????????????????????????????color: ‘#000‘,
???????????????????????????????fontSize: 12,
???????????????????????????????lineHeight: 33
???????????????????????????},
???????????????????????????per: {
???????????????????????????????color: ‘#000‘,
???????????????????????????????/*backgroundColor: ‘#fff‘,*/
???????????????????????????????padding: [2, 4],
???????????????????????????????borderRadius: 2
???????????????????????????}
???????????????????????}
???????????????????},
???????????????????emphasis: {
???????????????????????textStyle: {
???????????????????????????fontSize: 12
???????????????????????}
???????????????????}
???????????????},
???????????????labelLine: {
???????????????????normal: {
???????????????????????length: 10,
???????????????????????lineStyle: {
???????????????????????????width: 1,
???????????????????????????type: ‘solid‘
???????????????????????}
???????????????????}
???????????????},
???????????????itemStyle: {
???????????????????normal: {
???????????????????????borderColor: ‘#fff‘,
???????????????????????borderWidth: 1
???????????????????}
???????????????},
???????????????data: dataArr
???????????},
???????????{
???????????????name:‘漏斗图‘,
???????????????type:‘funnel‘,
???????????????left: ‘20%‘,
???????????????top: 60,
???????????????//x2: 80,
???????????????bottom: 60,
???????????????width: ‘60%‘,
???????????????// height: {totalHeight} - y - y2,
???????????????min: minValue,
???????????????/* max: maxValue,*/
???????????????minSize: "20%",
???????????????maxSize: "100%",
???????????????sort: ‘none‘, ??????//不排序,按照给定数据的顺序
???????????????//funnelAlign:‘center‘,
???????????????gap: 2,
???????????????label: {
???????????????????normal: {
???????????????????????show: true,
???????????????????????position: ‘left‘,
???????????????????????formatter: function(data){  //多个对象叠加,生成一个图标多个label
 ???????????????????????????//if(data.dataIndex <= gapArr.length-1){
???????????????????????????????return ‘{per|转化率:‘ + gapArr[data.dataIndex] + ‘}‘;
???????????????????????????//}
???????????????????????},
???????????????????????rich: {
???????????????????????????per: {
???????????????????????????????color: ‘#000‘,/*‘#3CABE7‘,*/
???????????????????????????????backgroundColor: ‘#fff‘,
???????????????????????????????padding: [2, 4],
???????????????????????????????borderRadius: 2
???????????????????????????}
???????????????????????}
???????????????????},
???????????????????emphasis: {
???????????????????????textStyle: {
???????????????????????????fontSize: 12
???????????????????????}
???????????????????}
???????????????},
???????????????labelLine: {
???????????????????normal: {
???????????????????????length: 10,
???????????????????????lineStyle: {
???????????????????????????width: 1,
???????????????????????????type: ‘solid‘
???????????????????????}
???????????????????}
???????????????},
???????????????itemStyle: {
???????????????????normal: {
???????????????????????borderColor: ‘#fff‘,
???????????????????????borderWidth: 1
???????????????????}
???????????????},
???????????????data: dataArr
???????????},
???????????{
???????????????name:‘漏斗图‘,
???????????????type:‘funnel‘,
???????????????left: ‘20%‘,
???????????????top: 60,
???????????????//x2: 80,
???????????????bottom: 60,
???????????????width: ‘60%‘,
???????????????// height: {totalHeight} - y - y2,
???????????????min: minValue,
???????????????/*max: maxValue,*/
???????????????minSize: "20%",
???????????????maxSize: "100%",
???????????????sort: ‘none‘,
???????????????//funnelAlign:‘center‘,
???????????????gap: 2,
???????????????label: {
???????????????????normal: {
???????????????????????show: true,
???????????????????????position: ‘right‘,
???????????????????????formatter: function(data){//多个对象叠加,生成一个图标多个label
 ???????????????????????????return ‘{b|‘ + data.name + ‘}‘
???????????????????????},
???????????????????????rich: {
???????????????????????????b: {
???????????????????????????????color: ‘#000‘,
???????????????????????????????fontSize: 12,
???????????????????????????????lineHeight: 33
???????????????????????????},

???????????????????????}
???????????????????},
???????????????????emphasis: {
???????????????????????textStyle: {
???????????????????????????fontSize: 12
???????????????????????}
???????????????????}
???????????????},
???????????????labelLine: {
???????????????????normal: {
???????????????????????length: 10,
???????????????????????lineStyle: {
???????????????????????????width: 1,
???????????????????????????type: ‘solid‘
???????????????????????}
???????????????????}
???????????????},
???????????????itemStyle: {
???????????????????normal: {
???????????????????????borderColor: ‘#fff‘,
???????????????????????borderWidth: 1
???????????????????}
???????????????},
???????????????data: dataArr
???????????},
???????]
???};

???var myChart=echarts.init(document.getElementById(chartId));
???myChart.setOption(option);
???window.addEventListener(‘resize‘,myChart.resize)
};

Js + echarts 漏斗图

原文地址:https://www.cnblogs.com/KellyChen/p/9520967.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved