Skip to content

Commit

Permalink
rebasing on master and fixing linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Dec 16, 2016
1 parent 126f1de commit c665d4c
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 52 deletions.
23 changes: 11 additions & 12 deletions src/ui/public/vis_maps/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function DataFactory(Private) {
return _.toArray(arr);
}
return [this.data];
};
}

/**
* Returns an array of chart data objects
Expand All @@ -91,7 +91,7 @@ export default function DataFactory(Private) {
}

return visData;
};
}

/**
* get min and max for all cols, rows of data
Expand All @@ -107,8 +107,8 @@ export default function DataFactory(Private) {
min: Math.min(props.min, minMax.min),
max: Math.max(props.max, minMax.max)
};
}, {min: Infinity, max: -Infinity});
};
}, { min: Infinity, max: -Infinity });
}

/**
* Get attributes off the data, e.g. `tooltipFormatter` or `xAxisFormatter`
Expand All @@ -123,7 +123,7 @@ export default function DataFactory(Private) {
get(thing, def) {
const source = (this.data.rows || this.data.columns || [this.data])[0];
return _.get(source, thing, def);
};
}

/**
* Return an array of all value objects
Expand All @@ -140,7 +140,7 @@ export default function DataFactory(Private) {
.pluck('values')
.flattenDeep()
.value();
};
}

/**
* ensure that the datas ordered property has a min and max
Expand All @@ -164,7 +164,7 @@ export default function DataFactory(Private) {
if (missingMax) d.ordered.max = extent[1];
}
});
};
}

/**
* Calculates min and max values for all map data
Expand All @@ -177,12 +177,11 @@ export default function DataFactory(Private) {
* @returns {Array} min and max values
*/
mapDataExtents(series) {
let values;
values = _.map(series.rows, function (row) {
const values = _.map(series.rows, function (row) {
return row[row.length - 1];
});
return [_.min(values), _.max(values)];
};
}

/**
* Get the maximum number of series, considering each chart
Expand All @@ -194,8 +193,8 @@ export default function DataFactory(Private) {
return this.chartData().reduce(function (max, chart) {
return Math.max(max, chart.series.length);
}, 0);
};
}
}

return Data;
};
}
26 changes: 13 additions & 13 deletions src/ui/public/vis_maps/lib/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function DispatchClass(Private, config) {

if (isSeries) {
// Find object with the actual d value and add it to the point object
const object = _.find(series, {'label': label});
const object = _.find(series, { 'label': label });
if (object) {
eventData.value = +object.values[i].y;

Expand All @@ -71,7 +71,7 @@ export default function DispatchClass(Private, config) {
}

return eventData;
};
}

/**
* Returns a function that adds events and listeners to a D3 selection
Expand All @@ -91,7 +91,7 @@ export default function DispatchClass(Private, config) {
}
});
};
};
}

/**
*
Expand All @@ -118,7 +118,7 @@ export default function DispatchClass(Private, config) {
}

return addEvent('mouseover', hover);
};
}

/**
*
Expand All @@ -138,7 +138,7 @@ export default function DispatchClass(Private, config) {
}

return addEvent('mouseout', mouseout);
};
}

/**
*
Expand All @@ -154,7 +154,7 @@ export default function DispatchClass(Private, config) {
}

return addEvent('click', click);
};
}

/**
* Determine if we will allow brushing
Expand All @@ -167,7 +167,7 @@ export default function DispatchClass(Private, config) {

//Allow brushing for ordered axis - date histogram and histogram
return Boolean(xAxis.ordered);
};
}

/**
* Determine if brushing is currently enabled
Expand All @@ -177,7 +177,7 @@ export default function DispatchClass(Private, config) {
*/
isBrushable() {
return this.allowBrushing() && this.listenerCount('brush') > 0;
};
}

/**
* Mouseover Behavior
Expand All @@ -187,7 +187,7 @@ export default function DispatchClass(Private, config) {
*/
addMousePointer() {
return d3.select(this).style('cursor', 'pointer');
};
}

/**
* Highlight the element that is under the cursor
Expand All @@ -214,7 +214,7 @@ export default function DispatchClass(Private, config) {
*/
unHighlight(element) {
$('[data-label]', element.parentNode).css('opacity', 1);
};
}

