ECharts平滑折线图缩放后显示不全,第一张图是未缩放的
下面这张是放大后的效果
期望放大后的效果类似:
JS中的配置代码:
var option = {
backgroundColor: "#100C2A",
animation: false,
xAxis: {
type: 'category',
min: 'dataMin',
max: 'dataMax',
data: [],//动态数据
axisLabel: {
fontSize: 14,
color: "white",
}
},
yAxis: {
type: 'value',
axisLabel: {
fontSize: 16,
color: "white",
},
splitLine: {
lineStyle: {
color: "gray",
width: 1,
type: "solid"
}
}
},
series: [{
data: [],//动态数据
type: 'line',
lineStyle: {
normal: {
width: 1.5
}
},
smooth: true,
}],
legend: {
data: [
'acc_lat',
'acc_long',
'acc_lat_can',
'acc_long_can'
],
textStyle: {
color: "white"
},
},
dataZoom: [
/*鼠标滚轮缩放*/
{
type: 'inside',
xAxisIndex: [0],
start: 0,
end: 100
},
{
type: 'inside',
yAxisIndex: [0],
start: 0,
end: 100
}
],
}
var size = {
with: 1200,
height: 800
}
//读取文件加载折线图
function readTxt(input) {
var image = document.getElementById("image");
image.style.display = "none";
let file = input.files[0];
console.log("file: ", file.name, typeof(file));
let reader = new FileReader();
reader.readAsText(file);
reader.onload = function() {
var arrlist = reader.result.split('####');
option.xAxis.data = arrlist[0].split['\n'];
for (var i = 1; i < arrlist.length; i++) {
option.series.length = 0;
var arr = arrlist[i].split('\n');
arr.splice(0, 1);
console.log(i + " arr: " + arr.length + ", " + arr[0].toString());
var serie = {
name: option.legend.data[i],
data: arr,
type: 'line',
lineStyle: {
normal: {
width: 1.5
}
},
smooth: true
}
option.series.push(serie);
var id = "echart" + (i);
loadEChart2(id);
}
}
}
function loadEChart2(chartId) {
var chart = document.getElementById("div-chat");
var width = chart.offsetWidth;
var height = chart.offsetHeight;
size.with = width / 2;
size.height = height / 2;
var chartDiv = document.getElementById(chartId);
var myChart = echarts.init(chartDiv, null, {
width: size.with,
height: size.height
});
// Y轴最大值和最小值取整
option.yAxis.max = function(value) {
return Math.ceil(value.max);
}
option.yAxis.min = function(value) {
return Math.floor(value.min);
}
option && myChart.setOption(option);
}
请教下ECharts的放大效果就是这样还是可以配置成 放大后折线不会显示不全的效果?