sel*_*der 6 html javascript echarts
我尝试在 echarts 4.1.0 版中编写一个折线图。我使用不同的浏览器,如 Chrome 版本 69.0.3497.100 或 Firefox 63.0.1(64 位)。我的问题是,如果我缩放 x 轴,如果点在焦点之外,连接线就会消失:
这就是我的这个例子的代码:
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0-release/echarts-en.min.js"></script>
</head>
<body>
<div id="main_chart" style="width: 1200px;height:600px;"></div>
<script type="text/javascript">
// based on prepared DOM, initialize echarts instance
var myChart = echarts.init(document.getElementById('main_chart'));
var app = {};
option = null;
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
}
},
xAxis: {
type: 'time',
axisLabel: {
formatter: function (value) {
return echarts.format.formatTime('yyyy-MM-dd hh:mm:ss', value);
}
}
},
yAxis: {
type: 'value',
min: 'dataMin'
},
dataZoom: [
{
type: 'slider',
xAxisIndex: 0,
filterMode: 'filter'
},
{
type: 'slider',
yAxisIndex: 0,
filterMode: 'empty'
},
{
type: 'inside',
xAxisIndex: 0,
filterMode: 'filter'
},
{
type: 'inside',
yAxisIndex: 0,
filterMode: 'empty'
}
],
series: [{
data: [["2018-11-06 11:27:54",37.2],["2018-11-06 11:29:33",37.2],["2018-11-06 11:29:34",37.3],["2018-11-06 13:09:33",37.3],["2018-11-06 13:09:34",37.2],["2018-11-06 13:09:34",37.2],["2018-11-06 13:09:35",37.3],["2018-11-06 13:09:49",37.3],["2018-11-06 13:09:50",37]],
type: 'line',
// step: 'end',
// smooth: true,
sampling: 'average'
}]
};
;
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我缩放时,连接线也应该连接显示区域外的点。您可以在下面看到预期的行为,这是我使用绘图程序所做的。
我可以在选项中改变什么来改变这种行为,或者它是 Echarts 库中的一个问题?
请参阅官方文档https://echarts.apache.org/en/option.html#dataZoom-slider.filterMode和https://echarts.apache.org/en/option.html#dataZoom-inside.filterMode。dataZoom: [{type: 'slider', ...}]dataZoom: [{type: 'inside', ...}]
问题与ECharts在放大时如何过滤数据有关。默认情况下,放大时它会忽略所有超出轴范围的值。设置filterMode: 'none'将防止数据被忽略,并且线条将延伸到基于轴范围之外的值的图形边缘。
| 归档时间: |
|
| 查看次数: |
834 次 |
| 最近记录: |