Commit c51dc602 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add axis_x_tick_fomat option

parent 9594e6ba
......@@ -74,6 +74,7 @@
var __axis_x_type = getConfig(['axis', 'x', 'type'], 'indexed'),
__axis_x_categories = getConfig(['axis', 'x', 'categories'], []),
__axis_x_tick_centered = getConfig(['axis', 'x', 'tick', 'centered'], false),
__axis_x_tick_format = getConfig(['axis', 'x', 'tick', 'format'], null),
__axis_x_default = getConfig(['axis', 'x', 'default'], null),
__axis_y_max = getConfig(['axis', 'y', 'max'], null),
__axis_y_min = getConfig(['axis', 'y', 'min'], null),
......@@ -157,7 +158,7 @@
var color = generateColor(__data_colors, __color_pattern);
var customTimeFormat = (function () {
var defaultTimeFormat = (function () {
var formats = [
[d3.time.format("%Y/%-m/%-d"), function () { return true; }],
[d3.time.format("%-m/%-d"), function (d) { return d.getMonth(); }],
......@@ -293,7 +294,7 @@
function getXAxis(scale, orient) {
var axis = (isCategorized ? categoryAxis() : d3.svg.axis()).scale(scale).orient(orient);
if (isTimeSeries) {
axis.tickFormat(customTimeFormat);
axis.tickFormat(__axis_x_tick_format ? function (date) { return d3.time.format(__axis_x_tick_format)(date); } : defaultTimeFormat);
}
if (isCategorized) {
axis.categories(__axis_x_categories).tickCentered(__axis_x_tick_centered);
......
......@@ -21,7 +21,10 @@
},
axis : {
x : {
type : 'timeseries'
type : 'timeseries',
tick : {
format : "%m/%d" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format
}
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment