Commit 3c674ef7 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Accept function as axis.x.tick.count - #67

parent 1987be65
...@@ -1457,15 +1457,17 @@ ...@@ -1457,15 +1457,17 @@
return isTimeSeries ? xs.map(function (x) { return new Date(x); }) : xs.map(function (x) { return +x; }); return isTimeSeries ? xs.map(function (x) { return new Date(x); }) : xs.map(function (x) { return +x; });
} }
function generateTickValues(xs) { function generateTickValues(xs) {
var tickValues = xs, start, end, count, interval, i, tickValue; var tickValues = xs, targetCount, start, end, count, interval, i, tickValue;
if (!__axis_x_tick_fit && __axis_x_tick_count) { if (!__axis_x_tick_fit && __axis_x_tick_count) {
// TODO: need some arguments for __axis_x_tick_count()?
targetCount = typeof __axis_x_tick_count === 'function' ? __axis_x_tick_count() : __axis_x_tick_count;
// compute ticks according to __axis_x_tick_count // compute ticks according to __axis_x_tick_count
if (__axis_x_tick_count === 1) { if (targetCount === 1) {
tickValues = [xs[0]]; tickValues = [xs[0]];
} else if (__axis_x_tick_count === 2) { } else if (targetCount === 2) {
tickValues = [xs[0], xs[xs.length - 1]]; tickValues = [xs[0], xs[xs.length - 1]];
} else if (__axis_x_tick_count > 2) { } else if (targetCount > 2) {
count = __axis_x_tick_count - 2; count = targetCount - 2;
start = xs[0]; start = xs[0];
end = xs[xs.length - 1]; end = xs[xs.length - 1];
interval = (end - start) / (count + 1); interval = (end - start) / (count + 1);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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