From 25a672864f1dff84566ee68dc70b92a0eca1d585 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Thu, 15 Aug 2013 19:11:59 +0900 Subject: [PATCH] Fix name and value for null data --- c3.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/c3.js b/c3.js index 4471033..529dae1 100644 --- a/c3.js +++ b/c3.js @@ -102,10 +102,16 @@ // tooltip - show when mouseover on each data 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, - text = "", i + text = "
" + date + "
", i, value, name; for (i = 0; i < d.length; i++){ - var value = typeof d[i].value !== 'undefined' ? (Math.round(d[i].value*100)/100).toFixed(2) : '-'; - text += "" + if (typeof d[i] !== 'undefined') { + value = typeof d[i].value !== 'undefined' ? (Math.round(d[i].value*100)/100).toFixed(2) : '-'; + name = d[i].name; + } else { + value = '-'; + name = '-'; + } + text += "" } return text + "
" + date + "
" + d[i].name + "" + value + "
" + name + "" + value + "
" }) @@ -839,6 +845,7 @@ // Add id,name to selectedData for (j = 0; j < selectedData.length; j++) { + if (typeof selectedData[j] === 'undefined') continue; name = __data_names[selectedData[j].id]; selectedData[j].name = typeof name !== 'undefined' ? name : selectedData[j].id; }