Skip to content

Commit

Permalink
fixing indentation to match our style
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Sep 8, 2016
1 parent 9cb6b60 commit 0b63b83
Show file tree
Hide file tree
Showing 17 changed files with 422 additions and 421 deletions.
24 changes: 12 additions & 12 deletions src/ui/public/vislib/lib/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ export default function AlertsFactory(Private) {
const data = this.data;

const alerts = _(this.alertDefs)
.map(function (alertDef) {
if (!alertDef) return;
if (alertDef.test && !alertDef.test(vis, data)) return;
.map(function (alertDef) {
if (!alertDef) return;
if (alertDef.test && !alertDef.test(vis, data)) return;

const type = alertDef.type || 'info';
const icon = alertDef.icon || type;
const msg = alertDef.msg;
const type = alertDef.type || 'info';
const icon = alertDef.icon || type;
const msg = alertDef.msg;

// alert container
const $icon = $('<i>').addClass('vis-alerts-icon fa fa-' + icon);
const $text = $('<p>').addClass('vis-alerts-text').text(msg);
// alert container
const $icon = $('<i>').addClass('vis-alerts-icon fa fa-' + icon);
const $text = $('<p>').addClass('vis-alerts-text').text(msg);

return $('<div>').addClass('vis-alert vis-alert-' + type).append([$icon, $text]);
})
.compact();
return $('<div>').addClass('vis-alert vis-alert-' + type).append([$icon, $text]);
})
.compact();

if (!alerts.size()) return;

Expand Down
22 changes: 11 additions & 11 deletions src/ui/public/vislib/lib/axis_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ export default function AxisTitleFactory(Private) {
self.validateWidthandHeight(width, height);

div.append('svg')
.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('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);
});
};
};
Expand Down
26 changes: 13 additions & 13 deletions src/ui/public/vislib/lib/chart_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ export default function ChartTitleFactory(Private) {
self.validateWidthandHeight(width, height);

div.append('svg')
.attr('width', 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', 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')
Expand Down
42 changes: 21 additions & 21 deletions src/ui/public/vislib/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ export default function DataFactory(Private) {

this._attr = _.defaults(attr || {}, {
stack: d3.layout.stack()
.x(function (d) {
return d.x;
})
.y(function (d) {
if (offset === 'expand') {
return Math.abs(d.y);
}
return d.y;
})
.offset(offset || 'zero')
.x(function (d) {
return d.x;
})
.y(function (d) {
if (offset === 'expand') {
return Math.abs(d.y);
}
return d.y;
})
.offset(offset || 'zero')
});

if (attr.mode === 'stacked' && attr.type === 'histogram') {
Expand Down Expand Up @@ -484,10 +484,10 @@ export default function DataFactory(Private) {
}

const points = chart.series
.reduce(function (points, series) {
return points.concat(series.values);
}, [])
.map(getValue);
.reduce(function (points, series) {
return points.concat(series.values);
}, [])
.map(getValue);

return d3[extent](points);
};
Expand Down Expand Up @@ -557,13 +557,13 @@ export default function DataFactory(Private) {
const namedObj = this.returnNames(slices.children, 0, columns);

return _(namedObj)
.sortBy(function (obj) {
return obj.index;
})
.unique(function (d) {
return d.label;
})
.value();
.sortBy(function (obj) {
return obj.index;
})
.unique(function (d) {
return d.label;
})
.value();
}
};

Expand Down
58 changes: 29 additions & 29 deletions src/ui/public/vislib/lib/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,43 +265,43 @@ export default function DispatchClass(Private) {

// Brush scale
const brush = d3.svg.brush()
.x(xScale)
.on('brushend', function brushEnd() {
.x(xScale)
.on('brushend', function brushEnd() {

// Assumes data is selected at the chart level
// In this case, the number of data objects should always be 1
const data = d3.select(this).data()[0];
const isTimeSeries = (data.ordered && data.ordered.date);
// Assumes data is selected at the chart level
// In this case, the number of data objects should always be 1
const data = d3.select(this).data()[0];
const isTimeSeries = (data.ordered && data.ordered.date);

// Allows for brushing on d3.scale.ordinal()
const selected = xScale.domain().filter(function (d) {
return (brush.extent()[0] <= xScale(d)) && (xScale(d) <= brush.extent()[1]);
});
const range = isTimeSeries ? brush.extent() : selected;
// Allows for brushing on d3.scale.ordinal()
const selected = xScale.domain().filter(function (d) {
return (brush.extent()[0] <= xScale(d)) && (xScale(d) <= brush.extent()[1]);
});
const range = isTimeSeries ? brush.extent() : selected;

return self.emit('brush', {
range: range,
config: attr,
e: d3.event,
data: data
});
return self.emit('brush', {
range: range,
config: attr,
e: d3.event,
data: data
});
});

// if `addBrushing` is true, add brush canvas
if (self.listenerCount('brush')) {
svg.insert('g', 'g')
.attr('class', 'brush')
.call(brush)
.call(function (brushG) {
// hijack the brush start event to filter out right/middle clicks
const brushHandler = brushG.on('mousedown.brush');
if (!brushHandler) return; // touch events in use
brushG.on('mousedown.brush', function () {
if (validBrushClick(d3.event)) brushHandler.apply(this, arguments);
});
})
.selectAll('rect')
.attr('height', height - margin.top - margin.bottom);
.attr('class', 'brush')
.call(brush)
.call(function (brushG) {
// hijack the brush start event to filter out right/middle clicks
const brushHandler = brushG.on('mousedown.brush');
if (!brushHandler) return; // touch events in use
brushG.on('mousedown.brush', function () {
if (validBrushClick(d3.event)) brushHandler.apply(this, arguments);
});
})
.selectAll('rect')
.attr('height', height - margin.top - margin.bottom);

return brush;
}
Expand Down
34 changes: 17 additions & 17 deletions src/ui/public/vislib/lib/handler/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ export default function HandlerBaseClass(Private) {

// render the chart(s)
selection.selectAll('.chart')
.each(function (chartData) {
const chart = new self.ChartClass(self, this, chartData);
.each(function (chartData) {
const chart = new self.ChartClass(self, this, chartData);

self.vis.activeEvents().forEach(function (event) {
self.enable(event, chart);
});

charts.push(chart);
chart.render();
self.vis.activeEvents().forEach(function (event) {
self.enable(event, chart);
});

charts.push(chart);
chart.render();
});
};

chartEventProxyToggle(method) {
Expand Down Expand Up @@ -163,18 +163,18 @@ export default function HandlerBaseClass(Private) {
this.removeAll(this.el);

const div = d3.select(this.el)
.append('div')
// class name needs `chart` in it for the polling checkSize function
// to continuously call render on resize
.attr('class', 'visualize-error chart error');
.append('div')
// class name needs `chart` in it for the polling checkSize function
// to continuously call render on resize
.attr('class', 'visualize-error chart error');

if (message === 'No results found') {
div.append('div')
.attr('class', 'text-center visualize-error visualize-chart ng-scope')
.append('div').attr('class', 'item top')
.append('div').attr('class', 'item')
.append('h2').html('<i class="fa fa-meh-o"></i>')
.append('h4').text(message);
.attr('class', 'text-center visualize-error visualize-chart ng-scope')
.append('div').attr('class', 'item top')
.append('div').attr('class', 'item')
.append('h2').html('<i class="fa fa-meh-o"></i>')
.append('h4').text(message);

div.append('div').attr('class', 'item bottom');
return div;
Expand Down
15 changes: 8 additions & 7 deletions src/ui/public/vislib/lib/handler/types/point_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export default function ColumnHandler(Private) {
const ChartTitle = Private(VislibLibChartTitleProvider);
const Alerts = Private(VislibLibAlertsProvider);

function getData(vis, opts) {
if (opts.zeroFill) {
return new Data(injectZeros(vis.data), vis._attr, vis.uiState);
} else {
return new Data(vis.data, vis._attr, vis.uiState);
}
}
/*
* Create handlers for Area, Column, and Line charts which
* are all nearly the same minus a few details
Expand All @@ -26,13 +33,7 @@ export default function ColumnHandler(Private) {

return function (vis) {
const isUserDefinedYAxis = vis._attr.setYExtents;
let data;

if (opts.zeroFill) {
data = new Data(injectZeros(vis.data), vis._attr, vis.uiState);
} else {
data = new Data(vis.data, vis._attr, vis.uiState);
}
const data = getData(vis, opts);

return new Handler(vis, {
data: data,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/vislib/lib/layout/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ export default function LayoutFactory(Private) {
}

return d3.select(el)
.append(type)
.attr('class', className);
.append(type)
.attr('class', className);
};

/**
Expand Down
Loading

0 comments on commit 0b63b83

Please sign in to comment.