话不多说,直接上代码
let option = {color:['xxx', 'xxx', 'xxx', 'xxx'], //直接设置color可修改图形颜色title: {text: '散点图图形',},tooltip: {trigger: 'axis',axisPointer: {type: 'cross'}},legend: {top: 2,right:2,itemWidth: 10,itemHeight: 10,textStyle:{fontSize:14},//legend里面的data属性可以设置值为对象数组 icon属性可设置点的形状data:[{ name: 'aaa', icon: 'square' },{ name: 'bbb', icon: 'square' },{ name: 'ccc', icon: 'circle' },{ name: 'ddd', icon: 'triangle' }]},grid: {left: '2%',right: '2%',bottom: 10,containLabel: true},xAxis: {},yAxis: {type: 'value',name: '测试',nameTextStyle: {color: '#6E707D',fontSize:14},axisLine: { show: false },axisTick: { show: false },axisLabel: {margin: 2,interval: 15,color: '#6E707D'}},series: [{name: 'aaa',type: 'scatter',// series里面data 也可以设置为对象数组 symbol可设置图形形状data: [// 正方形点{ value: [1, 5], symbol: 'square' },{ value: [6, 15], symbol: 'square' },{ value: [4, 9], symbol: 'square' },{ value: [10, 25], symbol: 'square' },{ value: [15, 25], symbol: 'square' },]},{name: 'bbb',type: 'scatter',data: [// 正方形点{ value: [6, 5], symbol: 'square' },{ value: [12, 15], symbol: 'square' },{ value: [1, 9], symbol: 'square' },{ value: [8, 25], symbol: 'square' },{ value: [7, 16], symbol: 'square' },]},{ name:'ccc',type: 'scatter',data: [// 圆形点{ value: [1, 2], symbol: 'circle' },{ value: [4, 2], symbol: 'circle' },{ value: [3, 10], symbol: 'circle' },{ value: [6, 8], symbol: 'circle' },{ value: [10, 20], symbol: 'circle' },]},{name:'ddd',type: 'scatter',data: [// 三角形点{ value: [2, 30], symbol: 'triangle' },{ value: [10, 25], symbol: 'triangle' },{ value: [8, 10], symbol: 'triangle' },{ value: [22, 32], symbol: 'triangle' },{ value: [16, 20], symbol: 'triangle' },]}]}