Echart 极坐标 方位距离图 图标符号旋转以及大小 颜色渐变

本文主要是介绍Echart 极坐标 方位距离图 图标符号旋转以及大小 颜色渐变,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

背景:

参与一个交互式图表项目,客户有一个极坐标对比需求,展示不同方位不同距离的不同类型的指标数据。具体到属性字段则是:
来源、距离、方位、ID、旋转角度、大小
先看效果图:

技术点:

图例说明:距离为图例的径向轴,方位为图例的角度轴,不同类型需要用不同颜色,不同图标符号进行展示且需要根据旋转角度旋转以及大小参数绘制。
这是一个非常规极坐标图,首先要解决的是角度问题,从0到180(-180)再到0,按照常规思维极坐标的角度应该是一个排序规则而且默认是由小到大,此处的解决思路是:

1.方位问题

方位范围为0°到180°(-180°)再到0°,及整体的极坐标为360°,在此原则下需要注意一下问题:
a.角度轴(angleAxis)的刻度按照要求30°为一个刻度,则在角度小于等于180°保留原值,大于等于180°的需要减去360°。即:

"angleAxis": {max:360,min:0,"axisLabel": {"show": true,"color": "#000000","fontSize": 10,"rotate": 0,"formatter":function (value, index) {if(value>180){return value-360 + '°';}else{return value + '°';}}},
}

b. 角度轴(angleAxis)的值(用户传递过来的方位)在0到180°时保留原值,-180°到0°时需要加上360°。

2.分组、图标、旋转、大小、颜色渐变

这些就是对应echart的相关属性
分组就是series不同数组即可。
图标对应的是series的symbol属性,如:"symbol": "arrow",
旋转对应的是series里具体数据的symbolRotate,如: "symbolRotate":76,
大小对应的是series的symbolSize,如:

"symbolSize":function(val){if(val[4]<3)return 3;elsereturn val[4]*2},

颜色渐变:
 

 "itemStyle": {"color": {"type": "radial","x": 0.4,"y": 0.3,"r": 1,"colorStops": [{"offset": 0,"color": "rgba(1,122,255,0.6)"},{"offset": 1,"color": "rgba(1,122,255,1)"}],"global": false}},

整理完以上技术点,结合测试数据就可以完成这个特殊极坐标的处理。

完整代码

