correcting style guide issues and YUI doc problems

This commit is contained in:
Shelby Sturgis 2014-10-15 17:38:46 +03:00
parent 89ddcc8443
commit fea744a5b1
23 changed files with 199 additions and 210 deletions

View file

@ -60,14 +60,14 @@ define(function (require) {
.attr('width', width)
.attr('height', height)
.append('text')
.attr('transform', function () {
if (div.attr('class') === 'x-axis-title') {
return 'translate(' + width / 2 + ',11)';
}
return 'translate(11,' + height / 2 + ')rotate(270)';
})
.attr('text-anchor', 'middle')
.text(title);
.attr('transform', function () {
if (div.attr('class') === 'x-axis-title') {
return 'translate(' + width / 2 + ',11)';
}
return 'translate(11,' + height / 2 + ')rotate(270)';
})
.attr('text-anchor', 'middle')
.text(title);
});
};
};

View file

@ -106,24 +106,24 @@ define(function (require) {
self.validateWidthandHeight(width, height);
div.append('svg')
.attr('width', function () {
if (dataType === 'rows') {
return 15;
}
return width;
})
.attr('height', height)
.append('text')
.attr('transform', function () {
if (dataType === 'rows') {
return 'translate(' + txtHtOffset + ',' + height / 2 + ')rotate(270)';
}
return 'translate(' + width / 2 + ',' + txtHtOffset + ')';
})
.attr('text-anchor', 'middle')
.text(function (d) {
return d.label;
});
.attr('width', function () {
if (dataType === 'rows') {
return 15;
}
return width;
})
.attr('height', height)
.append('text')
.attr('transform', function () {
if (dataType === 'rows') {
return 'translate(' + txtHtOffset + ',' + height / 2 + ')rotate(270)';
}
return 'translate(' + width / 2 + ',' + txtHtOffset + ')';
})
.attr('text-anchor', 'middle')
.text(function (d) {
return d.label;
});
// truncate long chart titles
div.selectAll('text')

View file

@ -82,7 +82,7 @@ define(function (require) {
_.forEach(visData, function countSeriesLength(obj) {
var dataLength = obj.series ? obj.series.length : obj.slices.children.length;
var label = dataLength === 1 && obj.series ? obj.series[0].label : undefined;
var label = (dataLength === 1 && obj.series) ? obj.series[0].label : undefined;
if (!seriesLabel) {
seriesLabel = label;
@ -167,7 +167,7 @@ define(function (require) {
*/
Data.prototype.shouldBeStacked = function (series) {
// Series should be an array
return this._attr.type === 'histogram' && series.length > 1;
return (this._attr.type === 'histogram' && series.length > 1);
};
/**
@ -250,7 +250,7 @@ define(function (require) {
var self = this;
_.forEach(array, function (obj) {
var fieldFormatter = columns && columns[index].field ? columns[index].field.format.convert : function (d) { return d; };
var fieldFormatter = (columns && columns[index].field) ? columns[index].field.format.convert : function (d) { return d; };
names.push({ key: fieldFormatter(obj.name), index: index });
if (obj.children) {
@ -282,12 +282,12 @@ define(function (require) {
var namedObj = this.returnNames(slices.children, 0, columns);
return _(namedObj)
.sortBy(function (obj) {
return obj.index;
})
.pluck('key')
.unique()
.value();
.sortBy(function (obj) {
return obj.index;
})
.pluck('key')
.unique()
.value();
}
};

View file

@ -1,5 +1,5 @@
define(function (require) {
return function DispatchClass(d3, Private) {
return function DispatchClass(d3) {
var _ = require('lodash');
/**
@ -120,10 +120,10 @@ define(function (require) {
// if `addBrushing` is true, add brush canvas
if (isBrush) {
svg.append('g')
.attr('class', 'brush')
.call(brush)
.selectAll('rect')
.attr('height', height - margin.top - margin.bottom);
.attr('class', 'brush')
.call(brush)
.selectAll('rect')
.attr('height', height - margin.top - margin.bottom);
}
return brush;

View file

@ -1,7 +1,5 @@
define(function (require) {
return function ColumnHandler(d3, Private) {
var _ = require('lodash');
var injectZeros = Private(require('components/vislib/components/zero_injection/inject_zeros'));
var Handler = Private(require('components/vislib/lib/handler/handler'));
var Data = Private(require('components/vislib/lib/data'));
@ -19,7 +17,7 @@ define(function (require) {
return function (vis) {
var data = new Data(injectZeros(vis.data), vis._attr);
var ColumnHandler = new Handler(vis, {
return new Handler(vis, {
data: data,
legend: new Legend(vis, vis.el, data.getLabels(), data.getColorFunc(), vis._attr),
axisTitle: new AxisTitle(vis.el, data.get('xAxisLabel'), data.get('yAxisLabel')),
@ -37,8 +35,6 @@ define(function (require) {
_attr: vis._attr
})
});
return ColumnHandler;
};
};
});

View file

@ -1,6 +1,5 @@
define(function (require) {
return function PieHandler(d3, Private) {
var Handler = Private(require('components/vislib/lib/handler/handler'));
var Data = Private(require('components/vislib/lib/data'));
var Legend = Private(require('components/vislib/lib/legend'));
@ -13,12 +12,10 @@ define(function (require) {
return function (vis) {
var data = new Data(vis.data, vis._attr);
var PieHandler = new Handler(vis, {
return new Handler(vis, {
legend: new Legend(vis, vis.el, data.pieNames(), data.getPieColorFunc(), vis._attr),
chartTitle: new ChartTitle(vis.el)
});
return PieHandler;
};
};
});

View file

@ -8,32 +8,32 @@ define(function () {
return function split(selection) {
selection.each(function (data) {
var div = d3.select(this)
.attr('class', function () {
if (data.rows) {
return 'chart-wrapper-row';
} else if (data.columns) {
return 'chart-wrapper-column';
} else {
return 'chart-wrapper';
}
});
.attr('class', function () {
if (data.rows) {
return 'chart-wrapper-row';
} else if (data.columns) {
return 'chart-wrapper-column';
} else {
return 'chart-wrapper';
}
});
var divClass;
var charts = div.selectAll('charts')
.append('div')
.data(function (d) {
if (d.rows) {
divClass = 'chart-row';
return d.rows;
} else if (d.columns) {
divClass = 'chart-column';
return d.columns;
} else {
divClass = 'chart';
return [d];
}
})
.enter()
.append('div')
.data(function (d) {
if (d.rows) {
divClass = 'chart-row';
return d.rows;
} else if (d.columns) {
divClass = 'chart-column';
return d.columns;
} else {
divClass = 'chart';
return [d];
}
})
.enter()
.append('div')
.attr('class', function () {
return divClass;

View file

@ -13,11 +13,11 @@ define(function () {
if (!data.series) {
div.selectAll('.chart-title')
.append('div')
.data(function (d) {
return d.rows ? d.rows : d.columns;
})
.enter()
.append('div')
.data(function (d) {
return d.rows ? d.rows : d.columns;
})
.enter()
.append('div')
.attr('class', 'chart-title');

View file

@ -12,11 +12,11 @@ define(function () {
var div = d3.select(this);
div.selectAll('.x-axis-div')
.append('div')
.data(function (d) {
return d.columns ? d.columns : [d];
})
.enter()
.append('div')
.data(function (d) {
return d.columns ? d.columns : [d];
})
.enter()
.append('div')
.attr('class', 'x-axis-div');
});

View file

@ -12,11 +12,11 @@ define(function () {
var div = d3.select(this);
div.selectAll('.y-axis-div')
.append('div')
.data(function (d) {
return d.rows ? d.rows : [d];
})
.enter()
.append('div')
.data(function (d) {
return d.rows ? d.rows : [d];
})
.enter()
.append('div')
.attr('class', 'y-axis-div');
});

View file

@ -10,32 +10,32 @@ define(function () {
return function split(selection) {
selection.each(function (data) {
var div = d3.select(this)
.attr('class', function () {
if (data.rows) {
return 'chart-wrapper-row';
} else if (data.columns) {
return 'chart-wrapper-column';
} else {
return 'chart-wrapper';
}
});
.attr('class', function () {
if (data.rows) {
return 'chart-wrapper-row';
} else if (data.columns) {
return 'chart-wrapper-column';
} else {
return 'chart-wrapper';
}
});
var divClass;
var charts = div.selectAll('charts')
.append('div')
.data(function (d) {
if (d.rows) {
divClass = 'chart-row';
return d.rows;
} else if (d.columns) {
divClass = 'chart-column';
return d.columns;
} else {
divClass = 'chart';
return [d];
}
})
.enter()
.append('div')
.data(function (d) {
if (d.rows) {
divClass = 'chart-row';
return d.rows;
} else if (d.columns) {
divClass = 'chart-column';
return d.columns;
} else {
divClass = 'chart';
return [d];
}
})
.enter()
.append('div')
.attr('class', function () {
return divClass;

View file

@ -15,11 +15,11 @@ define(function () {
if (!data.slices) {
div.selectAll('.chart-title')
.append('div')
.data(function (d) {
return d.rows ? d.rows : d.columns;
})
.enter()
.append('div')
.data(function (d) {
return d.rows ? d.rows : d.columns;
})
.enter()
.append('div')
.attr('class', 'chart-title');

View file

@ -1,6 +1,5 @@
define(function (require) {
return function ColumnLayoutFactory(d3, Private) {
var chartSplit = Private(require('components/vislib/lib/layout/splits/column_chart/chart_split'));
var yAxisSplit = Private(require('components/vislib/lib/layout/splits/column_chart/y_axis_split'));
var xAxisSplit = Private(require('components/vislib/lib/layout/splits/column_chart/x_axis_split'));

View file

@ -1,6 +1,5 @@
define(function (require) {
return function ColumnLayoutFactory(d3, Private) {
var chartSplit = Private(require('components/vislib/lib/layout/splits/pie_chart/chart_split'));
var chartTitleSplit = Private(require('components/vislib/lib/layout/splits/pie_chart/chart_title_split'));

View file

@ -44,12 +44,12 @@ define(function (require) {
*/
Legend.prototype.header = function (el, args) {
return el.append('div')
.attr('class', 'header')
.append('div')
.attr('class', 'column-labels')
.html(function () {
return legendHeaderTemplate(args._attr);
});
.attr('class', 'header')
.append('div')
.attr('class', 'column-labels')
.html(function () {
return legendHeaderTemplate(args._attr);
});
};
/**
@ -65,15 +65,15 @@ define(function (require) {
var self = this;
return el.append('ul')
.attr('class', function () {
if (args._attr.isOpen) {
return 'legend-ul';
}
return 'legend-ul hidden';
})
.selectAll('li')
.data(arrOfLabels)
.enter()
.attr('class', function () {
if (args._attr.isOpen) {
return 'legend-ul';
}
return 'legend-ul hidden';
})
.selectAll('li')
.data(arrOfLabels)
.enter()
.append('li')
.attr('class', function (d) {
return 'color ' + self.colorToClass(args.color(d));
@ -132,16 +132,16 @@ define(function (require) {
});
visEl.selectAll('.color')
.on('mouseover', function (d) {
var liClass = '.' + self.colorToClass(self.color(d));
visEl.selectAll('.color').style('opacity', self._attr.blurredOpacity);
// select series on chart
visEl.selectAll(liClass).style('opacity', self._attr.focusOpacity);
})
.on('mouseout', function () {
visEl.selectAll('.color').style('opacity', self._attr.defaultOpacity);
});
.on('mouseover', function (d) {
var liClass = '.' + self.colorToClass(self.color(d));
visEl.selectAll('.color').style('opacity', self._attr.blurredOpacity);
// select series on chart
visEl.selectAll(liClass).style('opacity', self._attr.focusOpacity);
})
.on('mouseout', function () {
visEl.selectAll('.color').style('opacity', self._attr.defaultOpacity);
});
};
return Legend;

View file

@ -49,22 +49,22 @@ define(function (require) {
var element = d3.select(this);
element
.on('mousemove.tip', function (d) {
var placement = self.getTooltipPlacement(d3.event);
var events = self.events ? self.events.eventResponse(d, i) : d;
.on('mousemove.tip', function (d) {
var placement = self.getTooltipPlacement(d3.event);
var events = self.events ? self.events.eventResponse(d, i) : d;
// return text and position for tooltip
return tooltipDiv.datum(events)
.html(tooltipFormatter)
.style('visibility', 'visible')
.style('left', placement.left + 'px')
.style('top', placement.top + 'px');
})
.on('mouseout.tip', function () {
return tooltipDiv.style('visibility', 'hidden')
.style('left', '-500px')
.style('top', '-500px');
});
// return text and position for tooltip
return tooltipDiv.datum(events)
.html(tooltipFormatter)
.style('visibility', 'visible')
.style('left', placement.left + 'px')
.style('top', placement.top + 'px');
})
.on('mouseout.tip', function () {
return tooltipDiv.style('visibility', 'hidden')
.style('left', '-500px')
.style('top', '-500px');
});
});
};
};

View file

@ -34,9 +34,7 @@ define(function (require) {
* @returns {D3.UpdateSelection} Appends x axis to visualization
*/
XAxis.prototype.render = function () {
d3.select(this.el)
.selectAll('.x-axis-div')
.call(this.draw());
d3.select(this.el).selectAll('.x-axis-div').call(this.draw());
};
/**
@ -369,16 +367,16 @@ define(function (require) {
var titleHeight = yAxisTitle.height();
text = visEl.select('.x-axis-title')
.select('svg')
.attr('width', titleWidth)
.select('text')
.attr('transform', 'translate(' + (titleWidth / 2) + ',11)');
.select('svg')
.attr('width', titleWidth)
.select('text')
.attr('transform', 'translate(' + (titleWidth / 2) + ',11)');
text = visEl.select('.y-axis-title')
.select('svg')
.attr('height', titleHeight)
.select('text')
.attr('transform', 'translate(11,' + (titleHeight / 2) + ')rotate(-90)');
.select('svg')
.attr('height', titleHeight)
.select('text')
.attr('transform', 'translate(11,' + (titleHeight / 2) + ')rotate(-90)');
if ($visEl.find('.x-axis-chart-title').length) {
xAxisChartTitle = $visEl.find('.x-axis-chart-title');
@ -387,10 +385,10 @@ define(function (require) {
titles = visEl.select('.x-axis-chart-title').selectAll('.chart-title');
titles.each(function () {
text = d3.select(this)
.select('svg')
.attr('width', titleWidth)
.select('text')
.attr('transform', 'translate(' + (titleWidth / 2) + ',11)');
.select('svg')
.attr('width', titleWidth)
.select('text')
.attr('transform', 'translate(' + (titleWidth / 2) + ',11)');
});
}
@ -401,10 +399,10 @@ define(function (require) {
titles = visEl.select('.y-axis-chart-title').selectAll('.chart-title');
titles.each(function () {
text = d3.select(this)
.select('svg')
.attr('height', titleHeight)
.select('text')
.attr('transform', 'translate(11,' + (titleHeight / 2) + ')rotate(-90)');
.select('svg')
.attr('height', titleHeight)
.select('text')
.attr('transform', 'translate(11,' + (titleHeight / 2) + ')rotate(-90)');
});
}

View file

@ -40,9 +40,9 @@ define(function (require) {
YAxis.prototype.getYScale = function (height) {
// save reference to y scale
this.yScale = d3.scale.linear()
.domain([0, this.yMax])
.range([height, 0])
.nice(this.tickScale(height));
.domain([0, this.yMax])
.range([height, 0])
.nice(this.tickScale(height));
return this.yScale;
};
@ -64,10 +64,10 @@ define(function (require) {
// Create the d3 yAxis function
this.yAxis = d3.svg.axis()
.scale(yScale)
.tickFormat(d3.format('s'))
.ticks(this.tickScale(height))
.orient('left');
.scale(yScale)
.tickFormat(d3.format('s'))
.ticks(this.tickScale(height))
.orient('left');
if (this.yScale.domain()[1] <= 10) {
this.yAxis.tickFormat(d3.format('n'));
@ -88,9 +88,9 @@ define(function (require) {
*/
YAxis.prototype.tickScale = function (height) {
var yTickScale = d3.scale.linear()
.clamp(true)
.domain([20, 40, 1000])
.range([0, 3, 11]);
.clamp(true)
.domain([20, 40, 1000])
.range([0, 3, 11]);
return Math.ceil(yTickScale(height));
};
@ -125,13 +125,13 @@ define(function (require) {
// Append svg and y axis
svg = div.append('svg')
.attr('width', width)
.attr('height', height + margin.top + margin.bottom);
.attr('width', width)
.attr('height', height + margin.top + margin.bottom);
svg.append('g')
.attr('class', 'y axis')
.attr('transform', 'translate(' + (width - 2) + ',' + margin.top + ')')
.call(yAxis);
.attr('class', 'y axis')
.attr('transform', 'translate(' + (width - 2) + ',' + margin.top + ')')
.call(yAxis);
});
};
};

View file

@ -60,7 +60,7 @@ define(function (require) {
if (error instanceof errors.ContainerTooSmall) {
this.handler.error(error.message);
} else {
console.error(error.message);
console.error(error.stack);
}
}
};

View file

@ -32,7 +32,7 @@ define(function (require) {
fieldIndex = _.findIndex(raw, {'categoryName': 'group'});
}
this.fieldFormatter = raw && raw[fieldIndex] ? raw[fieldIndex].field.format.convert : function (d) { return d; };
this.fieldFormatter = (raw && raw[fieldIndex]) ? raw[fieldIndex].field.format.convert : function (d) { return d; };
ColumnChart.Super.apply(this, arguments);
@ -198,9 +198,9 @@ define(function (require) {
*/
ColumnChart.prototype.mouseOverBar = function (that) {
return d3.select(that)
.classed('hover', true)
.style('stroke', '#333')
.style('cursor', 'pointer');
.classed('hover', true)
.style('stroke', '#333')
.style('cursor', 'pointer');
};
/**
@ -212,8 +212,8 @@ define(function (require) {
*/
ColumnChart.prototype.mouseOutBar = function (that) {
return d3.select(that)
.classed('hover', false)
.style('stroke', null);
.classed('hover', false)
.style('stroke', null);
};
/**

View file

@ -31,7 +31,7 @@ define(function (require) {
fieldIndex = _.findIndex(raw, {'categoryName': 'group'});
}
this.fieldFormatter = raw && raw[fieldIndex] ? raw[fieldIndex].field.format.convert : function (d) { return d; };
this.fieldFormatter = (raw && raw[fieldIndex]) ? raw[fieldIndex].field.format.convert : function (d) { return d; };
LineChart.Super.apply(this, arguments);
// Line chart specific attributes
@ -218,14 +218,14 @@ define(function (require) {
return svg
.attr('clip-path', 'url(#' + id + ')')
.append('clipPath')
.attr('id', id)
.attr('id', id)
.append('rect')
.attr('x', startX)
.attr('y', startY)
.attr('width', width)
// Adding clipPathBuffer to height so it doesn't
// cutoff the lower part of the chart
.attr('height', height + clipPathBuffer);
.attr('x', startX)
.attr('y', startY)
.attr('width', width)
// Adding clipPathBuffer to height so it doesn't
// cutoff the lower part of the chart
.attr('height', height + clipPathBuffer);
};
/**
@ -281,7 +281,7 @@ define(function (require) {
.attr('width', width + margin.left + margin.right)
.attr('height', height + margin.top + margin.bottom)
.append('g')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
self.addClipPath(svg, width, height);

View file

@ -37,8 +37,8 @@ define(function (require) {
* Adds Events to SVG paths
*
* @method addPathEvents
* @param path {D3.UpdateSelection} Reference to SVG path
* @returns {D3.UpdateSelection} SVG path with event listeners attached
* @param path {D3.Selection} Reference to SVG path
* @returns {D3.Selection} SVG path with event listeners attached
*/
PieChart.prototype.addPathEvents = function (path) {
var events = this.events;

View file

@ -6,7 +6,7 @@ define(function (require) {
*
* @module visLib
* @submodule VisTypeFactory
* @param Private {Service} Loads any function as an angular module
* @param Private {Object} Loads any function as an angular module
* @return {Function} Returns an Object of Visualization classes
*/
return {