{"id":16125708,"url":"https://github.com/dy/point-cluster","last_synced_at":"2025-07-26T20:14:30.436Z","repository":{"id":57326693,"uuid":"124160004","full_name":"dy/point-cluster","owner":"dy","description":"2d point clustering for datavis purposes.","archived":false,"fork":false,"pushed_at":"2020-08-12T19:07:45.000Z","size":129,"stargazers_count":13,"open_issues_count":8,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-23T22:53:29.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-07T01:19:28.000Z","updated_at":"2025-04-06T21:12:32.000Z","dependencies_parsed_at":"2022-09-11T09:40:45.602Z","dependency_job_id":null,"html_url":"https://github.com/dy/point-cluster","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dy/point-cluster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpoint-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpoint-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpoint-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpoint-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/point-cluster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpoint-cluster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267226529,"owners_count":24056346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T21:30:50.525Z","updated_at":"2025-07-26T20:14:30.360Z","avatar_url":"https://github.com/dy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# point-cluster [![Build Status](https://travis-ci.org/dy/point-cluster.svg?branch=master)](https://travis-ci.org/dy/point-cluster) [![experimental](https://img.shields.io/badge/stability-experimental-yellow.svg)](http://github.com/badges/stability-badges)\n\nPoint clustering for 2D spatial indexing. Incorporates optimized quad-tree data structure.\n\n\u003c!--\n* [ ] quad-tree, kd-tree, ann-tree and other tree types.\n* [x] splatting by zoom layers.\n* [x] point selection/hover by range.\n* [ ] point radius and weight.\n* [ ] reverse z-index order mode to keep visible points in reclustering.\n* [ ] appending/removing points.\n* [x] no visually noticeable clustering artifacts.\n* [x] high performance (faster than [snap-points-2d](https://github.com/gl-vis/snap-points-2d)).\n* [x] no memory overuse.\n\n[DEMO](https://github.com/dy/point-cluster)\n--\u003e\n\n\n```js\nconst cluster = require('point-cluster')\n\nlet ids = cluster(points)\n\n// get point ids in the indicated range\nlet selectedIds = ids.range([10, 10, 20, 20])\n\n// get levels of details: list of ids subranges for rendering purposes\nlet lod = ids.range([10, 10, 20, 20], { lod: true })\n```\n\n## API\n\n### `ids = cluster(points, options?)`\n\nCreate index for the set of 2d `points` based on `options`.\n\n* `points` is an array of `[x,y, x,y, ...]` or `[[x,y], [x,y], ...]` coordinates.\n* `ids` is _Uint32Array_ with point ids sorted by zoom levels, suitable for WebGL buffer, subranging or alike.\n* `options`\n\nOption | Default | Description\n---|---|---\n`bounds` | `'auto'` | Data range, if different from `points` bounds, eg. in case of subdata.\n`depth` | `256` | Max number of levels. Points below the indicated level are grouped into single level.\n`output` | `'array'` | Output data array or data format. For available formats see [dtype](https://npmjs.org/package/dtype).\n\u003c!-- `node` | `1` | Min size of node, ie. tree traversal is stopped once the node contains less than the indicated number of points. --\u003e\n\u003c!-- `sort` | `'z'` | Sort values within levels by `x`-, `y`-coordinate, `z`-curve or `r` - point radius. `z` is the fastest for init, `x` or `y` are faster for `lod` and `r` is the most data-relevant. --\u003e\n\u003c!-- `pick` | `'first'` | `'first'`, `'last'` or a function, returning point id for the level. --\u003e\n\n---\n\n\n### `result = ids.range(box?, options?)`\n\nGet point ids from the indicated range.\n\n* `box` can be any rectangle object, eg. `[l, t, r, b]`, see [parse-rect](https://github.com/dy/parse-rect).\n* `options`\n\nOption | Default | Description\n---|---|---\n`lod` | `false` | Makes result a list of level details instead of ids, useful for obtaining subranges to render.\n`px` | `0` | Min pixel size in data dimension (number or `[width, height]` couple) to search for, to ignore lower levels.\n`level` | `null` | Max level to limit search.\n\n```js\nlet levels = ids.range([0,0, 100, 100], { lod: true, d: dataRange / canvas.width })\n\nlevels.forEach([from, to] =\u003e {\n\t// offset and count point to range in `ids` array\n\trender( ids.subarray( from, to ) )\n})\n```\n\n\n### Related\n\n* [snap-points-2d](https://github.com/gl-vis/snap-points-2d) − grouping points by pixels.\n* [kdgrass](https://github.com/dy/kdgrass) − minimal kd-tree implementation.\n* [regl-scatter2d](https://github.com/dfreative/regl-scatter2d) − highly performant scatter2d plot.\n\n\n## License\n\n© 2017 Dmitry Yv. MIT License\n\nDevelopment supported by [plot.ly](https://github.com/plotly/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fpoint-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fpoint-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fpoint-cluster/lists"}