效果展示:
源码:
/**
* series-lines图表标注
* @param metricsList 指标数据
* @param markPointColor 标记颜色
*/
const getMetricsListCoord = (metricsList,markPointColor)=>{
let metricsListCoord:any = [];
if(!metricsList.length){return }
let curColor = '',curBackground = '',curBorderColor='';
if(markPointColor.gradientControl){
if(markPointColor.gradientDowntoUp){
curColor = markPointColor.gradientStart; //下-上
curBackground = markPointColor.gradientStart;
curBorderColor = markPointColor.gradientStart;
}else if(markPointColor.gradientUptoDown){
curColor = markPointColor.aggreColor;
curBackground = markPointColor.aggreColor;
curBorderColor = markPointColor.aggreColor;
}else{
curColor = markPointColor.aggreColor;
curBackground = markPointColor.aggreColor;
curBorderColor = markPointColor.aggreColor;
}
}else{
curColor = markPointColor.aggreColor;
curBackground = markPointColor.aggreColor;
curBorderColor = markPointColor.aggreColor;
}
for (let i =0;i<metricsList.length;i++){
metricsListCoord.push({
itemStyle: {
borderWidth: 0 ,
borderType: 'solid' ,
borderDashOffset: 0 ,
borderCap: 'butt' ,
borderJoin: 'bevel' ,
borderMiterLimit: 10 ,
shadowColor: 'rgba(225, 225, 225, 1)',
shadowBlur: 10,
shadowOffsetX: 0 ,
shadowOffsetY: 0 ,
opacity: 1 ,
color: curColor,
background: curBackground,
borderColor: curBorderColor,
// filter: 'drop-shadow(0 0 3px #31adff)'
},
coord: [metricsList[i], i]
})
}
return metricsListCoord;
}
export const getSeriesBarPoint=(metricsList,markPointColor)=>{
let markPointData = getMetricsListCoord(metricsList,markPointColor);
return{
// 标记图形
markPoint:{
// 标记的图形
symbol:'circle',
// 表示宽和高,例如 [20, 10] 表示标记宽为20,高为10
symbolSize:[14,14],
// 标注的样式
itemStyle: {
borderWidth: 1 ,
},
label:{
color:'#fff',
},
// 标注的数据数组
// 通过 x, y 属性指定相对容器的屏幕坐标,单位像素,支持百分比
// 当多个属性同时存在时,优先级按上述的顺序
data:markPointData
}
}
}