UNPKG

plotly.js

Version:

The open source javascript graphing library that powers plotly

61 lines (60 loc) • 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LABELOPTIMIZER = exports.LABELMAX = exports.LABELMIN = exports.LABELINCREASE = exports.LABELDISTANCE = exports.SADDLEREMAINDER = exports.CHOOSESADDLE = exports.NEWDELTA = exports.RIGHTSTART = exports.LEFTSTART = exports.TOPSTART = exports.BOTTOMSTART = void 0; // Some constants to help with marching squares algorithm // where does the path start for each index? exports.BOTTOMSTART = [1, 9, 13, 104, 713]; exports.TOPSTART = [4, 6, 7, 104, 713]; exports.LEFTSTART = [8, 12, 14, 208, 1114]; exports.RIGHTSTART = [2, 3, 11, 208, 1114]; // Which way [dx,dy] do we leave a given index? // saddles are already disambiguated exports.NEWDELTA = [ null, [-1, 0], [0, -1], [-1, 0], [1, 0], null, [0, -1], [-1, 0], [0, 1], [0, 1], null, [0, 1], [1, 0], [1, 0], [0, -1] ]; // For each saddle, the first index here is used // for dx||dy<0, the second for dx||dy>0 exports.CHOOSESADDLE = { 104: [4, 1], 208: [2, 8], 713: [7, 13], 1114: [11, 14] }; // After one index has been used for a saddle, which do we // substitute to be used up later? exports.SADDLEREMAINDER = { 1: 4, 2: 8, 4: 1, 7: 13, 8: 2, 11: 14, 13: 7, 14: 11 }; // Length of a contour, as a multiple of the plot area diagonal, per label exports.LABELDISTANCE = 2; // Number of contour levels after which we start increasing the number of // labels we draw. Many contours means they will generally be close // together, so it will be harder to follow a long way to find a label exports.LABELINCREASE = 10; // Minimum length of a contour line, as a multiple of the label length, // at which we draw *any* labels exports.LABELMIN = 3; // Max number of labels to draw on a single contour path, no matter how long exports.LABELMAX = 10; // Constants for the label position cost function exports.LABELOPTIMIZER = { // Weight given to edge proximity EDGECOST: 1, // Weight given to the angle off horizontal ANGLECOST: 1, // Weight given to distance from already-placed labels NEIGHBORCOST: 5, // Cost multiplier for labels on the same level SAMELEVELFACTOR: 10, // Minimum distance (as a multiple of the label length) // for labels on the same level SAMELEVELDISTANCE: 5, // Maximum cost before we won't even place the label MAXCOST: 100, // Number of evenly spaced points to look at in the first // iteration of the search INITIALSEARCHPOINTS: 10, // Number of binary search iterations after the initial wide search ITERATIONS: 5 };