Dragnipur / tiny-angular-wordcloud

A simple Angular wordcloud generator for AngularJS without any external dependencies.
MIT License
10 stars 4 forks source link

Words are too close together #10

Open vishakhadamle opened 7 years ago

vishakhadamle commented 7 years ago

Is there any way to increase the spacing between the words? They are too close together for my use case.

rmsmq commented 6 years ago

I made small modifications to the source to achieve this. First allow passing of a word buffer variable

scope: {
        words: '=',
        onClick: '&',
        hasLinks: '=',
        buffer: '=?'
  },

Then assign a default buffer value if none has been set

if (angular.isUndefined(scope.buffer)) {
    scope.buffer = 0;
}

Then use the buffer in the collision detection

function collisionDetected(spot, takenSpot) {
    if (spot.startX > takenSpot.endX + scope.buffer || spot.endX < takenSpot.startX - scope.buffer) {
                            return false;
    }

    return !(spot.startY > takenSpot.endY + scope.buffer || spot.endY < takenSpot.startY - scope.buffer);
}