Browse Source

remove tabs

pull/1337/head
Jan Teichmann 9 years ago
parent
commit
25e8ad2f23
  1. 30
      spec/tooltip-spec.js
  2. 28
      src/tooltip.js

30
spec/tooltip-spec.js

@ -100,23 +100,23 @@ describe('c3 chart tooltip', function () {
}); });
describe('tooltip getTooltipContent', function () { describe('tooltip getTooltipContent', function () {
beforeAll(function () { beforeAll(function () {
tooltipConfiguration = { tooltipConfiguration = {
data_order: 'desc' data_order: 'desc'
}; };
}); });
it('should sort values desc', function () { it('should sort values desc', function () {
var eventRect = d3.select('.c3-event-rect-2').node(); var eventRect = d3.select('.c3-event-rect-2').node();
window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect);
var tooltipTable = d3.select('.c3-tooltip')[0]; var tooltipTable = d3.select('.c3-tooltip')[0];
var expected = ["", "c3-tooltip-name--data3", var expected = ["", "c3-tooltip-name--data3",
"c3-tooltip-name--data1", "c3-tooltip-name--data2"]; "c3-tooltip-name--data1", "c3-tooltip-name--data2"];
var i; var i;
for (i = 0; i < tooltipTable[0].rows.length; i++) { for (i = 0; i < tooltipTable[0].rows.length; i++) {
expect(tooltipTable[0].rows[i].className).toBe(expected[i]); expect(tooltipTable[0].rows[i].className).toBe(expected[i]);
} }
});
}); });
});
}); });

28
src/tooltip.js

@ -30,23 +30,23 @@ c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaul
nameFormat = config.tooltip_format_name || function (name) { return name; }, nameFormat = config.tooltip_format_name || function (name) { return name; },
valueFormat = config.tooltip_format_value || defaultValueFormat, valueFormat = config.tooltip_format_value || defaultValueFormat,
text, i, title, value, name, bgcolor, text, i, title, value, name, bgcolor,
orderAsc = $$.isOrderAsc(); orderAsc = $$.isOrderAsc();
if (config.data_groups.length === 0) { if (config.data_groups.length === 0) {
d.sort(function(a,b){ d.sort(function(a,b){
return orderAsc ? a.value - b.value : b.value - a.value; return orderAsc ? a.value - b.value : b.value - a.value;
}); });
} else { } else {
var ids = $$.orderTargets($$.data.targets).map(function (i) { var ids = $$.orderTargets($$.data.targets).map(function (i) {
return i.id; return i.id;
}); });
d.sort(function(a, b) { d.sort(function(a, b) {
if (a.value > 0 && b.value > 0) { if (a.value > 0 && b.value > 0) {
return orderAsc ? ids.indexOf(a.id) - ids.indexOf(b.id) : ids.indexOf(b.id) - ids.indexOf(a.id); return orderAsc ? ids.indexOf(a.id) - ids.indexOf(b.id) : ids.indexOf(b.id) - ids.indexOf(a.id);
} else { } else {
return orderAsc ? a.value - b.value : b.value - a.value; return orderAsc ? a.value - b.value : b.value - a.value;
} }
}); });
} }
for (i = 0; i < d.length; i++) { for (i = 0; i < d.length; i++) {

Loading…
Cancel
Save