新建元件[矩形等]加入载入交互。注意:自定义元件名字要与下方lable相同[这里为ECharts]
javascript:
var script = document.createElement('script');
script.type = "text/javascript";
script.src ="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js";
document.head.appendChild(script);
setTimeout(function(){
var dom =$('[data-label=ECharts]').get(0);
var myChart = echarts.init(dom);
var option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
xAxis: {
type: 'category',
data: [
'2023-03-31 00:13:11',
'2023-03-31 01:13:11',
'2023-03-31 02:13:11',
'2023-03-31 08:13:11',
'2023-03-31 12:13:11'
]
},
legend: {
data: ["进气口气压", "出气口气压"],
textStyle: {
color: 'black'
}
},
yAxis: {
type: 'value'
},
series: [
{
name: "进气口气压",
data: [2100, 2000, 1700, 1600, 1500],
type: 'line',
color: 'yellow',
emphasis: {
itemStyle: {
color: 'whilte'
}
}
},
{
name: "出气口气压",
data: [2000, 1500, 1300, 1200, 1000],
type: 'line',
color: 'red',
emphasis: {
itemStyle: {
color: 'whilte'
}
}
}
]
};
myChart.on('updateAxisPointer', function (event) {
const xAxisInfo = event.axesInfo[0];
if (xAxisInfo) {
const dimension = xAxisInfo.value + 1;
myChart.setOption({
series: {
id: 'pie',
label: {
formatter: '{b}: {@[' + dimension + ']} ({d}%)'
},
encode: {
value: dimension,
tooltip: dimension
}
}
});
}
});
if (option && typeof option === "object"){
myChart.setOption(option, true);
}}, 800);
载入成功❀