Jshint unused and undef cleanup for D3 JS

Removing unused and undefined variables in D3 javascript.
This ensures that once we enable it globally, the gate will not barf.

Change-Id: I054bdd17d32c26b21fb0aba4656aef61c81c9d66
Partial-bug: #1438620
This commit is contained in:
Cindy Lu 2015-04-22 20:50:16 -07:00
parent 576736a2e3
commit 55eea4436d
2 changed files with 19 additions and 19 deletions

View File

@ -442,20 +442,20 @@ horizon.d3_bar_chart = {
.style('stroke-width', 0) .style('stroke-width', 0)
.attr('d', self.wrapper.percentage_used_value()) .attr('d', self.wrapper.percentage_used_value())
.attr('tooltip-used', self.wrapper.tooltip_used_value()) .attr('tooltip-used', self.wrapper.tooltip_used_value())
.on('mouseover', function(d){ .on('mouseover', function(){
if ($(this).attr('tooltip-used')){ if ($(this).attr('tooltip-used')){
tooltip.html($(this).attr('tooltip-used')); tooltip.html($(this).attr('tooltip-used'));
} }
tooltip.style('visibility', 'visible'); tooltip.style('visibility', 'visible');
}) })
.on('mousemove', function(d){ .on('mousemove', function(){
var eventX = event.offsetX || event.layerX; var eventX = event.offsetX || event.layerX;
var eventY = event.offsetY || event.layerY; var eventY = event.offsetY || event.layerY;
tooltip tooltip
.style('top', (eventY - 10) + 'px') .style('top', (eventY - 10) + 'px')
.style('left',(eventX + 10) + 'px'); .style('left',(eventX + 10) + 'px');
}) })
.on('mouseout', function(d){ .on('mouseout', function(){
tooltip.style('visibility', 'hidden'); tooltip.style('visibility', 'hidden');
}) })
.transition() .transition()
@ -614,17 +614,17 @@ horizon.d3_bar_chart = {
.attr('ry', self.wrapper.lvl_curve) .attr('ry', self.wrapper.lvl_curve)
.style('fill', self.wrapper.bkgrnd) .style('fill', self.wrapper.bkgrnd)
.on('mouseover', function(d){ .on('mouseover', function(){
tooltip_free.style('visibility', 'visible'); tooltip_free.style('visibility', 'visible');
}) })
.on('mousemove', function(d){ .on('mousemove', function(){
var eventX = event.offsetX || event.layerX; var eventX = event.offsetX || event.layerX;
var eventY = event.offsetY || event.layerY; var eventY = event.offsetY || event.layerY;
tooltip_free tooltip_free
.style('top',(eventY - 10) + 'px') .style('top',(eventY - 10) + 'px')
.style('left',(eventX + 10) + 'px'); .style('left',(eventX + 10) + 'px');
}) })
.on('mouseout', function(d){tooltip_free.style('visibility', 'hidden');}); .on('mouseout', function(){tooltip_free.style('visibility', 'hidden');});
self.wrapper.bar.append('rect') self.wrapper.bar.append('rect')
.attr('class', 'unused_component_border') .attr('class', 'unused_component_border')

View File

@ -1,3 +1,4 @@
/* global Rickshaw */
/* /*
Draw line chart in d3. Draw line chart in d3.
@ -380,7 +381,7 @@ horizon.d3_line_chart = {
self.start_loading(); self.start_loading();
horizon.ajax.queue({ horizon.ajax.queue({
url: self.final_url, url: self.final_url,
success: function (data, textStatus, jqXHR) { success: function (data) {
// Clearing the old chart data. // Clearing the old chart data.
self.jquery_element.empty(); self.jquery_element.empty();
$(self.legend_element).empty(); $(self.legend_element).empty();
@ -400,7 +401,7 @@ horizon.d3_line_chart = {
self.render(); self.render();
} }
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function () {
$(self.html_element).html(gettext('No data available.')); $(self.html_element).html(gettext('No data available.'));
$(self.legend_element).empty(); $(self.legend_element).empty();
// Setting a fix height breaks things when legend is getting // Setting a fix height breaks things when legend is getting
@ -409,7 +410,7 @@ horizon.d3_line_chart = {
// FIXME add proper fail message // FIXME add proper fail message
horizon.alert('error', gettext('An error occurred. Please try again later.')); horizon.alert('error', gettext('An error occurred. Please try again later.'));
}, },
complete: function (jqXHR, textStatus) { complete: function () {
self.finish_loading(); self.finish_loading();
} }
}); });
@ -474,7 +475,7 @@ horizon.d3_line_chart = {
graph.render(); graph.render();
if (self.hover_formatter === 'verbose'){ if (self.hover_formatter === 'verbose'){
var hoverDetail = new Rickshaw.Graph.HoverDetail({ new Rickshaw.Graph.HoverDetail({
graph: graph, graph: graph,
formatter: function(series, x, y) { formatter: function(series, x, y) {
if(y % 1 === 0) { if(y % 1 === 0) {
@ -505,17 +506,17 @@ horizon.d3_line_chart = {
element: self.legend_element element: self.legend_element
}); });
var shelving = new Rickshaw.Graph.Behavior.Series.Toggle({ new Rickshaw.Graph.Behavior.Series.Toggle({
graph: graph, graph: graph,
legend: legend legend: legend
}); });
var order = new Rickshaw.Graph.Behavior.Series.Order({ new Rickshaw.Graph.Behavior.Series.Order({
graph: graph, graph: graph,
legend: legend legend: legend
}); });
var highlighter = new Rickshaw.Graph.Behavior.Series.Highlight({ new Rickshaw.Graph.Behavior.Series.Highlight({
graph: graph, graph: graph,
legend: legend legend: legend
}); });
@ -532,7 +533,7 @@ horizon.d3_line_chart = {
}; };
if (!self.settings.axes_y_label){ if (!self.settings.axes_y_label){
// hiding label of Y axis if setting is set to false // hiding label of Y axis if setting is set to false
axes_y_settings.tickFormat = (function (d) { return ''; }); axes_y_settings.tickFormat = (function () { return ''; });
} }
var axes_y = new Rickshaw.Graph.Axis.Y(axes_y_settings); var axes_y = new Rickshaw.Graph.Axis.Y(axes_y_settings);
axes_y.render(); axes_y.render();
@ -701,7 +702,7 @@ horizon.d3_line_chart = {
* has to be projected to forms. So when form input is changed, * has to be projected to forms. So when form input is changed,
* all connected charts are refreshed. * all connected charts are refreshed.
*/ */
connect_forms_to_charts = function(){ var connect_forms_to_charts = function(){
$(selector).each(function() { $(selector).each(function() {
var chart = $(this); var chart = $(this);
$(chart.data('form-selector')).each(function(){ $(chart.data('form-selector')).each(function(){
@ -724,7 +725,7 @@ horizon.d3_line_chart = {
* @param event_name Event name we want to delegate. * @param event_name Event name we want to delegate.
* @param settings An object containing settings of the chart. * @param settings An object containing settings of the chart.
*/ */
delegate_event_and_refresh_charts = function(selector, event_name, settings) { var delegate_event_and_refresh_charts = function(selector, event_name, settings) {
$('form').delegate(selector, event_name, function() { $('form').delegate(selector, event_name, function() {
/* /*
Registering 'any event' on form element by delegating. This way it Registering 'any event' on form element by delegating. This way it
@ -747,7 +748,7 @@ horizon.d3_line_chart = {
* A helper function for catching change event of form selectboxes * A helper function for catching change event of form selectboxes
* connected to charts. * connected to charts.
*/ */
bind_select_box_change = function(settings) { var bind_select_box_change = function(settings) {
delegate_event_and_refresh_charts(select_box_selector, 'change', settings); delegate_event_and_refresh_charts(select_box_selector, 'change', settings);
}; };
@ -755,8 +756,7 @@ horizon.d3_line_chart = {
* A helper function for catching changeDate event of form datepickers * A helper function for catching changeDate event of form datepickers
* connected to charts. * connected to charts.
*/ */
bind_datepicker_change = function(settings) { var bind_datepicker_change = function(settings) {
var now = new Date();
$(datepicker_selector).each(function() { $(datepicker_selector).each(function() {
var el = $(this); var el = $(this);