尝试找出ID为 startDate 的字段的默认值。 它在右下角的渲染窗口中显示“24/04/2008”,但无法看到它在代码中的设置位置。
// this methid is called each time the selected period of the chart is changed
function handleZoom(event) {
var startDate = event.startDate;
var endDate = event.endDate;
document.getElementById("startDate").value = AmCharts.formatDate(startDate, "DD/MM/YYYY");
document.getElementById("endDate").value = AmCharts.formatDate(endDate, "DD/MM/YYYY");
// as we also want to change graph type depending on the selected period, we call this method
changeGraphType(event);
}
// this method is called when user changes dates in the input field
function changeZoomDates() {
var startDateString = document.getElementById("startDate").value;
var endDateString = document.getElementById("endDate").value;
var startDate = stringToDate(startDateString);
var endDate = stringToDate(endDateString);
chart.zoomToDates(startDate, endDate);
}
<input onChange="changeZoomDates()" style="width:100px; text-align:center" type="text" id="startDate">
JSFiddle http://jsfiddle.net/nos0q1dL/
答案 0 :(得分:0)
没有太多文档,但请参阅此部分:
// this method is called when chart is first inited as we listen for "dataUpdated" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(chartData.length - 7, chartData.length - 1);
}
读取它:缩放到第一次显示图表时的最后7天,例如,您可以通过更改7到10进行确认。
要显示所有内容,您可以:
chart.zoomToIndexes( 0, chartData.length - 1);
第一个参数是起始位置的索引,第二个参数是结束位置的索引。
答案 1 :(得分:0)
如果按&#34;默认值&#34;你指的是&#34;初始值&#34;,那么它必须是:
document.getElementById("startDate").value = AmCharts.formatDate(startDate, "DD/MM/YYYY");
将该行替换为:
document.getElementById("startDate").value = "01/01/2007";
你会看到。