echart立体柱状图
var MyCubeRect = echarts.graphic.extendShape({ shape: { x: 0, y: 0, }, buildPath: function (ctx, shape) { const api = shape.api; const xAxisPoint = api.coord([shape.xValue, 0]); const p0 = [shape.x - 18, shape.y - 10]; const p1 = [xAxisPoint[0] - 18, xAxisPoint[1] - 5] const p2 = [xAxisPoint[0], xAxisPoint[1]] const p3 = [shape.x, shape.y] ctx.moveTo(p0[0], p0[1]); //4 ctx.lineTo(p1[0], p1[1]); //3 ctx.lineTo(p2[0], p2[1]); //3 ctx.lineTo(p3[0], p3[1]); //3 ctx.closePath(); } }); var MyCubeShadow = echarts.graphic.extendShape({ shape: { x: 0, y: 0, }, buildPath: function (ctx, shape) { const api = shape.api; const xAxisPoint = api.coord([shape.xValue, 0]); const p0 = [shape.x + 18, shape.y - 8]; const p1 = [xAxisPoint[0] + 18, xAxisPoint[1] - 5] const p2 = [xAxisPoint[0], xAxisPoint[1]] const p3 = [shape.x, shape.y] ctx.moveTo(p0[0], p0[1]); //4 ctx.lineTo(p1[0], p1[1]); //3 ctx.lineTo(p2[0], p2[1]); //3 ctx.lineTo(p3[0], p3[1]); //3 ctx.closePath(); } }); var MyCubeTop = echarts.graphic.extendShape({ shape: { x: 0, y: 0, }, buildPath: function(ctx, shape) { const c1 = [shape.x, shape.y] const c2 = [shape.x + 19, shape.y - 8] const c3 = [shape.x + 5, shape.y - 22] const c4 = [shape.x - 18, shape.y - 10] 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('MyCubeRect', MyCubeRect); echarts.graphic.registerShape('MyCubeShadow', MyCubeShadow); echarts.graphic.registerShape('MyCubeTop', MyCubeTop); var seriesData = [20,100,50,44,12]; option = { grid: { height: 300 }, xAxis: { data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'] }, yAxis: { type: 'value' },
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
series: [{ type: 'custom', data: seriesData, renderItem: function (params, api) { let location = api.coord([api.value(0), api.value(1)]); return { type: 'group', children: [ { type: 'MyCubeRect', shape: { api, xValue: api.value(0), yValue: api.value(1), x: location[0], y: location[1] }, style: { fill: 'rgba(0,178,255,1)',//平面颜色 stroke: '#555', } }, { type: 'MyCubeShadow', shape: { api, xValue: api.value(0), yValue: api.value(1), x: location[0], y: location[1] }, style: { fill: 'rgba(0,178,255,1)',//平面颜色 stroke: '#555', } }, { type: 'MyCubeTop', shape: { api, xValue: api.value(0), yValue: api.value(1), x: location[0], y: location[1], xAxisPoint: api.coord([api.value(0), 0]), }, style: { fill: 'rgba(0,178,255,1)',//平面颜色 stroke: '#555', } } ] }; } }] };
一辈子说长不长,说短不短,努力做好两件事:第一件事爱生活,爱身边的人,爱自己;第二件事是好好学习,好好工作,实现自己的人生价值观,而不仅仅是为了赚钱
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
· Linux系列:如何调试 malloc 的底层源码
· 对象命名为何需要避免'-er'和'-or'后缀
· JDK 24 发布,新特性解读!
· C# 中比较实用的关键字,基础高频面试题!
· .NET 10 Preview 2 增强了 Blazor 和.NET MAUI
· SQL Server如何跟踪自动统计信息更新?