简体   繁体   English

如何显示轴线(x轴)上数据(传递给图表的数组)中的最后一个值?

[英]How to show last value from data ( array passed to charts ) at axis line (x-axis)?

In below picture, 在下面的图片中,

The date displayed at end of axis line (x-axis) is diff from date displayed at end of data zoom. 轴线(x轴)末端显示的日期与数据缩放末端显示的日期相差。

Required, 需要,

The date should be same, at axis line & data zoom, When no zoom is applied. 在不应用缩放的情况下,日期应与轴线和数据缩放的日期相同。 The date should be the last value in data that is passed to charts by settings. 日期应该是通过设置传递到图表的数据中的最后一个值。

Screenshot is taken from official site of echarts. 屏幕截图取自echarts的官方网站。

https://ecomfe.github.io/echarts-examples/public/editor.html?c=area-rainfall https://ecomfe.github.io/echarts-examples/public/editor.html?c=area-rainfall 在此处输入图片说明

Actually, the chart does show data up to 2009/10/18 , but since the xAxis ticks aren't equally spaced, there's a small area at the chart's end 实际上,该图表确实显示了截至2009/10/18数据,但是由于xAxis刻度线的间距不相等,因此图表的末尾有一个很小的区域

Look what happens when I hover over the chart's right end. 看看当我将鼠标悬停在图表的右端时会发生什么。 It does show you 2009/10/18 . 它确实向您显示2009/10/18

在此处输入图片说明

Because the axis ticks are alligned from the left, and the chart's axis is dynamic (because of the custom zoom range), it may not always fit perfectly. 因为轴刻度线是从左侧开始分配的,并且图表的轴是动态的(由于自定义缩放范围),所以它可能并不总是很合适。


You can, however, play a little with the ticks and labels. 但是,您可以在刻度线和标签上玩一些。

For example, when you have 100 datapoints, you can change the tick interval and label from auto to, let's say, 10 (or another whole number divisible by the number of datapoints). 例如,当您有100个数据点时,您可以将刻度间隔和标签从auto更改为10 (或另一个可以被数据点数整除的整数)。

xAxis: [
    {
        axisTick: {
            interval: 10
        },
        axisLabel: {
            interval: 10
        },
    }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM