Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
An occlusion-free label layout on the map or other 2D spaces. Implemented in JavaScript.
An occlusion-free label layout on the map or other 2D spaces. Implemented in JavaScript.
TagMap is a visualization to expose textual topics that are tied to different locations on the map. TagMap has some parallels with tag cloud, e.g., the size/color of tags are weighted by the tag's volume or other properties. However, the layout of tags in TagMap is more constrained by their spatial locations.
This library supports generating tagMaps in either the geographic space or the general 2D space, and also allows transforming from one space to another by specifying a project
function.
See the API section for more details.
npm install tagmap.js
import TagMap from 'tagmap.js';
// data format, position can either be [lon, lat] or [x, y].
const data = [
{label: '#nyc', position: [0, 0], weight: 1},
....
];
const tagMap = new TagMap();
// group points of the same label and build data hierarchy
// this function is called only one time if the data do not change.
tagMap.buildHierarchy(data);
// extract tag clusters at a certain *scale*
const weightThreshold = 1;
const maxDist = 20;
tagMap.extractCluster({weightThreshold, maxDist});
// a sample size measure that returns the size of a label
const sizeMeasurer = (label, fontSize) => ({
width: fontSize * 0.6 * label.length,
height: fontSize
});
const maxFontSize = 30;
const minFontSize = 10;
// the actual overlap removal algorithm
const tags = tagMap.layout({maxFontSize, minFontSize, sizeMeasurer});
The returned tags
contains a list of tag
. Each tag
contains the following attributes:
label
: label text.center
: the center coordinate of the label's bounding box.width
: the width of the label's bounding box.height
: the height of the label's bounding box.This project is licensed under the MIT License.
FAQs
An occlusion-free label layout on the map or other 2D spaces. Implemented in JavaScript.
The npm package tagmap.js receives a total of 137 weekly downloads. As such, tagmap.js popularity was classified as not popular.
We found that tagmap.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.