

Top10.window.UserRankingLog = Ext.extend(Ext.Window,{
	
	widget: '',
	context: '',
	context_name: '',
    context_id: null,
	account_id: null,
	nickname: null,
	
	width: 700,
	height: 327,
	
    initComponent: function() {
    	var s = new Ext.data.JsonStore({
            url: Top10.APP_URL + 'widgets/chart',
            root: 'records',
            successProperty: 'success',
            fields: [
                {name :'date'},
                {name: 'ranking', type: 'int'}
            ],
            autoLoad: true,
            baseParams: {
                'widget': this.widget,
                'context': this.context,
                'context_id': this.context_id,
                'account_id': this.account_id
            }
        });

        var c = new Ext.chart.LineChart({
            layout: 'fit',
            region: 'center',
            store: s,
            xField: 'date',
            xAxis: new Ext.chart.CategoryAxis({
                title: I18n.Date
            }),
            yAxis: new Ext.chart.NumericAxis({
                title: I18n.Rank,
                minorUnit: 1,
                minimum: 10,
                reverse: true
            }),
            extraStyle: {
                xAxis: {
                    labelRotation: 45
                },
                yAxis: {
                    titleRotation: -90
                }
            },
            series: [{
                type: 'line',
                yField: 'ranking',
                style: {
                    color: 0xAA0000
                }
            }],
            tipRenderer : function(chart, record, index, series){
            	return String.format(I18n.RankingLogChartToolTip, record.data.ranking, record.data.date);
            }
        });
        
        this.context_name = this.context_name == 'World' ? '' : this.context_name;
        
        var config = {
            title: String.format(I18n.UserRankingLogWindowTitle, this.nickname, this.context, this.context_name),
            iconCls: Top10.Icon.css('chart_line'),
            items: c
        };
    	
    	Ext.apply(this, config);
    	Ext.apply(this.initialConfig, config);
    	
    	Top10.window.UserRankingLog.superclass.initComponent.apply(this, arguments);
    }
});

Ext.reg('userrankinglogwindow', Top10.window.UserRankingLog);