echarts实现多个立体柱状图

通过Echarts怎样实现立体柱状图 大家好,我是梁木由。之前在做大屏可视化项目时,UI设计了一个立体形状的柱状图,根据之前做的一些图表的项目没有能复用的,没有做过这种立体形状的图表,打开echarts也没看到有相关的demo,看下如何实现` 阅读详情

效果图:

 

代码如下:

 

// 1.后台返回数据
{
	"resultCode": 200,
	"message": "操作成功",
	"data": {
		"items": [
			{
				"areaCode": "320115",
				"areaType": 2,
				"areaName": "江宁区",
				"recorddate": 201129,
				"rateHb": 1,
				"changeCountHb": 2,
				"changeCountMeter": 14,
				"changeCountPhase": 7,
				"rateHxb": 1,
				"changeCountBranch": 14,
				"ratePhase": 1,
				"rateMeter": 1,
				"provinceId": null,
				"cityId": null,
				"districtId": null,
				"courtId": null,
				"substainId": null,
				"type": null,
				"count": null,
				"subName": null,
				"assetNumber": null
			}
		]
	}
}



// 2.数据格式化
function renderAccuracyChart(data) {
    var legends = [];
    var hbData = [];
    var meterData = [];
    var phaseData = [];
    $(data).each(function (idx,itm) {
        legends.push(itm.areaName);
        hbData.push(fmtNumber(itm.rateHb,2)*100);
        meterData.push(fmtNumber(itm.rateMeter,2)*100);
        phaseData.push(fmtNumber(itm.ratePhase,2)*100)
    });
    drawDiscernRatio('discern-ratio',legends,hbData,meterData,phaseData);
}



// 3.主方法
function drawDiscernRatio(elId,legends,hbData,meterData,phaseData) {
    // 绘制左侧面
    const wid = 20;
    const w1 = Math.sin(Math.PI/6) * wid; //4
    const w2 = Math.sin(Math.PI/3) * wid; // 6.8
    const snapHeight = wid / 4;
    const CubeLeft = echarts.graphic.extendShape({
        shape: {
            x: 0,
            y: 0
        },
        buildPath: function(ctx, shape) {
            // 会canvas的应该都能看得懂,shape是从custom传入的
            const xAxisPoint = shape.xAxisPoint
            const c0 = [shape.x, shape.y - 2]
            const c1 = [shape.x - w2, shape.y - w1 + snapHeight - 2]
            const c2 = [shape.x - w2, xAxisPoint[1] -w1 + snapHeight - 2]
            const c3 = [shape.x, xAxisPoint[1] - 2]
            ctx.moveTo(c0[0], c0[1]).lineTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).closePath()
        }
    })
// 绘制右侧面
    const CubeRight = echarts.graphic.extendShape({
        shape: {
            x: 0,
            y: 0
        },
        buildPath: function(ctx, shape) {
            const xAxisPoint = shape.xAxisPoint
            const c1 = [shape.x, shape.y - 2]
            const c2 = [shape.x, xAxisPoint[1] - 2]
            const c3 = [shape.x + w1, xAxisPoint[1] - w2 + snapHeight -2]
            const c4 = [shape.x + w1, shape.y - w2 + snapHeight - 2]
            ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath()
        }
    })
// 绘制顶面
    const CubeTop = echarts.graphic.extendShape({
        shape: {
            x: 0,
            y: 0
        },
        buildPath: function(ctx, shape) {
            const c1 = [shape.x, shape.y - 2]
            const c2 = [shape.x + w1, shape.y - w2 + snapHeight - 2] //右点
            const c3 = [shape.x - w2 + w1, shape.y - w1-w2 +  + snapHeight*2 - 2]
            const c4 = [shape.x - w2, shape.y - w1 + snapHeight - 2]
            ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath()
        }
    })
// 注册三个面图形
    echarts.graphic.registerShape('CubeLeft', CubeLeft)
    echarts.graphic.registerShape('CubeRight', CubeRight)
    echarts.graphic.registerShape('CubeTop', CubeTop)

    let option = {
        legend:{
            data: ['户变关系识别完成度','电表资产识别完成度','电表相位识别完成度'],
            selectedMode:false
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            },
            formatter: function(params){
                let item ='';
                item += params[0].name+'<br>'
                $(params).each(function (idx,itm) {
                    item += itm.seriesName+':'+itm.value +'<br>'
                });
                return item;
            }
        },
        grid: {
            left: '5%',
            right: '5%',
            top: '15%',
            bottom: '10%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            data: legends,
            axisLine: {
                show: true,
                lineStyle: {
                    color: '#AAA'
                }
            },
            axisTick: {
                show: false,
                length: 9,
                alignWithLabel: true,
                lineStyle: {
                    color: '#AAA'
                }
            },
            axisLabel: {
                fontSize: 20
            }
        },
        yAxis: {
            name:'识别完成度/%',
            type: 'value',
            nameTextStyle:{
                color:'#707e98'
            },
            axisLine: {
                show: true,
                lineStyle: {
                    color: '#AAA'
                }
            },
            axisLabel: {
                color: '#AAA'
            }
        },
        series: [{
            name:"户变关系识别完成度",
            type: 'custom',
            renderItem: (params, api) => {
                const location = api.coord([api.value(0), api.value(1)])
                location[0] = location[0] + wid*(-2);
                const xlocation = api.coord([api.value(0), 0]);
                xlocation[0] = xlocation[0] + wid*(-2);
                return {
                    type: 'group',
                    children: [{
                        type: 'CubeLeft',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#55B6F8'
                            },
                                {
                                    offset: 1,
                                    color: '#55B6F8'
                                }
                            ])
                        }
                    }, {
                        type: 'CubeRight',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#55B6F8'
                            },
                                {
                                    offset: 1,
                                    color: '#55B6F8'
                                }
                            ])
                        }
                    }, {
                        type: 'CubeTop',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#55B6F8'
                            },
                                {
                                    offset: 1,
                                    color: '#55B6F8'
                                }
                            ])
                        }
                    }]
                }
            },
            color:'#55B6F8',
            data: hbData
        },{
            name:"电表资产识别完成度",
            type: 'custom',
            renderItem: (params, api) => {
                const location = api.coord([api.value(0), api.value(1)]);
                location[0] = location[0] + wid*0;
                const xlocation = api.coord([api.value(0), 0]);
                xlocation[0] = xlocation[0] + wid*0;
                return {
                    type: 'group',
                    children: [{
                        type: 'CubeLeft',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#FB8C91'
                            },
                                {
                                    offset: 1,
                                    color: '#FB8C91'
                                }
                            ])
                        }
                    }, {
                        type: 'CubeRight',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#FB8C91'
                            },
                                {
                                    offset: 1,
                                    color: '#FB8C91'
                                }
                            ])
                        }
                    }, {
                        type: 'CubeTop',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#FB8C91'
                            },
                                {
                                    offset: 1,
                                    color: '#FB8C91'
                                }
                            ])
                        }
                    }]
                }
            },
            color:'#FB8C91',
            data: meterData
        },{
            name:"电表相位识别完成度",
            type: 'custom',
            renderItem: (params, api) => {
                const location = api.coord([api.value(0), api.value(1)]);
                location[0] = location[0] + wid*2;
                const xlocation = api.coord([api.value(0), 0]);
                xlocation[0] = xlocation[0] + wid*2;
                return {
                    type: 'group',
                    children: [{
                        type: 'CubeLeft',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#36D6D7'
                            },
                                {
                                    offset: 1,
                                    color: '#36D6D7'
                                }
                            ])
                        }
                    }, {
                        type: 'CubeRight',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#36D6D7'
                            },
                                {
                                    offset: 1,
                                    color: '#36D6D7'
                                }
                            ])
                        }
                    }, {
                        type: 'CubeTop',
                        shape: {
                            api,
                            xValue: api.value(0),
                            yValue: api.value(1),
                            x: location[0],
                            y: location[1],
                            xAxisPoint: xlocation
                        },
                        style: {
                            fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#36D6D7'
                            },
                                {
                                    offset: 1,
                                    color: '#36D6D7'
                                }
                            ])
                        }
                    }]
                }
            },
            color:'#36D6D7',
            data:phaseData
        }]
    }

    _WOO.c.drawEchart(elId,option);
}






 

03-echarts如何画立体柱状图 这个方法里面先创建三个形状的空壳子,并注册,如下图,并且注册完成以后在这个方法里面调用构建图表的方法initChart,在初始化页面的时候就不用调用initChart方法了。那么坐标是怎么看的,那么左上角的话就是(0,0),右上角就是(500,0),左下角就是(0,500),右下角就是(500,500),相当于右边是X轴正轴,往下看是Y轴正轴。根据官网提示,需要返回一个type为group的对象,并且将三个面都加到children里面,如下图,P2:【基础X轴坐标点+侧面宽度,顶部Y轴坐标点- 斜角高度】 阅读详情

相关推荐

echarts的图表立体感——实现立体柱状图和立体饼图的详细教程

准备HTML结构和容器,用于容纳图表的展示。初始化Echarts实例,并将之前创建的容器关联起来。配置图表所需的数据,包括x轴和对应的柱状图的高度值(对于立体柱状图)或每个扇区的名称和对应的数值(对于立体饼图)。配置图表的选项,包括样式、颜色和其他属性。渲染图表并呈现在页面中,通过调用Echarts实例的setOption方法将之前配置好的选项应用到图表中,并通过调用Echarts实例的render方法将图表渲染出来。

杜永康的博客 2万+

echarts 柱状图【立体】

立体柱状 echarts 柱状图上面显示文字 series: [ { name: 'a', tooltip: { show: false, }, data: this.data, type: 'bar', barWidth: 16, // 柱条的宽度,不设时自适应。 barGap: 200, // 不同系列的柱间距离

小菜张的博客 1万+

echarts实现立体柱状图

基于象形柱图pictorialBar实现。 var rocket = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAAAeCAYAAACPOlitAAAAAXNSR0IArs4c6QAADOdJREFUaEPFmttvXNd1xn9r7TNnOBzeRIkSRetiW7Lk0q5tWXIcSS2qFrENFMlLADtNAyc24tZAC/ShL+1b1H+hQAuoqKvIjlvAfstLYSNFpCRO4tiMGsryTfcL

ʚ菲菲的博客ɞ 2359

Echarts使用平面方法绘制三维立体柱状图表

Echarts使用平面方法绘制三维立体柱状图表。使用Echarts的自定义系列custom,使用了三个 polygon 类型的图形元素来绘制立方柱状图的三个面。通过调整坐标点的位置来确定形状。在设置不同的渐变色,就可以实现立体效果。

qq_53911056的博客 5798

Echarts立体柱状图

echarts绘制漂亮的立体柱状图(超详细) 为了做一个漂亮的立体柱状图,几乎吧echarts所有的柱状图都看了一遍,一遍遍的改,终于绘制出我想要的效果,下面是代码: HTML: <div class="content bgBox"> <div class="firstTitle"> <p class="titleName">购买力最强</p> </div> <div id="buyTop" style="width: 100%;h

Swallow的博客 1万+

04-echarts-立体柱状图扩展

echarts立体柱状图扩展

jiuliangliang的博客 1553

echarts 立体柱状图(多个柱状图)

echarts 立体柱状图(多个柱状图)

cjy_fly的博客 5812

使用echarts实现立体-柱状图

效果图 https://mp.youkuaiyun.com/mp_blog/creation/editor/125918054 用echarts实现立体-柱状图ECharts,一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE9/10/11,Chrome,Firefox,Safari等),底层依赖矢量图形库 ZRender,提供直观,交互丰富,可高度个性化定制的数据可视化图表。ECharts 提供了常规的折线图、柱状图、散点图、饼图、K线图,用于统计的盒形图,用于地理数据可视化的地图、热力图、线图,用于关系数据可视化的关系图、treemap、旭日图,多维数据可视化的平行坐标,还有用于 BI 的漏斗图,仪表盘,并且支持图与图之间的混搭ECharts 内置的 dataset 属性(4.0+)支持直接传入包括二维表,key-value 等多种格式的数据源,通过简单的设置 encode 属性就可以完成从数据到图形的映射,这种方式更符合可视化的直觉,省去了大部分场景下数据转换的步骤,而且多

【Echarts系列】—— 实现电池图、3D立体圆形柱状图

【代码】【Echarts系列】—— 实现电池图、3D立体圆形柱状图。

Hannah_wy的博客 1917

手动以及使用torch.nn实现前馈神经网络实验

手动以及使用torch.nn实现前馈神经网络 手动实现前馈神经网络解决上述回归、二分类、多分类任务 利用torch.nn解决上述回归、二分类、多分类任务 在多分类任务中使用至少三种不同的激活函数 对多分类任务中的模型评估隐藏层层数和隐藏单元个数对实验结果的影响

m0_52910424的博客 9373

Keil环境下单片机串口通信实战:如何用printf发送中文(附完整代码)

本文详细解析了在Keil开发环境下,单片机通过串口通信发送中文信息时产生乱码的根本原因及解决方案。核心在于理解并统一编码(如GB2312或UTF-8),并正确重定向printf函数。文章提供了针对STC89C52和STM32F103的完整代码示例,涵盖工程配置、编码设置、调试技巧,帮助开发者实现稳定可靠的中文串口输出。

weixin_29168675的博客 469

漏刻有时数据可视化Echarts组件开发(6):象形柱图实现水塔水位的动画

构建容器 <div id="main"></div> 封装函数 // 基于准备好的dom,初始化echarts实例; function makeBar(dataList, level, colorList, id) { var myChart = echarts.init(document.getElementById(id)); option = { tooltip: { trigg.

挖掘大数据价值,让决策者快速洞悉趋势,让大众读懂数据背后的故事。 1215

ArcGIS Pro中文帮助离线包安装指南:版本匹配与操作详解

本文详细指导如何为ArcGIS Pro安装中文帮助离线包,解决在线帮助访问不畅的问题。核心在于确保软件版本与离线包的精确匹配,并提供了从版本查看、离线包获取、安装步骤到软件内配置的完整操作流程。文中重点强调了版本匹配的重要性,并分享了高效使用本地帮助搜索及管理多版本帮助的实用技巧。

whisky的博客 991

echarts 多个3D柱状图

【代码】echarts 多个3D柱状图。

qq_39877681的博客 613

从内外参推导IPM变换方程及代码实现(生成AVM环视拼接图)

最近想实现AVM拼接,看了不少博客和论文,不过比较愚钝,一直没能很好理解原理,尤其是怎么在实现时把下文中Z1和Z2消除的,所以严谨的推导了一下对应的公式,如有不对,水平有限,烦请指出~IPM变换(逆透视变换),顾名思义,即将正常透视效应消除的变换,变换结果为鸟瞰图BEV(俯视图);AVM环视拼接一般是将车身前后左右的四个鱼眼相机拼接成环视图(也是俯视),其使用的单应矩阵将四个相机转到同一个俯视坐标系。

mxdsdo09的博客 4175

在VM虚拟机的MobaXterm下安装JDK17

本文介绍了在Linux系统下安装配置JDK17的完整步骤:1)从Oracle或OpenJDK官网下载Linux版JDK17压缩包;2)上传至/usr/local目录;3)解压安装包;4)通过编辑/etc/profile文件配置环境变量,添加JAVA_HOME和PATH路径;5)使用source命令使配置生效;6)通过javac -version验证安装是否成功。整个过程涵盖了从下载到环境配置的完整流程,确保Java开发环境正确设置。

qq_2937655951的博客 442

echarts3D立体柱状图

【代码】echarts3D立体柱状图。

m0_56277111的博客 436

HBuilderx 坑 之前没问题 改了几行代码 小程序上传报分包大小超过限制

Error: 分包大小超过限制,main package source size 4199KB exceed max limit 2MB [20221213 10:08:06][wx432abdb518bdc1eb]下面的我提示是都没超过2M,却提示我超过限制,代码改了不到20行吧,之前是正常上传的.....,比如这类,要压缩的,前提是没压缩过的,但是我肯定提交的时候是压缩的,没勾选此项的要注意,如果本文解决了你的困扰 来波666不为过吧!

爱就码上行动,奔赴热爱,追光而行。愿你带着从容与热爱,拥抱每一天的惊喜与美好 5221

echarts实现单3D立体柱状图

效果图: 实现代码: function getEcharts3DBar (xAxisData, data, colorType) { var colorArr = []; if (colorType == '01') { colorArr = ["#2886c6", "#50bfda", "#89e3ec"]; } else { colorArr = ["#28c1c6", "#50dac0", "#87e8c7"]; } var c

Dalin0929的博客 1万+

ROS机器人未知环境自主探索功能包explore_lite最全源码详细解析(一)

本系列文章主要针对ROS机器人常使用的未知环境自主探索功能包explore_lite展开全源码的详细解析,并进行概括总结。 本系列文章共包含六篇文章,前五篇文章主要介绍explore_lite功能包中 explore.cpp、costmap_tools.h、frontier_search.cpp、costmap_client.cpp等源码实现文件中全部函数的详细介绍,第六篇文章进行概括总结,包含自主探索功能包explore_lite的简介,实现未知环境自主探索功能的原理及流程总结,效果演示,使用功能包

慕羽★的博客 3939

【AI智能体】Codex 开发聚合搜索应用项目实战操作详解

Codex 开发聚合搜索应用项目实战操作详解

congge 3100

echarts - 自定义形状 - 实现立体柱状图

如果需要复杂的图表样式,echarts 自带的 series 类型无法满足,那么就可以使用 custom 类型,这时就需要通过 canvas 手动绘制图表的形状了。

qq_35432583的博客 6159

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

echarts 实现立体柱状图

<div class="dayFluxDetail" id="mainCahrts" style=" width: 100%; height: 8.5rem;"></div> // 配置项 // mainCahrts // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('mainCahrts')); const data = [220

liumengyue的博客 2万+

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

echarts 在 vue项目中使用及立体柱状图的实现

vue 项目中使用echarts 首先安装echarts依赖 cnpm install echarts -S / yarn add echarts 在需要使用echarts图表的组件内引入 import echarts from ‘echarts’ 通过ref进行标记 <div ref="echarts" style="width:100%;height:100%" class="echarts"></div> 在mounted内进行实例化 mounted() { thi

JKC_HOWL的博客 1929

echarts的柱状图立体效果解决方案 echarts.graphic.LinearGradient

最近用的echarts的柱状图,客户需要有立体的效果,需要echarts的渐变色生成器echarts.graphic.LinearGradient实现,特记录一下解决方法: 效果图如下 代码如下(主要配置color): var myChart = echarts .init(document.getElementById('main3'), 'macarons'); // ...

Java in my life 2万+

echarts实现3D立体堆叠柱状图

基于这篇博客的灵感,在其基础上做了一些改动; https://blog.youkuaiyun.com/Dalin0929/article/details/111906862 效果图 实现代码: var legends = ['A相','B相','C相']; var name = ['01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00']..

SpringHASh的博客 6799
上一篇: Linux使用xshell配合nginx代理打隧道代理到本地端口
下一篇: echarts实现自定义仪表盘图例
宁漂打工仔
博客等级 码龄9年 1万+粉丝 153原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宁漂打工仔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值