option = {"title": {"text": "极坐标","textStyle": {"fontWeight": "bold","fontSize": 14,"color": "#000000","fontStyle": "normal"},"show": true,"left": "8px","top": "8px"},"grid": {"x": 0,"y": 0,"x2": 0,"y2": 0},"xAxis": {"min": -100,"max": 100,"axisTick": {"show": false},"axisLine": {"show": true,"lineStyle": {"color": "#CCCCCC","width": 1,"style": "solid"}},"axisLabel": {"show": false},"splitLine": {"show": false}},"yAxis": {"min": -100,"max": 100,"axisTick": {"show": false},"axisLine": {"show": true,"lineStyle": {"color": "#CCCCCC","width": 1,"style": "solid"}},"axisLabel": {"show": false},"splitLine": {"show": false}},"angleAxis": {max:360,min:0,"axisLabel": {"show": true,"color": "#000000","fontSize": 10,"rotate": 0,"formatter":function (value, index) {if(value>180){return value-360 + '°';}else{return value + '°';}}},"splitLine": {"show": true,"lineStyle": {"color": "#CCCCCC","width": 1,"style": "solid"}},"axisLine": {"show": true,"lineStyle": {"color": "#cccccc","width": 1,"style": "solid"}},"show": true,"axisTick": {"show": true,"lineStyle": {"color": "#cccccc","width": 1,"style": "solid"}}},"radiusAxis": {"type": "category","data": ["100","300","600"],"z": 10,"axisLabel": {"show": true,"color": "#000000","fontSize": 10,"rotate": 0,"formatter": "{value}"},"axisTick": {"show": false,"lineStyle": {"color": "#cccccc","width": 1,"style": "solid"}},"axisLine": {"show": false,"lineStyle": {"color": "#cccccc","width": 1,"style": "solid"}},"boundaryGap": true,"splitLine": {"show": true,"lineStyle": {"color": "#CCCCCC","width": 1,"style": "solid"}},"show": true,"position": "left","name": "","nameTextStyle": {"color": "#000000","fontSize": 10}},"polar": {"radius": ["10%","70%"]},"series": [{"name": "类别1","type": "scatter","data": [{"value": ["100",-30,'a128',55,16],"symbolRotate":55,"dimensionList": [{"id": "58295c72-e13a-4bf5-80e6-16d4253dec53","value": "100"}],"quotaList": [{"id": "84c1ad50-f031-4ee3-99d5-343761639e98"}],},{"value": ["300",110,'a127',20,25],"symbolRotate":20,"dimensionList": [{"id": "58295c72-e13a-4bf5-80e6-16d4253dec53","value": "300"}],"quotaList": [{"id": "84c1ad50-f031-4ee3-99d5-343761639e98"}]},{"value": ["600",6.54,'a126',76,30],"symbolRotate":76,"dimensionList": [{"id": "58295c72-e13a-4bf5-80e6-16d4253dec53","value": "600"}],"quotaList": [{"id": "84c1ad50-f031-4ee3-99d5-343761639e98"}]}],"itemStyle": {"color": {"type": "radial","x": 0.4,"y": 0.3,"r": 1,"colorStops": [{"offset": 0,"color": "rgba(1,122,255,0.6)"},{"offset": 1,"color": "rgba(1,122,255,1)"}],"global": false}},"symbol": "arrow","symbolSize":function(val){if(val[4]<3)return 3;elsereturn val[4]*2},"label": {"show": false,"position": "inside","color": "#000000","fontSize": 10,"formatter": "{c}","gaugeFormatter": "{value}","labelLine": {"show": true},"gaugeLabelFormatter": {"type": "value","unit": 1,"suffix": "","decimalCount": 2,"thousandSeparator": true},"reserveDecimalCount": 2,"labelContent": ["dimension","proportion"],"modifyName": "show","propertyName": "label-selector"},"z": 100,"coordinateSystem": "polar","selectedMode": true,"select": {"itemStyle": {"shadowBlur": 2}},},{"name": "类别2","type": "scatter","data": [{"value": ["100",7.77,'a123',50,22],"symbolRotate":50,"dimensionList": [{"id": "58295c72-e13a-4bf5-80e6-16d4253dec53","value": "100"}],"quotaList": [{"id": "acee783e-c4e7-4616-8fbf-e1e5b8e6f411"}]},{"value": ["300",-90,'a124',90,23],"symbolRotate":90,"dimensionList": [{"id": "58295c72-e13a-4bf5-80e6-16d4253dec53","value": "300"}],"quotaList": [{"id": "acee783e-c4e7-4616-8fbf-e1e5b8e6f411"}]},{"value": ["600",9.08,'a125',0,15],"symbolRotate":0,"dimensionList": [{"id": "58295c72-e13a-4bf5-80e6-16d4253dec53","value": "600"}],"quotaList": [{"id": "acee783e-c4e7-4616-8fbf-e1e5b8e6f411"}]}],"itemStyle": {"color": {"type": "radial","x": 0.4,"y": 0.3,"r": 1,"colorStops": [{"offset": 0,"color": "rgba(98,186,70,0.6)"},{"offset": 1,"color": "rgba(98,186,70,1)"}],"global": false}},"symbol": "triangle","symbolSize":function(val){if(val[4]<3)return 3;elsereturn val[4]*2},"label": {"show": false,"position": "inside","color": "#000000","fontSize": 10,"formatter": "{c}","gaugeFormatter": "{value}","labelLine": {"show": true},"gaugeLabelFormatter": {"type": "value","unit": 1,"suffix": "","decimalCount": 2,"thousandSeparator": true},"reserveDecimalCount": 2,"labelContent": ["dimension","proportion"],"modifyName": "show","propertyName": "label-selector"},"z": 100,"coordinateSystem": "polar","selectedMode": true,"select": {"itemStyle": {"shadowBlur": 2}}}],"legend": {"show": true,"data": ["类别1","类别2"],"textStyle": {"color": "#000000","fontSize": 10},"left": "center","bottom": "8px","orient": "horizontal","icon": "circle","pageIconColor": "#000000","pageIconInactiveColor": "#8c8c8c"},"color": ["#017AFF","#62BA46","#FFC601","#F7821B","#FF5257","#F74F9E","#CC9494","#955FBC","#A55057"],"tooltip": {"show": true,"trigger": "item","confine": true,"textStyle": {"fontSize": 10,"color": "#000000"},"formatter": function(params){console.log(params)return  "ID:"+params.value[2]+"<br />距离:"+params.value[0]+"<br />方位:"+params.value[1]+"°<br />旋转:"+params.value[3]+"°"},"backgroundColor": "#FFFFFF","modifyName": "trigger","propertyName": "tooltip-selector","borderColor": "#FFFFFF","appendToBody": true}
};

这篇关于Echart 极坐标 方位距离图 图标符号旋转以及大小 颜色渐变的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/705679

相关文章

poj 2187 凸包or旋转qia壳法

题意: 给n(50000)个点,求这些点与点之间距离最大的距离。 解析: 先求凸包然后暴力。 或者旋转卡壳大法。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#include <s

