Changeset 26052

Show
Ignore:
Timestamp:
12/07/08 20:42:24 (4 years ago)
Author:
hirobe
Message:

start,endオプションを有効にした
y軸の最小値を0に固定、単位を整数に変更。
タイムゾーンによるx軸のずれを補正。
週表示の場合にx軸の最小単位を7日に変更。

Location:
platform/trac/plugins/querychart/trunk/querychart
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • platform/trac/plugins/querychart/trunk/querychart/htdocs/js/querychart.js

    r26043 r26052  
    55var opt_upper = $("#querychartopt_"+idstr+" .upper").text().toLowerCase(); 
    66var opt_per = $("#querychartopt_"+idstr+" .per").text().toLowerCase(); 
     7var tzoffset = (new Date()).getTimezoneOffset()*60*1000; 
    78 
    89var datas = []; 
     
    1516    a = $(this).text(); break; 
    1617  case 1: 
    17     b = new Date($(this).text()).getTime(); break; 
     18    b = new Date($(this).text()).getTime()-tzoffset; break; 
    1819  default: 
    1920    c = $(this).text(); 
     
    3839 
    3940var posit = opt_upper == "true" ? "se" : "ne"; 
     41var x_minTickSize = opt_per == "week" ? [7,"day"] : [1,"day"]; 
    4042 
    4143function showTooltip(x, y, contents){ 
     
    5759  lines: { show: true }, 
    5860  points: { show: true }, 
    59   xaxis: { mode: "time", timeformat: "%y/%m/%d" }, 
     61  xaxis: { mode: "time", timeformat: "%y/%m/%d", minTickSize: x_minTickSize }, 
     62  yaxis: { min: 0, tickDecimals: 0,autoscaleMargin: 0.05 }, 
    6063  grid: { hoverable: true, clickable: false } 
    6164}); 
  • platform/trac/plugins/querychart/trunk/querychart/macro.py

    r26043 r26052  
    112112 
    113113    def _make_data(self,req,opts): 
    114         arg_x_min = opts['min'] 
    115         arg_x_max = opts['max'] 
     114        arg_x_min = opts['start'] 
     115        arg_x_max = opts['end'] 
    116116        per = opts['per'] 
    117117        query_str = opts['query'] 
     
    163163            return None#'''No data to output.''' 
    164164 
    165         x_min = min(edgedays) 
    166         x_max = max(edgedays) 
    167  
     165        x_min = arg_x_min or min(edgedays) 
     166        x_max = arg_x_max or max(edgedays) 
     167        x_min = datetime(x_min.year,x_min.month,x_min.day,tzinfo=x_min.tzinfo) 
     168        x_max = datetime(x_max.year,x_max.month,x_max.day,tzinfo=x_max.tzinfo) 
    168169 
    169170        if per=='week': 
     
    179180        for daylist,dayids in daylists: 
    180181            for x in x_axis: 
     182                 
    181183                count = len([1 for c in daylist if c <= x]) 
    182184                #ids = [dayids[c] for c in daylist if c <= x and c>last_x ] 
     
    187189            linenum += 1 
    188190 
    189         x_min = arg_x_min or x_min 
    190         x_max = arg_x_max or x_max 
    191191 
    192192        return {'x_axis':x_axis, 
     
    213213               'width':'536', 
    214214               'height':'300', 
    215                'max':None, 
    216                'min':None, 
     215               'end':None, 
     216               'start':None, 
    217217               'query':'', 
    218218               'col':[], 
     
    245245                            break 
    246246 
    247             elif key in ['max','min']: 
     247            elif key in ['start','end']: 
    248248                opts[key]= parse_date(value) 
    249249            else: