Echarts笔记
1.显示轴线
xAxis: {
axisLine: { // 显示轴线
show: true,
onZero: false,
lineStyle: {
color: '#ffffff'
}
},
},
2.点击legend
legendClick(myChart, legendData) option && myChart.setOption(option, true) legendClick(chart, legendData) { chart.off('legendselectchanged') // 定义当前点击的标签 let legendWai = '' chart.on('legendselectchanged', function(obj) { legendWai = obj.name for (let i = 0; i < legendData.length; i++) { // 显示当前legend 关闭非当前legent if (legendWai == legendData[i]) { chart.dispatchAction({ type: 'legendSelect', name: legendData[i] }) } else { chart.dispatchAction({ type: 'legendUnSelect', name: legendData[i] }) } } }) }
3.个别数据进行个性化定义
1 2 3 4 5 6 7 8 9 10 11 | series:{ data:[ 12, 34, { value:56, label:{}, itemStyle:{....} } ] } |
4.线图点颜色自定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | series: [ { name: 'BMI' , type: 'line' , itemStyle: { normal: { color: function (params) { return params.data.color }, lineStyle: { color: 'pink' } } }, emphasis: { focus: 'series' }, data: seriesData }<br>] |
5.标题富文本形式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | title: { text: '行为表现得分情况 {small|(a得分 b班级平均分 c年级平均分)}' , x: 'left' , textStyle: { color: '#000' , fontWeight: 'normal' , fontSize: 18, lineHeight: '30' , rich: { small: { fontSize: 14, fontWeight: 'normal' , color: '#666' } } }, }, |
6.选择性点亮legend
1 2 3 4 5 6 7 | legend: { data: [ '波长' , '物理量' ], selected: { '物理量' : true , '波长' : false } }, |
7.雷达图被遮挡
radar: { indicator:indicator, radius:85, // 缩放 }
8.饼图label线的位置和长度设置
label: { formatter: '{b}:{c}%', fontSize: 12, padding: [0, -100, 20, -100], }, labelLayout: function(params) { let points = params.labelLinePoints let isLeft = params.labelRect.x < myChart.getWidth() / 2 points[2][0] = isLeft ? params.labelRect.x : params.labelRect.x + params.labelRect.width return { labelLinePoints: points, } }
9.饼图label线的位置和长度设置
echarts地图json文件生成地址:https://datav.aliyun.com/portal/school/atlas/area_selector
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· .NET Core 中如何实现缓存的预热?
· 三行代码完成国际化适配,妙~啊~
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?