Reputation: 155
I'm using Javascript Stock Chart from amcharts. I want a dropdown calendar view in click of period selector input field. Please can anyone help me how can I make drop-down calendar in from and to fields here?
Upvotes: 1
Views: 2954
Reputation: 150
@user3094124 : Hi, I am using same code it works for me,
Here is my script for amChart, first check if it shows alert on changed or not and you have to use <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");
});
`
Upvotes: 1
Reputation: 150
Add this code , it will help you
chart.addListener('rendered' ,function (event){
$( ".amChartsPeriodSelector .amChartsInputField" ).datepicker({
dateFormat: "dd-mm-yy",
//minDate: newStartDate,
//maxDate: newEndDate,
onClose: function() {
$(".amChartsPeriodSelector .amChartsInputField" ).trigger('blur');
}
});
});
`
Upvotes: 1
Reputation: 8299
1.You can use JQUERY UI Date picker.
http://jqueryui.com/datepicker/
Here are few more good calenders, meet your needs, with good tutorial & docs-
2.http://keith-wood.name/datepick.html
3.http://www.eyecon.ro/datepicker/
Here is another list of useful calendars-
http://www.webdesignbooth.com/9-useful-jquery-calendar-and-date-picker-plugins-for-web-designers/
Upvotes: 0