From 1c30d0782736c38bdd2ea1ee5866fe6f3d587619 Mon Sep 17 00:00:00 2001 From: Brandon Bernal Date: Thu, 22 May 2014 11:44:17 -0400 Subject: [PATCH] Spacing and Tabbing reported by Travis CI, 2nd pass. --- c3.js | 190 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/c3.js b/c3.js index cdfabf7..b80a5f5 100644 --- a/c3.js +++ b/c3.js @@ -992,7 +992,7 @@ } }); if (isNaN(d.endAngle)) { - d.endAngle = d.startAngle; + d.endAngle = d.startAngle; } if (isGaugeType(d.data)) { var sA = d.startAngle, eA = d.endAngle; @@ -1000,7 +1000,7 @@ gF = Math.abs(gMin) + gMax, fA = Math.abs(sA) + eA, aTic = (Math.PI) / gF; d.startAngle = (-1 * (Math.PI / 2)) + (aTic * Math.abs(gMin)); - d.endAngle = d.startAngle + (aTic * ((d.value > gMax) ? gMax : d.value )); + d.endAngle = d.startAngle + (aTic * ((d.value > gMax) ? gMax : d.value)); } return found ? d : null; } @@ -1041,7 +1041,7 @@ return translate; } function getArcRatio(d) { - var whole = __gauge_style == 'arc' ? Math.PI : (Math.PI * 2); + var whole = __gauge_style === 'arc' ? Math.PI : (Math.PI * 2); return d ? (d.endAngle - d.startAngle) / whole : null; } function convertToArcData(d) { @@ -2257,13 +2257,13 @@ return function (value) { for (var a = 1; a < levels.length; a++) { if (levels[0] === 'percentage' && ((value / __gauge_max) * 100) < levels[a]) { - return colors[a-1]; + return colors[a - 1]; } if (levels[0] === 'whole' && value < levels[a]) { - return colors[a-1]; + return colors[a - 1]; } } - return colors[colors.length-1]; + return colors[colors.length - 1]; }; } @@ -2440,44 +2440,44 @@ } function generateDrawArea(areaIndices, isSub) { - var area, - getPoint = generateGetAreaPoint(areaIndices, isSub), - yScaleGetter = isSub ? getSubYScale : getYScale; - - if (__axis_rotated) { - area = d3.svg.area() - .x0(function (d, i) { return yScaleGetter(d.id)(0); }) - .x1(function (d, i) { return yScaleGetter(d.id)(d.value); }) - .y(xx); - } else { - area = d3.svg.area() - .x(xx) - .y0(function (d, i) { if (__data_groups.length > 0) { var point = getPoint(d,i); return point[0][1]; } return yScaleGetter(d.id)(0); }) - .y1(function (d, i) { if (__data_groups.length > 0) { var point = getPoint(d,i); return point[1][1]; } return yScaleGetter(d.id)(d.value); }); - } - - return function (d, i) { - var data = filterRemoveNull(d.values), x0, y0; - - if (hasType([d], 'area') || hasType([d], 'area-spline')) { - isSplineType(d) ? area.interpolate("cardinal") : area.interpolate("linear"); - return area(data); - } else if (hasType([d], 'area-step')) { - isStepType(d) ? area.interpolate("step-after") : area.interpolate("linear"); - return area(data); - } else { - x0 = x(data[0].x); - y0 = getYScale(d.id)(data[0].value); - return __axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; - } - }; + var area, + getPoint = generateGetAreaPoint(areaIndices, isSub), + yScaleGetter = isSub ? getSubYScale : getYScale; + + if (__axis_rotated) { + area = d3.svg.area() + .x0(function (d, i) { return yScaleGetter(d.id)(0); }) + .x1(function (d, i) { return yScaleGetter(d.id)(d.value); }) + .y(xx); + } else { + area = d3.svg.area() + .x(xx) + .y0(function (d, i) { if (__data_groups.length > 0) { var point = getPoint(d, i); return point[0][1]; } return yScaleGetter(d.id)(0); }) + .y1(function (d, i) { if (__data_groups.length > 0) { var point = getPoint(d, i); return point[1][1]; } return yScaleGetter(d.id)(d.value); }); + } + + return function (d, i) { + var data = filterRemoveNull(d.values), x0, y0; + + if (hasType([d], 'area') || hasType([d], 'area-spline')) { + isSplineType(d) ? area.interpolate("cardinal") : area.interpolate("linear"); + return area(data); + } else if (hasType([d], 'area-step')) { + isStepType(d) ? area.interpolate("step-after") : area.interpolate("linear"); + return area(data); + } else { + x0 = x(data[0].x); + y0 = getYScale(d.id)(data[0].value); + return __axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; + } + }; } function generateDrawLine(lineIndices, isSub) { var getPoint = generateGetLinePoint(lineIndices, isSub), yScaleGetter = isSub ? getSubYScale : getYScale, xValue = isSub ? subxx : xx, - yValue = function (d,i) { if (__data_groups.length > 0) { var point = getPoint(d,i); return point[0][1]; } return yScaleGetter(d.id)(d.value); }, + yValue = function (d, i) { if (__data_groups.length > 0) { var point = getPoint(d, i); return point[0][1]; } return yScaleGetter(d.id)(d.value); }, line = d3.svg.line() .x(__axis_rotated ? yValue : xValue) .y(__axis_rotated ? xValue : yValue); @@ -2550,25 +2550,25 @@ } function generateGetAreaPoint(areaIndices, isSub) { // partial duplication of generateGetBarPoints - var areaTargetsNum = areaIndices.__max__ + 1, - x = getAreaX(areaTargetsNum, areaIndices, !!isSub), - y = getAreaY(!!isSub), - areaOffset = getAreaOffset(areaIndices, !!isSub), - yScale = isSub ? getSubYScale : getYScale; - return function (d, i) { - var y0 = yScale(d.id)(0), - offset = areaOffset(d, i) || y0, // offset is for stacked area chart - posX = x(d), posY = y(d); - // fix posY not to overflow opposite quadrant - if (__axis_rotated) { - if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; } - } - // 1 point that marks the area position - return [ - [posX, offset], - [posX, posY - (y0 - offset)] - ]; - }; + var areaTargetsNum = areaIndices.__max__ + 1, + x = getAreaX(areaTargetsNum, areaIndices, !!isSub), + y = getAreaY(!!isSub), + areaOffset = getAreaOffset(areaIndices, !!isSub), + yScale = isSub ? getSubYScale : getYScale; + return function (d, i) { + var y0 = yScale(d.id)(0), + offset = areaOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), posY = y(d); + // fix posY not to overflow opposite quadrant + if (__axis_rotated) { + if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; } + } + // 1 point that marks the area position + return [ + [posX, offset], + [posX, posY - (y0 - offset)] + ]; + }; } function generateGetBarPoints(barIndices, isSub) { @@ -2597,24 +2597,24 @@ } function generateGetLinePoint(lineIndices, isSub) { // partial duplication of generateGetBarPoints - var lineTargetsNum = lineIndices.__max__ + 1, - x = getLineX(lineTargetsNum, lineIndices, !!isSub), - y = getLineY(!!isSub), - lineOffset = getLineOffset(lineIndices, !!isSub), - yScale = isSub ? getSubYScale : getYScale; - return function (d, i) { - var y0 = yScale(d.id)(0), - offset = lineOffset(d, i) || y0, // offset is for stacked area chart - posX = x(d), posY = y(d); - // fix posY not to overflow opposite quadrant - if (__axis_rotated) { - if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; } - } - // 1 point that marks the line position - return [ - [posX, posY - (y0 - offset)] - ]; - }; + var lineTargetsNum = lineIndices.__max__ + 1, + x = getLineX(lineTargetsNum, lineIndices, !!isSub), + y = getLineY(!!isSub), + lineOffset = getLineOffset(lineIndices, !!isSub), + yScale = isSub ? getSubYScale : getYScale; + return function (d, i) { + var y0 = yScale(d.id)(0), + offset = lineOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), posY = y(d); + // fix posY not to overflow opposite quadrant + if (__axis_rotated) { + if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; } + } + // 1 point that marks the line position + return [ + [posX, posY - (y0 - offset)] + ]; + }; } function lineWithRegions(d, x, y, _regions) { @@ -2843,14 +2843,14 @@ updateLegend(mapToIds(c3.data.targets), {withTransform: false, withTransitionForTransform: false}); /*-- Main Region --*/ - if (c3.data.targets.length == 0) { - main.append("text") - .attr("class", CLASS.text) - .attr("x", (main[0][0].parentNode.width.baseVal.value / 2) - margin.left) - .attr("y", (main[0][0].parentNode.height.baseVal.value / 2) - margin.top) - .attr("text-anchor", "middle") - .attr("style", (__data_empty_label_fill ? "fill:"+ __data_empty_label_fill +"; " : "") + (__data_empty_label_size ? "font-size:"+ __data_empty_label_size +"; " : "") ) - .text(__data_empty_label_text); + if (c3.data.targets.length === 0) { + main.append("text") + .attr("class", CLASS.text) + .attr("x", (main[0][0].parentNode.width.baseVal.value / 2) - margin.left) + .attr("y", (main[0][0].parentNode.height.baseVal.value / 2) - margin.top) + .attr("text-anchor", "middle") + .attr("style", (__data_empty_label_fill ? "fill:" + __data_empty_label_fill + "; " : "") + (__data_empty_label_size ? "font-size:" + __data_empty_label_size + "; " : "")) + .text(__data_empty_label_text); } // Grids @@ -3722,18 +3722,18 @@ mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) .data(arcData); if (__gauge_style === "arc") { - mainArc.enter().append("path") - .attr("class", "") - .style("opacity", 1) - .style("fill", __gauge_color) // Where background color would receive customization. - .style("cursor", "pointer") - .attr("transform", "scale(1,1)") - .attr("d", function (d) { - d.value = __gauge_max; - d.startAngle = -1*(Math.PI/2); - d.endAngle = Math.PI/2; - return getArc(d, true); - }); + mainArc.enter().append("path") + .attr("class", "") + .style("opacity", 1) + .style("fill", __gauge_color) // Where background color would receive customization. + .style("cursor", "pointer") + .attr("transform", "scale(1,1)") + .attr("d", function (d) { + d.value = __gauge_max; + d.startAngle = -1 * (Math.PI / 2); + d.endAngle = Math.PI / 2; + return getArc(d, true); + }); mainArc.exit().transition().duration(durationForExit) .style('opacity', 0) .remove();