我使用amcharts的Javascript Stock Chart。我想要一个下拉日历视图,点击周期选择器输入字段。请任何人都可以帮助我如何在此处的字段中输入下拉日历?
答案 0 :(得分:1)
添加此代码,它会帮助您
chart.addListener('rendered' ,function (event){
$( ".amChartsPeriodSelector .amChartsInputField" ).datepicker({
dateFormat: "dd-mm-yy",
//minDate: newStartDate,
//maxDate: newEndDate,
onClose: function() {
$(".amChartsPeriodSelector .amChartsInputField" ).trigger('blur');
}
});
});
`
答案 1 :(得分:1)
@ user3094124:嗨,我正在使用它适用于我的相同代码,
这是我的amChart脚本,首先检查它是否显示已更改的警报,你必须使用<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
jquery ui liabrary。
`
AmCharts.ready(function() {
var chart = new AmCharts.AmStockChart();
chart.pathToImages = "/amcharts/amcharts/images/";
var dataSet = new AmCharts.DataSet();
dataSet.dataProvider = chartDataS;
dataSet.fieldMappings = [{fromField:"val", toField:"value"}];
dataSet.categoryField = "date";
chart.dataSets = [dataSet];
var stockPanel = new AmCharts.StockPanel();
chart.panels = [stockPanel];
var legend = new AmCharts.StockLegend();
stockPanel.stockLegend = legend;
var panelsSettings = new AmCharts.PanelsSettings();
panelsSettings.startDuration = 5;
chart.panelsSettings = panelsSettings;
var graph = new AmCharts.StockGraph();
graph.valueField = "value";
graph.type = "column";
graph.title = "Users ";
graph.fillAlphas = 1;
stockPanel.addStockGraph(graph);
var categoryAxesSettings = new AmCharts.CategoryAxesSettings();
categoryAxesSettings.dashLength = 1;
chart.categoryAxesSettings = categoryAxesSettings;
var valueAxesSettings = new AmCharts.ValueAxesSettings();
valueAxesSettings .dashLength = 1;
chart.valueAxesSettings = valueAxesSettings;
var chartScrollbarSettings = new AmCharts.ChartScrollbarSettings();
chartScrollbarSettings.graph = graph;
chartScrollbarSettings.graphType = "line";
chart.chartScrollbarSettings = chartScrollbarSettings;
var chartCursorSettings = new AmCharts.ChartCursorSettings();
chartCursorSettings.valueBalloonsEnabled = true;
//chartCursorSettings.fullWidth = true;
chart.chartCursorSettings = chartCursorSettings;
var periodSelector = new AmCharts.PeriodSelector();
periodSelector.periods = [{period:"DD", count:1, label:"1 day"},
{period:"DD", selected:true, count:5, label:"5 days"},
{period:"MM", count:1, label:"1 month"},
{period:"YYYY", count:1, label:"1 year"},
{period:"YTD", label:"YTD"},
{period:"MAX", label:"MAX",selected:true}];
periodSelector.position = "top";
chart.periodSelector = periodSelector;
/*chart.periodSelector.addListener('changed', function(){
alert('changed');
$( ".amChartsPeriodSelector .amChartsInputField" ).datepicker({
dateFormat: "dd-mm-yy"
});
});*/
chart.addListener('rendered' ,function (event){
$( ".amChartsPeriodSelector .amChartsInputField" ).datepicker({
dateFormat: "dd-mm-yy",
//minDate: newStartDate,
//maxDate: newEndDate,
onClose: function() {
$(".amChartsPeriodSelector .amChartsInputField" ).trigger('blur');
}
});
});
chart.write("StockChartDiv");
});
`
答案 2 :(得分:0)
1.您可以使用JQUERY UI日期选择器。
http://jqueryui.com/datepicker/
这里有一些更好的压光机,满足您的需求,有良好的教程和文档 -
2。http://keith-wood.name/datepick.html
3。http://www.eyecon.ro/datepicker/
以下是另一个有用的日历列表 -
http://www.webdesignbooth.com/9-useful-jquery-calendar-and-date-picker-plugins-for-web-designers/