eniaclyl commented on issue #10747: 直线带箭头如何实现 URL: https://github.com/apache/incubator-echarts/issues/10747#issuecomment-505873172 我自己实现了一个,但是放大后超出坐标轴的部分不会裁剪,代码如下: var lineData = [] function getColor() { //定义字符串变量colorValue存放可以构成十六进制颜色值的值 var colorValue = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f"; //以","为分隔符,将colorValue字符串分割为字符数组["0","1",...,"f"] var colorArray = colorValue.split(","); var color = "#";//定义一个存放十六进制颜色值的字符串变量,先将#存放进去 //使用for循环语句生成剩余的六位十六进制值 for (var i = 0; i < 6; i++) { //colorArray[Math.floor(Math.random()*16)]随机取出 // 由16个元素组成的colorArray的某一个值,然后将其加在color中, //字符串相加后,得出的仍是字符串 color += colorArray[Math.floor(Math.random() * 16)]; } return color; } for (var i = 0; i < 20; ++i) { var x = Math.floor(Math.random()*600+50) var y = Math.floor(Math.random()*600+50) var xSign = Math.floor(Math.random()*2+1) var ySign = Math.floor(Math.random()*2+1) //负数 if (xSign === 1) { x *= -1; } if (ySign === 1) { y *= -1; } var obj = { name: "测试直线"+i+1, coords: [ [0, 0], [x, y] ], label: { show:false }, lineStyle: { normal: { color: getColor(), width: 1 } } } lineData.push(obj); } option = { animation: false, title: { text: '网络拓扑图' }, xAxis: { type:'value', min: -1000, max: 1000, splitLine:{ lineStyle: { width: 1 } } }, yAxis: { type:'value', min: -1000, max: 1000, splitLine:{ lineStyle: { width: 1 } } }, dataZoom: [{ type: 'inside', xAxisIndex: 0, filterMode: 'filter' }, { type: 'inside', yAxisIndex: 0, filterMode: 'weakFilter' } ], series: [{ type: 'lines', name: '网络拓扑图', coordinateSystem: 'cartesian2d', lineStyle: { normal: { color: '#F00', width: 1 } }, label: { fontSize: 15 }, symbol: ['none', 'arrow'], // 数据 data: lineData }] };
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