Android 10.0 mtk平板camera2横屏预览旋转90度横屏拍照图片旋转90度功能实现

1.前言 在10.0的系统rom定制化开发中,在进行一些平板等默认横屏的设备开发的过程中,需要在进入camera2的 时候,默认预览图像也是需要横屏显示的,在上一篇已经实现了横屏预览功能,然后发现横屏预览后,拍照保存的图片 依然是竖屏的,所以说同样需要将图片也保存为横屏图标了,所以就需要看下mtk的camera2的相关横屏保存图片功能, 如何实现实现横屏保存图片功能 如图所示: 2.mtk

PDFQFZ高效定制:印章位置、大小随心所欲

前言 在科技编织的快节奏时代,我们不仅追求速度,更追求质量,让每一分努力都转化为生活的甜蜜果实——正是在这样的背景下,一款名为PDFQFZ-PDF的实用软件应运而生,它以其独特的功能和高效的处理能力,在PDF文档处理领域脱颖而出。 它的开发,源自于对现代办公效率提升的迫切需求。在数字化办公日益普及的今天,PDF作为一种跨平台、不易被篡改的文档格式,被广泛应用于合同签署、报告提交、证书打印等各个

[环境配置]ubuntu20.04安装后wifi有图标但是搜不到热点解决方法

最近刚入手一台主机,暗影精灵8plus电竞主机,安装ubuntu后wifi怎么都搜不到热点,前后重装系统6次才算解决问题。这个心酸历程只有搞技术人才明白。下面介绍我解决过程。 首先主机到手后是个windows10系统,我用无线网连接了一下,可以正常上网,说明主机有无限网卡且正常。然后我就直接开始安装Ubuntu20.04了,安装成功后发现wifi有图标但是搜不到热点,我想是不是无线网卡驱动有没有

【CSS in Depth 2 精译_024】4.2 弹性子元素的大小

当前内容所在位置(可进入专栏查看其他译好的章节内容) 第一章 层叠、优先级与继承(已完结) 1.1 层叠1.2 继承1.3 特殊值1.4 简写属性1.5 CSS 渐进式增强技术1.6 本章小结 第二章 相对单位(已完结) 2.1 相对单位的威力2.2 em 与 rem2.3 告别像素思维2.4 视口的相对单位2.5 无单位的数值与行高2.6 自定义属性2.7 本章小结 第三章 文档流与盒模型(已

Linux下获取硬盘空间的大小

1. df 命令查看所有硬盘设备的信息 2. 查看指定路径的磁盘空间大小 代码获取空间大小案例:

二维旋转公式

二维旋转公式 ros的tf工具包可以很方便的实现任意坐标系之间的坐标转换。但是,如果只是想简单的测试想法,而又不想编写过于庞杂的代码,考虑自己写二维旋转的函数。而与二维旋转问题对偶的另一个问题便是二维坐标系旋转变换。这两个问题的形式基本一样,只是旋转的角度相差一个负号。就是这个容易搞混,所以做个笔记,以备查用。 1. 二维旋转公式(算法) 而(此文只针对二维)旋转则是表示某一坐标点 ( x

线性代数|机器学习-P35距离矩阵和普鲁克问题

文章目录 1. 距离矩阵2. 正交普鲁克问题3. 实例说明 1. 距离矩阵 假设有三个点 x 1 , x 2 , x 3 x_1,x_2,x_3 x1​,x2​,x3​,三个点距离如下: ∣ ∣ x 1 − x 2 ∣ ∣ 2 = 1 , ∣ ∣ x 2 − x 3 ∣ ∣ 2 = 1 , ∣ ∣ x 1 − x 3 ∣ ∣ 2 = 6 \begin{equation} ||x

Windows11电脑上自带的画图软件修改照片大小(不裁剪尺寸的情况下)

针对一张图片,有时候上传的图片有大小限制,那么在这种情况下如何修改其大小呢,在不裁剪尺寸的情况下 步骤如下: 1.选定一张图片,右击->打开方式->画图,如下: 第二步:打开图片后,我们可以看到图片的大小为82.1kb,点击上面工具栏的“重设大小和倾斜”进行调整,如下: 第三步:修改水平和垂直的数字,此处我修改为分别都修改为50,然后保存,可以看到大小变成63.5kb,如下:

超级 密码加密 解密 源码,支持表情,符号,数字,字母,加密

超级 密码加密 解密 源码,支持表情,符号,数字,字母,加密 可以将表情,动物,水果,表情,手势,猫语,兽语,狗语,爱语,符号,数字,字母,加密和解密 可以将文字、字母、数字、代码、标点符号等内容转换成新的文字形式,通过简单的文字以不同的排列顺序来表达不同的内容 源码截图: https://www.httple.net/152649.html