amCharts错误的缩放startDates和endDates [英] amCharts wrong Zoom startDates and endDates
问题描述
我正在使用amCharts来显示库存数据.我有7个缩放级别:1H, 1D, 1W, 1M, 3M, 1Y, MAX
.对于1H,1D,我正在使用包含分钟数据的数据集.对于1W,1M,我使用具有小时数据的另一个数据集.对于其余3个级别,我还有另一个包含按日数据的数据集.现在这是我的问题:
I am using amCharts for displaying stock data. I have 7 zoom levels: 1H, 1D, 1W, 1M, 3M, 1Y, MAX
. For 1H, 1D, I am using a dataset which contains minute wise data. For 1W, 1M, I use a different dataset which has hour wise data. And for rest 3 levels, I have another dataset with day wise data. Now here is my problem:
最初,我以默认的缩放级别1D加载每分钟的数据,并在单击1W按钮或任何其他缩放级别按钮后将监听器"changed"
添加到chart.periodSelector
,其中startDate和endDate之间的分钟差生成的事件:var minsDiff = (event.endDate.getTime() - event.startDate.getTime()) / 60000
始终等于 1天(1440)中的分钟数,而不是 7天.
When initially, I load minute wise data at default zoom level 1D, and add a listener "changed"
to chart.periodSelector
, after clicking on 1W button or any further zoom level button, the difference in minutes between startDate and endDate of generated event: var minsDiff = (event.endDate.getTime() - event.startDate.getTime()) / 60000
is always equal to number of minutes in 1 day (1440) instead of 7 days.
我想这可能是因为当前加载的数据集是具有1440个最大数据点数的分钟数据集.因此,可能将1周的日期范围设置为等于1天的日期范围,因为只有这么多的数据可用.但是我想要的是如果我单击1W按钮,则是1周的实际日期范围,因为我想使用不同的数据集(1W的每小时数据)加载不同的图表.
I suppose this may be because the current dataset loaded is minutes dataset with 1440 max number of datapoints. So it may be setting date range for 1 Week equal to that of 1 Day because only that much data is available. But what I want is actual date range of 1 week if I click 1W button because I want to load a different chart with different dataset (hour wise data for 1W).
我尝试使用图表的侦听器"zoomed"
.但是,同样的问题仍然存在.
I tried using listener "zoomed"
of chart. But same problem persisted.
推荐答案
通常,超出范围的时期是不可见的,除非您设置 changed
事件中的predifinedPeriod
属性是一种确保方法来查看单击了哪个按钮,这将在这种情况下数据不一定包含整个期间的情况下会有所帮助:
Normally out of scope periods are not visible unless you set hideOutOfScopePeriods
to false. As you noticed, if a period is greater than the amount of data available then the chart will truncate the zoom to fit the data you have. Checking the predifinedPeriod
property in the changed
event is a surefire way to see which button was clicked, which will help in this scenario where the data doesn't necessarily encompass the entire period:
listeners: [
{
event: "changed",
method: function(eventObj) {
console.log("clicked " + eventObj.predefinedPeriod);
}
}
]
这篇关于amCharts错误的缩放startDates和endDates的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!