Skip to content

Commit

Permalink
Remove lodash as dependencies (#16)
Browse files Browse the repository at this point in the history
* Remove lodash as dependencies
  • Loading branch information
MrMeison authored and ignatvilesov committed Jun 15, 2017
1 parent 3381365 commit 918b701
Show file tree
Hide file tree
Showing 10 changed files with 6,082 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0
* Removed `lodash`
* Updated dependencies

## 1.0.1
* Update ChartUtils to use SVG utils version 1.0.0
* Add CHANGELOG
16 changes: 0 additions & 16 deletions docs/usage/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ npm install powerbi-visuals-utils-chartutils --save

This command installs the package and adds a package as a dependency to your ```package.json```

After installation of the package, you should install the [typings](https://www.npmjs.com/package/typings) package as a global dependency by using the following command:
```bash
npm install typings -g
```

After that, you should run the following command in the directory with your current custom visual:
```bash
typings install --save --global dt~d3#0.0.0+20160907005744 dt~jquery#1.10.0+20160929162922 dt~lodash#4.14.0+20161110215204
```

This command installs type declarations to the ```typings``` directory. These declarations are necessary for TypeScript compiler and Intellisense.

## Including declarations to the build flow
The package contains ```d.ts``` declarations file, it's necessary for TypeScript compiler and it helps to develop your visuals fast and confident. You should add the following files to the ```files``` property of ```tsconfig.json```:
* ```typings/index.d.ts```
Expand All @@ -59,9 +47,7 @@ As a result you will have the following file structure:

## Including JavaScript artifacts to the custom visual
To use the package with your custom visuals you should add the following files to the ```externalJS``` property of ```pbiviz.json``` :
* ```node_modules/jquery/dist/jquery.min.js```
* ```node_modules/d3/d3.min.js```
* ```node_modules/lodash/lodash.min.js```
* ```node_modules/globalize/lib/globalize.js```
* ```node_modules/globalize/lib/cultures/globalize.culture.en-US.js```
* ```node_modules/powerbi-visuals-utils-typeutils/lib/index.js```
Expand All @@ -78,9 +64,7 @@ As a result you will have the following file structure:
"author": {...},
"assets": {...},
"externalJS": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/d3/d3.min.js",
"node_modules/lodash/lodash.min.js",
"node_modules/globalize/lib/globalize.js",
"node_modules/globalize/lib/cultures/globalize.culture.en-US.js",
"node_modules/powerbi-visuals-utils-typeutils/lib/index.js",
Expand Down
20 changes: 10 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ var powerbi;
var xMax = 0; // bottom margin
var ordinalLabelOffset = xAxisProperties.categoryThickness ? xAxisProperties.categoryThickness / 2 : 0;
var scaleIsOrdinal = isOrdinalScale(xAxisProperties.scale);
var hasHierarchy = !_.isEmpty(axes.xStack);
var hasHierarchy = !arrayIsEmpty(axes.xStack);
var xLabelOuterPadding = 0;
if (xAxisProperties.outerPadding !== undefined) {
xLabelOuterPadding = xAxisProperties.outerPadding;
Expand Down Expand Up @@ -703,7 +703,7 @@ var powerbi;
}
// Prepare Tick Values for formatting
var tickValues;
if (isScalar && !_.isEmpty(dataDomain) && bestTickCount === 1) {
if (isScalar && bestTickCount === 1 && !arrayIsEmpty(dataDomain)) {
tickValues = [dataDomain[0]];
}
else {
Expand Down Expand Up @@ -771,7 +771,7 @@ var powerbi;
function getScalarLabelMaxWidth(scale, tickValues) {
// find the distance between two ticks. scalar ticks can be anywhere, such as:
// |---50----------100--------|
if (scale && !_.isEmpty(tickValues)) {
if (scale && !arrayIsEmpty(tickValues)) {
return Math.abs(scale(tickValues[1]) - scale(tickValues[0]));
}
return 1;
Expand Down Expand Up @@ -1042,7 +1042,7 @@ var powerbi;
}
axis_1.createValueDomain = createValueDomain;
function createOrdinalDomain(data) {
if (_.isEmpty(data)) {
if (arrayIsEmpty(data)) {
return [];
}
// each series shares the same categories for oridinal axes (even if a series has some nulls)
Expand Down Expand Up @@ -1184,7 +1184,7 @@ var powerbi;
});
}
else {
var maxLabelWidth = !_.isEmpty(axisProperties.xLabelMaxWidths) ? axisProperties.xLabelMaxWidths[datum] : axisProperties.xLabelMaxWidth;
var maxLabelWidth = !arrayIsEmpty(axisProperties.xLabelMaxWidths) ? axisProperties.xLabelMaxWidths[datum] : axisProperties.xLabelMaxWidth;
var newLabelText = textTruncator(textProperties, maxLabelWidth);
if (newLabelText !== labelText)
axisLabel.text(newLabelText);
Expand Down Expand Up @@ -1400,6 +1400,9 @@ var powerbi;
return value / Math.pow(10, log10) === 1;
}
axis_1.powerOfTen = powerOfTen;
function arrayIsEmpty(array) {
return !(array && array.length);
}
})(axis = chart.axis || (chart.axis = {}));
})(chart = utils.chart || (utils.chart = {}));
})(utils = extensibility.utils || (extensibility.utils = {}));
Expand Down Expand Up @@ -2256,7 +2259,7 @@ var powerbi;
}
};
SVGLegend.prototype.calculateTitleLayout = function (title) {
var width = 0, hasTitle = !_.isEmpty(title);
var width = 0, hasTitle = !!title;
if (hasTitle) {
var isHorizontal = this.isTopOrBottom(this.orientation), maxMeasureLength = void 0;
if (isHorizontal) {
Expand All @@ -2281,7 +2284,6 @@ var powerbi;
// Remeasure the text since its measurement may be different than the max (ex. when the max is negative, the text will be ellipsis, and not have a negative width)
width = textMeasurementService.measureSvgTextWidth(textProperties);
}
;
if (isHorizontal) {
width += SVGLegend.TitlePadding;
}
Expand Down Expand Up @@ -2450,7 +2452,7 @@ var powerbi;
});
}
// If there are items at max width, evenly redistribute the extra space to them
var itemsOverMax = _.filter(legendItems, function (li) { return li.desiredOverMaxWidth; });
var itemsOverMax = legendItems.filter(function (li) { return li.desiredOverMaxWidth; });
var numItemsOverMax = itemsOverMax.length;
if (numItemsOverMax > 0) {
var extraWidth = availableWidth - occupiedWidth;
Expand Down Expand Up @@ -3870,12 +3872,10 @@ var powerbi;
return textWidth > maxTextWidth;
}
utils.isTextWidthOverflows = isTextWidthOverflows;
;
function isTextHeightOverflows(textHeight, innerChordLength) {
return textHeight > innerChordLength;
}
utils.isTextHeightOverflows = isTextHeightOverflows;
;
})(utils = dataLabel.utils || (dataLabel.utils = {}));
})(dataLabel = chart.dataLabel || (chart.dataLabel = {}));
})(chart = utils_1.chart || (utils_1.chart = {}));
Expand Down
Loading

0 comments on commit 918b701

Please sign in to comment.