Commit 8ed33531 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix tooltip title to be formatted

parent 26af06f4
...@@ -128,8 +128,8 @@ ...@@ -128,8 +128,8 @@
// tooltip - show when mouseover on each data // tooltip - show when mouseover on each data
var __tooltip_contents = getConfig(['tooltip', 'contents'], function (d) { var __tooltip_contents = getConfig(['tooltip', 'contents'], function (d) {
var date = isTimeSeries ? d[0].x.getFullYear() + '.' + (d[0].x.getMonth() + 1) + '.' + d[0].x.getDate() : isCategorized ? category(d[0].x) : d[0].x, var title = getXAxisTickFormat()(d[0].x),
text = "<table class='-tooltip'><tr><th colspan='2'>" + date + "</th></tr>", i, value, name; text = "<table class='-tooltip'><tr><th colspan='2'>" + title + "</th></tr>", i, value, name;
for (i = 0; i < d.length; i++) { for (i = 0; i < d.length; i++) {
if (isDefined(d[i])) { if (isDefined(d[i])) {
value = isDefined(d[i].value) ? (Math.round(d[i].value * 100) / 100).toFixed(2) : '-'; value = isDefined(d[i].value) ? (Math.round(d[i].value * 100) / 100).toFixed(2) : '-';
...@@ -329,13 +329,9 @@ ...@@ -329,13 +329,9 @@
function getXAxis(scale, orient) { function getXAxis(scale, orient) {
var axis = (isCategorized ? categoryAxis() : d3.svg.axis()).scale(scale).orient(orient); var axis = (isCategorized ? categoryAxis() : d3.svg.axis()).scale(scale).orient(orient);
var tickFormat = isTimeSeries ? defaultTimeFormat : null;
// Set tick format // Set tick format
if (__axis_x_tick_format) { axis.tickFormat(getXAxisTickFormat());
tickFormat = typeof __axis_x_tick_format === 'function' ? __axis_x_tick_format : isTimeSeries ? function (date) { return d3.time.format(__axis_x_tick_format)(date); } : null;
}
axis.tickFormat(tickFormat);
// Set categories // Set categories
if (isCategorized) { if (isCategorized) {
...@@ -353,6 +349,13 @@ ...@@ -353,6 +349,13 @@
function getAxisId(id) { function getAxisId(id) {
return id in __data_axes ? __data_axes[id] : 'y'; return id in __data_axes ? __data_axes[id] : 'y';
} }
function getXAxisTickFormat() {
var tickFormat = isTimeSeries ? defaultTimeFormat : isCategorized ? category : null;
if (__axis_x_tick_format) {
tickFormat = typeof __axis_x_tick_format === 'function' ? __axis_x_tick_format : isTimeSeries ? function (date) { return d3.time.format(__axis_x_tick_format)(date); } : tickFormat;
}
return tickFormat;
}
//-- Domain --// //-- Domain --//
......
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