{"id":28437344,"url":"https://github.com/komed3/linscale","last_synced_at":"2025-06-28T01:31:36.758Z","repository":{"id":270233401,"uuid":"909713183","full_name":"komed3/linscale","owner":"komed3","description":"lightweight npm package to create linear scales","archived":true,"fork":false,"pushed_at":"2025-06-22T12:27:45.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T12:31:16.937Z","etag":null,"topics":["linear-scale","range","scale"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/linscale","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/komed3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-29T15:07:07.000Z","updated_at":"2025-06-22T12:28:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"e354ec8d-4aeb-49a5-8644-ee1bfefa490b","html_url":"https://github.com/komed3/linscale","commit_stats":null,"previous_names":["komed3/linscale"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/komed3/linscale","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Flinscale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Flinscale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Flinscale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Flinscale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/komed3","download_url":"https://codeload.github.com/komed3/linscale/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/komed3%2Flinscale/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262361150,"owners_count":23299042,"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","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":["linear-scale","range","scale"],"created_at":"2025-06-05T23:41:11.537Z","updated_at":"2025-06-28T01:31:36.752Z","avatar_url":"https://github.com/komed3.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LinScale\n\nThis lightweight npm package can be used to calculate a simple linear scale between two given values (minimum and maximum) and the maximal amount of ticks.\n\n\u003e [!WARNING]\n\u003e This package is no longer actively developed, maintained or supported.  \n\u003e Please use the **[scalax](https://npmjs.com/package/scalax)** package instead.\n\n## Install\n\nUsing Node.js, install the package with the following shell command:\n\n```sh\nnpm install linscale\n```\n\n## Usage\n\nLoad the package into your project:\n\n```js\nconst LinScale = require( 'linscale' );\n```\n\nSample of how to use the package in your code:\n\n```js\nlet scale = new LinScale( -1.341, 6.5, 6 );\n\nif ( scale.calculate() ) {\n\n    let min = scale.getMinimum();\n    // expected: -2\n\n    let max = scale.getMaximum();\n    // expected: 7\n\n    let ticks = scale.getTicks();\n    // expected: [ -2, 0, 2, 4, 6, 8 ]\n\n    let pct = scale.pct( 1.5 );\n    // expected: 35\n\n    let crossesZero = scale.crossesZero();\n    // expected: true\n\n}\n```\n\n### JavaScript\n\nUsing JavaScript load this package by embed this file via jsDelivr:\n\n```js\nimport LinScale from 'https://cdn.jsdelivr.net/npm/linscale@1.0.3/+esm';\n```\n\nRemember: To use import you need to load your JavaScript file as ``type=\"module\"``.\n\n## API\n\nHere you can find all methods available in the ``LinScale`` class.\n\nCreating a new instance of ``LinScale`` allows to pass the bounds and maximum number of ticks. This replaces methods ``setBounds`` and ``setMaxTicks``. You still need to run ``calculate()``.\n\n### ``setBounds( min, max )``\n\nSet lower / upper bounds for the scale. Requires to run ``calculate()`` afterwards.\n\n### ``setMaxTicks( ticks )``\n\nSet maximum number of ticks within the scale. Requires to run ``calculate()`` afterwards.\n\n### ``centerAt ( [ value = 0 ] )``\n\nCenter scale at the given value (default is zero). Requires to run ``calculate()`` afterwards.\n\n### ``calculate()``\n\nCalculates the scale range, minimum, maximum and step size.\n\n### ``isNegative()``\n\nChecks if the entire scale is negative. Returns ``true`` if the scale is negative.\n\n### ``crossesZero()``\n\nChecks if the scale crosses zero. Returns ``true`` if the scale crosses zero.\n\n### ``getStepSize()``\n\nReturns the scale step size.\n\n### ``getRange()``\n\nReturns the scale range (from min to max).\n\n### ``getMinimum()``\n\nReturns the scale minium value.\n\n### ``getMaximum()``\n\nReturns the scale maximum value.\n\n### ``getTicks()``\n\nReturns an array of the scale ticks (ascending order).\n\n### ``getTicksReverse()``\n\nReturns an array of the scale ticks (descending order).\n\n### ``pct( value [, from = 'min' ] )``\n\nReturns the percentage of a value within the scale from the reference point (either minimum or maximum value).\n\n## Patch notes\n\n### 1.0.4\n\n* Successor **[scalax](https://npmjs.com/package/scalax)** takes over this package\n\n### 1.0.3\n\n* Documentation update\n* Minor fixes\n\n### 1.0.2\n\n* Add ``isNegative`` method\n* Add ``crossesZero`` method\n* Fixed lower / upper bound couldn’t be zero\n\n### 1.0.1\n\n* Add ``centerAt`` method\n\n### 1.0.0\n\n* Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomed3%2Flinscale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkomed3%2Flinscale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkomed3%2Flinscale/lists"}