Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithm improvement: Compute maxHeight #9

Merged
merged 1 commit into from
Jul 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/area-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ function areaLabel(area) {
// The minimum label bounding box height in pixels.
minHeight = 2,

// The maximum label bounding box height in pixels.
maxHeight = 1000,

// The tolerance within we wish to optimize the bounding box height.
epsilon = 0.01,

Expand Down Expand Up @@ -121,6 +118,11 @@ function areaLabel(area) {
// The aspect ratio of the text label bounding box.
var aspect = boxWidth / boxHeight;

// Compute maximum possible label bounding box height in pixels.
var maxHeight = d3.max(data, function (d) {
return y0(d) - y1(d);
});

// The test function for use in the bisection method.
var test = function (testHeight){
return fits(data, aspect, testHeight, true);
Expand Down Expand Up @@ -170,11 +172,6 @@ function areaLabel(area) {
return arguments.length ? (minHeight = +_, my) : minHeight;
};

// TODO compute this from the area, no need to have this constant.
my.maxHeight = function(_) {
return arguments.length ? (maxHeight = +_, my) : maxHeight;
};

my.epsilon = function(_) {
return arguments.length ? (epsilon = +_, my) : epsilon;
};
Expand Down