/**
* Adds D3 brush to SVG and returns the brush function
Expand All @@ -226,7 +226,7 @@ export default function DispatchClass(Private, config) {
createBrush(xScale, svg) {
const self = this;
const visConfig = self.handler.visConfig;
const {width, height} = svg.node().getBBox();
const { width, height } = svg.node().getBBox();
const isHorizontal = self.handler.categoryAxes[0].axisConfig.isHorizontal();

// Brush scale
Expand Down Expand Up @@ -281,7 +281,7 @@ export default function DispatchClass(Private, config) {

return brush;
}
};
}
}

/**
Expand Down Expand Up @@ -312,4 +312,4 @@ export default function DispatchClass(Private, config) {
}

return Dispatch;
};
}
10 changes: 5 additions & 5 deletions src/ui/public/vis_maps/lib/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export default function LayoutFactory(Private) {
render() {
this.removeAll();
this.createLayout();
};
}

createLayout() {
const wrapper = this.appendElem(this.el, 'div', 'vis-wrapper');
wrapper.datum(this.data.data);
const colWrapper = this.appendElem(wrapper.node(), 'div', 'vis-col-wrapper');
const chartWrapper = this.appendElem(colWrapper.node(), 'div', 'chart-wrapper');
chartWrapper.call(mapSplit, colWrapper.node(), this.config);
};
}

appendElem(el, type, className) {
if (!el || !type || !className) {
Expand All @@ -39,12 +39,12 @@ export default function LayoutFactory(Private) {
return d3.select(el)
.append(type)
.attr('class', className);
};
}

removeAll() {
return d3.select(this.el).selectAll('*').remove();
};
}
}

return Layout;
};
}
6 changes: 3 additions & 3 deletions src/ui/public/vis_maps/lib/maps_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function MapsConfigFactory(Private) {
class MapsConfig {
constructor(mapsConfigArgs) {
this._values = _.defaultsDeep({}, mapsConfigArgs, DEFAULT_VIS_CONFIG);
};
}

get(property, defaults) {
if (_.has(this._values, property) || typeof defaults !== 'undefined') {
Expand All @@ -27,11 +27,11 @@ export default function MapsConfigFactory(Private) {
throw new Error(`Accessing invalid config property: ${property}`);
return defaults;
}
};
}

set(property, value) {
return _.set(this._values, property, value);
};
}
}

return MapsConfig;
Expand Down
10 changes: 5 additions & 5 deletions src/ui/public/vis_maps/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function MapsFactory(Private) {
if (first && added && this.handler) this.handler.enable(event);

return ret;
};
}

off(event, listener) {
const last = this.listenerCount(event) === 1;
Expand All @@ -64,7 +64,7 @@ export default function MapsFactory(Private) {
// Once all listeners are removed, disable the events in the handler
if (last && removed && this.handler) this.handler.disable(event);
return ret;
};
}

render(data, uiState) {
if (!data) {
Expand All @@ -76,12 +76,12 @@ export default function MapsFactory(Private) {
this.visConfig = new MapsConfig(this.mapsConfigArgs, this.data, this.uiState);
this.layout = new Layout(this.el, this.visConfig, this.data);
this.draw();
};
}

destroy() {
this.charts.forEach(chart => chart.destroy());
d3.select(this.el).selectAll('*').remove();
};
}

draw() {
this.layout.render();
Expand All @@ -103,4 +103,4 @@ export default function MapsFactory(Private) {
}

return Maps;
};
}
16 changes: 8 additions & 8 deletions src/ui/public/vis_maps/maps_renderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import VisRenderbotProvider from 'ui/vis/renderbot';
import MapsVisTypeBuildChartDataProvider from 'ui/vislib_vis_type/build_chart_data';
module.exports = function MapsRenderbotFactory(Private, $injector) {
const AngularPromise = $injector.get('Promise');
let Maps = Private(MapsProvider);
let Renderbot = Private(VisRenderbotProvider);
let buildChartData = Private(MapsVisTypeBuildChartDataProvider);
const Maps = Private(MapsProvider);
const Renderbot = Private(VisRenderbotProvider);
const buildChartData = Private(MapsVisTypeBuildChartDataProvider);

_.class(MapsRenderbot).inherits(Renderbot);
function MapsRenderbot(vis, $el, uiState) {
Expand All @@ -29,7 +29,7 @@ module.exports = function MapsRenderbotFactory(Private, $injector) {
};

MapsRenderbot.prototype._getMapsParams = function () {
let self = this;
const self = this;

return _.assign(
{},
Expand All @@ -52,9 +52,9 @@ module.exports = function MapsRenderbotFactory(Private, $injector) {
};

MapsRenderbot.prototype.destroy = function () {
let self = this;
const self = this;

let mapsVis = self.mapsVis;
const mapsVis = self.mapsVis;

_.forOwn(self.vis.listeners, function (listener, event) {
mapsVis.off(event, listener);
Expand All @@ -64,10 +64,10 @@ module.exports = function MapsRenderbotFactory(Private, $injector) {
};

MapsRenderbot.prototype.updateParams = function () {
let self = this;
const self = this;

// get full maps params object
let newParams = self._getMapsParams();
const newParams = self._getMapsParams();

// if there's been a change, replace the vis
if (!_.isEqual(newParams, self.mapsParams)) self._createVis();
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/vis_maps/maps_vis_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'plugins/kbn_vislib_vis_types/controls/vislib_basic_options';
import VisVisTypeProvider from 'ui/vis/vis_type';
import MapsVisTypeMapsRenderbotProvider from 'ui/vis_maps/maps_renderbot';
export default function MapsVisTypeFactory(Private) {
let VisType = Private(VisVisTypeProvider);
let MapsRenderbot = Private(MapsVisTypeMapsRenderbotProvider);
const VisType = Private(VisVisTypeProvider);
const MapsRenderbot = Private(MapsVisTypeMapsRenderbotProvider);


_.class(MapsVisType).inherits(VisType);
Expand All @@ -19,4 +19,4 @@ export default function MapsVisTypeFactory(Private) {
};

return MapsVisType;
};
}
6 changes: 3 additions & 3 deletions src/ui/public/vis_maps/visualizations/_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function ChartBaseClass(Private) {
const selection = d3.select(this.chartEl);
selection.selectAll('*').remove();
selection.call(this.draw());
};
}


/**
Expand All @@ -53,8 +53,8 @@ export default function ChartBaseClass(Private) {
tooltip.destroy();
});
selection.remove();
};
}
}

return Chart;
};
}

0 comments on commit c665d4c

Please sign in to comment.