具体的上代码
var myChartzuoixia = echarts.init(document.querySelector(''));
$("#tableEcharts").removeAttr("_echarts_instance_").empty();
let option = {
tooltip: {
trigger: 'axis',
axisPointer: {
// type: 'cross',
crossStyle: {
color: '#999'
}
},
textStyle: {
fontSize: document.body.clientWidth > 2800 ? 23 : 14
},
formatter: function (params) {
// return console.log(params);
let circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:15px;height:15px;left:5px;background-color:params[0].color"></span>`;
// let data0 = `${circle}params[0].color"></span>`;
let aa=params[0].color
// return `${params[0].axisValueLabel}<br/>${data0}<br/>${data1}`;
return `${params[0]. axisValueLabel}</br><span style="display:inline-block;margin-right:5px;margin-top:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:${aa}"></span> ${nameshuichang} :${params[0].value[1]}`
}
},
textStyle: {
color: 'rgb(250,253,255)'
},
legend: {
// data: ['${nameshuichang}'],
function(name) {
return 'Legend ' + name;
},
textStyle: {//图例文字的样式
color: '#fff',
fontSize: document.body.clientWidth > 2800 ? 20 : 12
},
selectedMode: true,//取消图例上的点击事件
},
// color: ['#ff8734', '#00e6fb', '#3bff38', 'transparent', 'red', 'red'],
grid: {
left: '4%',
right: '4%',
bottom: '12%',
top: '10%',
containLabel: true
},
xAxis: [
{
type: 'time',
axisPointer: {
type: 'shadow'
},
axisLine: {//线
show: false
},
axisTick: {//刻度
show: false
},
splitLine: {
show: false//去掉分割线
},
axisLabel: {
show: true,
color: '#fff',
textStyle: {
fontSize: document.body.clientWidth > 2800 ? 18 : 14 //更改坐标轴文字大小
}
}
}
],
yAxis: [
{
type: 'value',
nameTextStyle: {
fontSize: document.body.clientWidth > 2800 ? 20 : 14
},
axisLine: {//线
show: false
},
axisTick: {//刻度
show: false
},
splitLine: {
show: false,//去掉分割线
lineStyle: {
color: 'rgb(80,80,80)'
}
},
axisLabel: {
show: true,
color: '#fff',
textStyle: {
fontSize: document.body.clientWidth > 2800 ? 18 : 14 //更改坐标轴文字大小
}
},
}
],
dataZoom: [
{
type: 'slider',
xAxisIndex: 0,
filterMode: 'empty',
backgroundColor: 'rgba(1,80,114,0.5)',
fillerColor: 'rgba(35,159,253,.6)',
filterMode: 'none',
start: 0,
end: 100,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '80%',
height: 13,
handleSize: 20,
borderColor: 'rgba(1,80,114,0.5)',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
},
textStyle: {
color: '#fff'
}
},
{
type: 'slider',
yAxisIndex: 0,
filterMode: 'empty',
left: '1%',
backgroundColor: 'rgba(1,80,114,0.5)',
fillerColor: 'rgba(35,159,253,.6)',
filterMode: 'none',
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '80%',
width: 13,
handleSize: 20,
borderColor: 'rgba(1,80,114,0.5)',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
},
textStyle: {
color: '#fff'
}
},
{
type: 'inside',
xAxisIndex: 0,
filterMode: 'empty',
backgroundColor: 'rgba(1,80,114,0.5)',
fillerColor: 'rgba(35,159,253,.6)',
filterMode: 'none',
start: 0,
end: 100,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '80%',
height: 13,
handleSize: 20,
borderColor: 'rgba(1,80,114,0.5)',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
},
textStyle: {
color: '#fff'
}
},
{
type: 'slider',
yAxisIndex: 1,
filterMode: 'empty',
backgroundColor: 'rgba(1,80,114,0.5)',
fillerColor: 'rgba(35,159,253,.6)',
filterMode: 'none',
start: 0,
end: 100,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '80%',
width: 13,
handleSize: 20,
borderColor: 'rgba(1,80,114,0.5)',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
},
textStyle: {
color: '#fff'
}
},
],
series: [
{
name: nameshuichang,
type: 'line',
showSymbol: false,
data: a,
// itemStyle: {normal: {opacity: 0}},
// lineStyle: {normal: {opacity: 0}}
},
]
}
myChartzuoixia.setOption(option)
tooltip: {
trigger: 'axis',
axisPointer: {
// type: 'cross',
crossStyle: {
color: '#999'
}
},
textStyle: {
fontSize: document.body.clientWidth > 2800 ? 23 : 14
},
// 这个是关键
formatter: function (params) {
// return console.log(params);
let circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:15px;height:15px;left:5px;background-color:params[0].color"></span>`;
// let data0 = `${circle}params[0].color"></span>`;
let aa=params[0].color
// return `${params[0].axisValueLabel}<br/>${data0}<br/>${data1}`;
return `${params[0]. axisValueLabel}</br><span style="display:inline-block;margin-right:5px;margin-top:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:${aa}"></span> ${nameshuichang} :${params[0].value[1]}`
}
},
// 默认高亮 ,模拟鼠标划入效果使用
let index = 0; // 高亮索引
myChart.dispatchAction({
type: "highlight",
seriesIndex: index,
dataIndex: index
});
myChart.on("mouseover", function(e) {
if (e.dataIndex != index) {
myChart.dispatchAction({
type: "downplay",
seriesIndex: 0,
dataIndex: index
});
}
});
myChart.on("mouseout", function(e) {
index = e.dataIndex;
myChart.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: e.dataIndex
});
});
window.addEventListener("resize", function () {
myChart.resize()
})
let myChart = echarts.init(chartDom2, null, {renderer: 'svg'});
// 贡献值的echarts
ContributionEcharts() {
let that = this
let chartDom2 = document.getElementById('ContributionEchartsid');
let myChart = echarts.init(chartDom2, null, {renderer: 'svg'});
var salvProMax = [];//背景按最大值
for (let i = 0; i < that.salvProValue.length; i++) {
salvProMax.push(that.salvProValue[0])
}
let option = {
// backgroundColor:"#003366",
grid: {
left: '2%',
right: '2%',
bottom: '-1%',
top: '1%',
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
},
formatter: function (params) {
return params[0].name + ' : ' + params[0].value
}
},
xAxis: {
show: false,
// type: 'value',
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: {
show: false
},
},
yAxis: [{
// scale : true,
// max :9,
// min :0,
// splitNumber : 100,
// boundaryGap : [ 0.4, 0.3 ],
// show: true,
type: 'category',
inverse: true,
axisLabel: {
show: true,
textStyle: {
color: '#000000',
fontSize: '16',
//
},
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: {
show: false
},
data: that.salvProName
}, {
type: 'category',
inverse: true,
axisTick: 'none',
axisLine: 'none',
show: true,
axisLabel: {
margin: -20,
textStyle: {
color: '#000000',
fontSize: '16',
},
},
data: that.salvProValue
}],
series: [{
name: '值',
type: 'bar',
zlevel: 1,
itemStyle: {
normal: {
color: 'rgb( 89,190,255)',
barBorderRadius: [0, 30, 30, 0],
// borderRadius: //(顺时针左上,右上,右下,左下)
// color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
// offset: 0,
// color: 'rgb( 89,190,255)'
// }, {
// offset: 1,
// color: 'rgb( 89,190,255)'
// }]),
},
},
barWidth: 17,
data: that.salvProValue
},
{
name: '背景',
type: 'bar',
barWidth: 17,
barGap: '-100%',
data: salvProMax,
itemStyle: {
normal: {
color: 'rgba( 176,230,255,0.3)',
barBorderRadius: 30,
}
},
},
]
};
myChart.setOption(option)
window.addEventListener("resize", function () {
myChart.resize()
})
},
下方是数据
salvProName: ["王海波", "霍志鹏", "区敏豪", "张章军", "张献翔", "林 勇", "霍志鹏", "霍志鹏", "霍志鹏", "霍志鹏"],
salvProValue: [239, 181, 154, 144, 135, 117, 74, 72, 67, 55],
myChart.dispatchAction({
type: 'highlight',
// 可选,系列名称,可以是一个数组指定多个系列
// seriesName: items.name,
// 可选,数据的 index
// dataIndex: number,
// // 可选,数据的 名称
name: indexs
})
原文地址:https://blog.csdn.net/qq_44161703/article/details/127269323
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_35478.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。