Browse Source

fixed NaN bug in rotation of axis ticks, ran grunt tasks

pull/1834/head
Dakota St. Laurent 9 years ago
parent
commit
adf95631f9
  1. 12
      c3.css
  2. 31
      c3.js
  3. 10
      c3.min.js
  4. 10
      src/c3.axis.js

12
c3.css

@ -1,7 +1,7 @@
/*-- Chart --*/
.c3 svg {
font: 10px sans-serif;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
-webkit-tap-highlight-color: transparent; }
.c3 path, .c3 line {
fill: none;
@ -12,7 +12,11 @@
-moz-user-select: none;
user-select: none; }
.c3-legend-item-tile, .c3-xgrid-focus, .c3-ygrid, .c3-event-rect, .c3-bars path {
.c3-legend-item-tile,
.c3-xgrid-focus,
.c3-ygrid,
.c3-event-rect,
.c3-bars path {
shape-rendering: crispEdges; }
.c3-chart-arc path {
@ -71,11 +75,11 @@
/*-- Region --*/
.c3-region {
fill: steelblue;
fill-opacity: 0.1; }
fill-opacity: .1; }
/*-- Brush --*/
.c3-brush .extent {
fill-opacity: 0.1; }
fill-opacity: .1; }
/*-- Select - Drag --*/
/*-- Legend --*/

31
c3.js

@ -1275,6 +1275,9 @@
tooltip_init_position: {top: '0px', left: '50px'},
tooltip_onshow: function () {},
tooltip_onhide: function () {},
tooltip_total_show: false,
tooltip_total_name: undefined,
tooltip_total_format_value: undefined,
// title
title_text: undefined,
title_padding: {
@ -3842,7 +3845,9 @@
titleFormat = config.tooltip_format_title || defaultTitleFormat,
nameFormat = config.tooltip_format_name || function (name) { return name; },
valueFormat = config.tooltip_format_value || defaultValueFormat,
text, i, title, value, name, bgcolor,
totalName = config.tooltip_total_name || "Total",
totalValueFormat = config.tooltip_total_format_value || valueFormat,
text, i, title, value, name, bgcolor, totalValue,
orderAsc = $$.isOrderAsc();
if (config.data_groups.length === 0) {
@ -3883,6 +3888,20 @@
text += "</tr>";
}
}
// adding a "Total" row to the tooltip - if a formatter is not given then the total
// value will be formatted the same way as the other values
if (config.tooltip_total_show) {
totalValue = 0;
for (i = 0; i < d.length; i++) {
if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; }
totalValue += d[i].value;
}
totalValue = totalValueFormat(totalValue);
text += "<tr>";
text += "<td class='name'><strong>" + totalName + "</strong></td>";
text += "<td class='value'>" + totalValue + "</td>";
text += "</tr>";
}
return text + "</table>";
};
c3_chart_internal_fn.tooltipPosition = function (dataToShow, tWidth, tHeight, element) {
@ -6953,12 +6972,18 @@
function axisX(selection, x) {
selection.attr("transform", function (d) {
return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)";
var translateValue = Math.ceil(x(d) + tickOffset);
return isNaN(translateValue) ?
"translate(0, 0)" :
"translate(" + translateValue + ", 0)";
});
}
function axisY(selection, y) {
selection.attr("transform", function (d) {
return "translate(0," + Math.ceil(y(d)) + ")";
var translateValue = Math.ceil(y(d));
return isNaN(translateValue) ?
"translate(0, 0)" :
"translate(" + translateValue + ", 0)";
});
}
function scaleExtent(domain) {

10
c3.min.js vendored

File diff suppressed because one or more lines are too long

10
src/c3.axis.js

@ -13,12 +13,18 @@ function c3_axis(d3, params) {
function axisX(selection, x) {
selection.attr("transform", function (d) {
return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)";
var translateValue = Math.ceil(x(d) + tickOffset);
return isNaN(translateValue) ?
"translate(0, 0)" :
"translate(" + translateValue + ", 0)";
});
}
function axisY(selection, y) {
selection.attr("transform", function (d) {
return "translate(0," + Math.ceil(y(d)) + ")";
var translateValue = Math.ceil(y(d));
return isNaN(translateValue) ?
"translate(0, 0)" :
"translate(" + translateValue + ", 0)";
});
}
function scaleExtent(domain) {

Loading…
Cancel
Save