Browse Source

Spacing and Tabbing reported by Travis CI, 2nd pass.

pull/254/head
Brandon Bernal 10 years ago
parent
commit
1c30d07827
  1. 190
      c3.js

190
c3.js

@ -992,7 +992,7 @@
} }
}); });
if (isNaN(d.endAngle)) { if (isNaN(d.endAngle)) {
d.endAngle = d.startAngle; d.endAngle = d.startAngle;
} }
if (isGaugeType(d.data)) { if (isGaugeType(d.data)) {
var sA = d.startAngle, eA = d.endAngle; var sA = d.startAngle, eA = d.endAngle;
@ -1000,7 +1000,7 @@
gF = Math.abs(gMin) + gMax, fA = Math.abs(sA) + eA, gF = Math.abs(gMin) + gMax, fA = Math.abs(sA) + eA,
aTic = (Math.PI) / gF; aTic = (Math.PI) / gF;
d.startAngle = (-1 * (Math.PI / 2)) + (aTic * Math.abs(gMin)); 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; return found ? d : null;
} }
@ -1041,7 +1041,7 @@
return translate; return translate;
} }
function getArcRatio(d) { 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; return d ? (d.endAngle - d.startAngle) / whole : null;
} }
function convertToArcData(d) { function convertToArcData(d) {
@ -2257,13 +2257,13 @@
return function (value) { return function (value) {
for (var a = 1; a < levels.length; a++) { for (var a = 1; a < levels.length; a++) {
if (levels[0] === 'percentage' && ((value / __gauge_max) * 100) < levels[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]) { 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) { function generateDrawArea(areaIndices, isSub) {
var area, var area,
getPoint = generateGetAreaPoint(areaIndices, isSub), getPoint = generateGetAreaPoint(areaIndices, isSub),
yScaleGetter = isSub ? getSubYScale : getYScale; yScaleGetter = isSub ? getSubYScale : getYScale;
if (__axis_rotated) { if (__axis_rotated) {
area = d3.svg.area() area = d3.svg.area()
.x0(function (d, i) { return yScaleGetter(d.id)(0); }) .x0(function (d, i) { return yScaleGetter(d.id)(0); })
.x1(function (d, i) { return yScaleGetter(d.id)(d.value); }) .x1(function (d, i) { return yScaleGetter(d.id)(d.value); })
.y(xx); .y(xx);
} else { } else {
area = d3.svg.area() area = d3.svg.area()
.x(xx) .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); }) .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); }); .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) { return function (d, i) {
var data = filterRemoveNull(d.values), x0, y0; var data = filterRemoveNull(d.values), x0, y0;
if (hasType([d], 'area') || hasType([d], 'area-spline')) { if (hasType([d], 'area') || hasType([d], 'area-spline')) {
isSplineType(d) ? area.interpolate("cardinal") : area.interpolate("linear"); isSplineType(d) ? area.interpolate("cardinal") : area.interpolate("linear");
return area(data); return area(data);
} else if (hasType([d], 'area-step')) { } else if (hasType([d], 'area-step')) {
isStepType(d) ? area.interpolate("step-after") : area.interpolate("linear"); isStepType(d) ? area.interpolate("step-after") : area.interpolate("linear");
return area(data); return area(data);
} else { } else {
x0 = x(data[0].x); x0 = x(data[0].x);
y0 = getYScale(d.id)(data[0].value); y0 = getYScale(d.id)(data[0].value);
return __axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; return __axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
} }
}; };
} }
function generateDrawLine(lineIndices, isSub) { function generateDrawLine(lineIndices, isSub) {
var getPoint = generateGetLinePoint(lineIndices, isSub), var getPoint = generateGetLinePoint(lineIndices, isSub),
yScaleGetter = isSub ? getSubYScale : getYScale, yScaleGetter = isSub ? getSubYScale : getYScale,
xValue = isSub ? subxx : xx, 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() line = d3.svg.line()
.x(__axis_rotated ? yValue : xValue) .x(__axis_rotated ? yValue : xValue)
.y(__axis_rotated ? xValue : yValue); .y(__axis_rotated ? xValue : yValue);
@ -2550,25 +2550,25 @@
} }
function generateGetAreaPoint(areaIndices, isSub) { // partial duplication of generateGetBarPoints function generateGetAreaPoint(areaIndices, isSub) { // partial duplication of generateGetBarPoints
var areaTargetsNum = areaIndices.__max__ + 1, var areaTargetsNum = areaIndices.__max__ + 1,
x = getAreaX(areaTargetsNum, areaIndices, !!isSub), x = getAreaX(areaTargetsNum, areaIndices, !!isSub),
y = getAreaY(!!isSub), y = getAreaY(!!isSub),
areaOffset = getAreaOffset(areaIndices, !!isSub), areaOffset = getAreaOffset(areaIndices, !!isSub),
yScale = isSub ? getSubYScale : getYScale; yScale = isSub ? getSubYScale : getYScale;
return function (d, i) { return function (d, i) {
var y0 = yScale(d.id)(0), var y0 = yScale(d.id)(0),
offset = areaOffset(d, i) || y0, // offset is for stacked area chart offset = areaOffset(d, i) || y0, // offset is for stacked area chart
posX = x(d), posY = y(d); posX = x(d), posY = y(d);
// fix posY not to overflow opposite quadrant // fix posY not to overflow opposite quadrant
if (__axis_rotated) { if (__axis_rotated) {
if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; } if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; }
} }
// 1 point that marks the area position // 1 point that marks the area position
return [ return [
[posX, offset], [posX, offset],
[posX, posY - (y0 - offset)] [posX, posY - (y0 - offset)]
]; ];
}; };
} }
function generateGetBarPoints(barIndices, isSub) { function generateGetBarPoints(barIndices, isSub) {
@ -2597,24 +2597,24 @@
} }
function generateGetLinePoint(lineIndices, isSub) { // partial duplication of generateGetBarPoints function generateGetLinePoint(lineIndices, isSub) { // partial duplication of generateGetBarPoints
var lineTargetsNum = lineIndices.__max__ + 1, var lineTargetsNum = lineIndices.__max__ + 1,
x = getLineX(lineTargetsNum, lineIndices, !!isSub), x = getLineX(lineTargetsNum, lineIndices, !!isSub),
y = getLineY(!!isSub), y = getLineY(!!isSub),
lineOffset = getLineOffset(lineIndices, !!isSub), lineOffset = getLineOffset(lineIndices, !!isSub),
yScale = isSub ? getSubYScale : getYScale; yScale = isSub ? getSubYScale : getYScale;
return function (d, i) { return function (d, i) {
var y0 = yScale(d.id)(0), var y0 = yScale(d.id)(0),
offset = lineOffset(d, i) || y0, // offset is for stacked area chart offset = lineOffset(d, i) || y0, // offset is for stacked area chart
posX = x(d), posY = y(d); posX = x(d), posY = y(d);
// fix posY not to overflow opposite quadrant // fix posY not to overflow opposite quadrant
if (__axis_rotated) { if (__axis_rotated) {
if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; } if ((d.value > 0 && posY < offset) || (d.value < 0 && posY > offset)) { posY = offset; }
} }
// 1 point that marks the line position // 1 point that marks the line position
return [ return [
[posX, posY - (y0 - offset)] [posX, posY - (y0 - offset)]
]; ];
}; };
} }
function lineWithRegions(d, x, y, _regions) { function lineWithRegions(d, x, y, _regions) {
@ -2843,14 +2843,14 @@
updateLegend(mapToIds(c3.data.targets), {withTransform: false, withTransitionForTransform: false}); updateLegend(mapToIds(c3.data.targets), {withTransform: false, withTransitionForTransform: false});
/*-- Main Region --*/ /*-- Main Region --*/
if (c3.data.targets.length == 0) { if (c3.data.targets.length === 0) {
main.append("text") main.append("text")
.attr("class", CLASS.text) .attr("class", CLASS.text)
.attr("x", (main[0][0].parentNode.width.baseVal.value / 2) - margin.left) .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("y", (main[0][0].parentNode.height.baseVal.value / 2) - margin.top)
.attr("text-anchor", "middle") .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 +"; " : "") ) .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); .text(__data_empty_label_text);
} }
// Grids // Grids
@ -3722,18 +3722,18 @@
mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc)
.data(arcData); .data(arcData);
if (__gauge_style === "arc") { if (__gauge_style === "arc") {
mainArc.enter().append("path") mainArc.enter().append("path")
.attr("class", "") .attr("class", "")
.style("opacity", 1) .style("opacity", 1)
.style("fill", __gauge_color) // Where background color would receive customization. .style("fill", __gauge_color) // Where background color would receive customization.
.style("cursor", "pointer") .style("cursor", "pointer")
.attr("transform", "scale(1,1)") .attr("transform", "scale(1,1)")
.attr("d", function (d) { .attr("d", function (d) {
d.value = __gauge_max; d.value = __gauge_max;
d.startAngle = -1*(Math.PI/2); d.startAngle = -1 * (Math.PI / 2);
d.endAngle = Math.PI/2; d.endAngle = Math.PI / 2;
return getArc(d, true); return getArc(d, true);
}); });
mainArc.exit().transition().duration(durationForExit) mainArc.exit().transition().duration(durationForExit)
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();

Loading…
Cancel
Save