X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-tickers.js;h=a3fe90a14f87fdf384d6317c8f4632cb4bc7a38a;hb=11ce506e365f0dfb3a2b489847b5a24d27fe1f9d;hp=715ef7eaeb70e090105ac767719098bedae1efab;hpb=8c68278651a932ea86f8159a4a5b63e58a07d84c;p=dygraphs.git diff --git a/dygraph-tickers.js b/dygraph-tickers.js index 715ef7e..a3fe90a 100644 --- a/dygraph-tickers.js +++ b/dygraph-tickers.js @@ -184,7 +184,7 @@ Dygraph.numericTicks = function(a, b, pixels, opts, dygraph, vals) { // Construct the set of ticks. // Allow reverse y-axis if it's explicitly requested. if (low_val > high_val) scale *= -1; - for (i = 0; i < nTicks; i++) { + for (i = 0; i <= nTicks; i++) { tickV = low_val + i * scale; ticks.push( {v: tickV} ); } @@ -259,7 +259,13 @@ Dygraph.SHORT_SPACINGS[Dygraph.SIX_HOURLY] = 1000 * 3600 * 6; Dygraph.SHORT_SPACINGS[Dygraph.DAILY] = 1000 * 86400; Dygraph.SHORT_SPACINGS[Dygraph.WEEKLY] = 1000 * 604800; -/** @type {Array.} */ +/** + * A collection of objects specifying where it is acceptable to place tick + * marks for granularities larger than WEEKLY. + * 'months' is an array of month indexes on which to place tick marks. + * 'year_mod' ticks are placed when year % year_mod = 0. + * @type {Array.} + */ Dygraph.LONG_TICK_PLACEMENTS = []; Dygraph.LONG_TICK_PLACEMENTS[Dygraph.MONTHLY] = { months : [0,1,2,3,4,5,6,7,8,9,10,11], @@ -450,12 +456,12 @@ Dygraph.getDateAxis = function(start_time, end_time, granularity, opts, dg) { var start_year = new Date(start_time).getFullYear(); var end_year = new Date(end_time).getFullYear(); - var zeropad = Dygraph.zeropad; for (var i = start_year; i <= end_year; i++) { if (i % year_mod !== 0) continue; for (var j = 0; j < months.length; j++) { - var date_str = i + "/" + zeropad(1 + months[j]) + "/01"; - t = Dygraph.dateStrToMillis(date_str); + var dt = new Date(i, months[j], 1); + dt.setFullYear(i); + t = dt.getTime(); if (t < start_time || t > end_time) continue; ticks.push({ v:t, label: formatter(new Date(t), granularity, opts, dg)