PDA

View Full Version : Dynamically Assigning dates in 'fromDate' and 'toDate' in Time Axes of Line chart



Mahesh Sakunala
14 Aug 2012, 11:46 PM
Hello Guys,

I am facing an issue with assigning dates dynamically in 'fromDate' and 'toDate' configs in Time Axes of Line chart.
I can mention only particular date in that configs.But i need to show the data based on certain date for different scenarios.
I am pasting my sample code for Reference.

axes:
{
title: 'Scanned Time',
type: 'Time',
position: 'bottom',
fields: ['timeline'],
dateFormat: 'ga',
constrain: false,
fromDate: new Date('08/15/2012 09:00:00 am'),
toDate: new Date('08/15/2012 05:00:00 pm'),
step: [Ext.Date.HOUR, 1],
}


It would be great if anyone can help me out.

Thanks

jonathanmv
16 Aug 2012, 7:41 AM
Use a method to get the axes configuration. You can try something like



Ext.define('MyApp.view.MyTimeChart', {
extend: 'Ext.chart.Chart',
/**
* @cfg {Date} startDate Initial date
*/
startDate: new Date(),
/**
* @cfg {Date} endDate Final date
*/
endDate: new Date(),
series: { ... },
axes: {
title: 'Scanned Time',
type: 'Time',
position: 'bottom',
fields: ['timeline'],
dateFormat: 'ga',
constrain: false,
step: [Ext.Date.HOUR, 1]
},
initComponent: function(){
var me = this;
me.axes.fromDate = me.startDate;
me.axes.toDate = me.endDate;
},
//...
});

Then set the values when creating the chart


Ext.create('MyApp.view.MyTimeChart', {
startDate: new Date('08/15/2012 09:00:00 am'),
endDate: new Date('08/15/2012 05:00:00 pm')
});


Hope it helps

Mahesh Sakunala
17 Aug 2012, 2:00 AM
Hi Jonathanmv,
Thanks for the help!

I have solved the problem in the other way.
I am changing the data in the back-end itself so that it changes dynamically.

Cheers.