npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chart-axis

v1.0.7

Published

Generate a continuous value range intervaled, and determine the coordinate position according to the specified value

Downloads

4

Readme

chart-axis

Library to generate a continuous range by some interval, and get the coordinate position according to the specified value

Install

npm install geolib

yarn add geolib

Usage

import { getIntervalRange, getCoordByValue } from 'chart-axis'

const { getIntervalRange, getCoordByValue } = require('chart-axis');
<script src="lib/chart_axis.js"></script>

<script>
  const { getIntervalRange, getCoordByValue } = chart_axis;
</script>

Functions

getIntervalRange({ data, intervals = 5, forceInt=false, max=null, steps = [3] })

This function takes up to 3 arguments. First one argument is required.

It returns an incremental array represents the range

const reange1 = getIntervalRange({data:[2343,1234,5434,7435], intervals:5, steps:[3]});
// range1 is [0, 1000, 6300, 6600, 6900, 7200, 7500]

const reange2 = getIntervalRange({data:[2343,1234,5434,7435], intervals:5, steps:[5]})
// range2 is [0, 1000, 5500, 6000, 6500, 7000, 7500]

const reange3 = getIntervalRange({data:[2343,1234,5434,7435], intervals:4, steps:[10]})
// range3 is [0, 1000, 4500, 5500, 6500, 7500]

const reange4 = getIntervalRange({data:[2343,1234,5434,7435], intervals:5, steps:[2,4,6]});
// range4 is [0, 1000, 6700, 6900, 7100, 7300, 7500]

data

Param 'data' must be an value array, most times it is your data list, it is required

intervals

Param 'intervals' determies how many intervals there are in the value range. It's equal to the number of intervals after the range array removes 0;

steps

Param steps is an array type, the inner elements can be valued from 1 to 10. it determines how to decrease in the range returned

max

forceInt

getCoordByValue({ type = "reverse", minCoord, maxCoord, range })

This function return another function that reutrns the coordinate according to a specified value which is within the given range

type

Param type can only be valued at 'reverse' and 'normal',it determines whether the start point for coordinate of specified value is minCoord or maxCoord.

minCoord

If you have a coordinate system in your page, no matter whether it is svg or canvas or just a div, you should specify which interval of the continuous value range should be distributed in the coordinate system.

minCoord is the minimum coordinate in the coordinate interval

maxCoord

maxCoord is the maxmum coordinate in the coordinate interval

range

an array returned by getIntervalRange

const getCoord = getCoordByValue({minCoord:0,maxCoord:300,range:[0, 1000, 6700, 6900, 7100, 7300, 7500]});
getCoord(7500)
// 0
getCoord(0)
//300
getCoord(6900)
//150

const getCoord = getCoordByValue({type:'normal', minCoord:0,maxCoord:300,range:[0, 1000, 6700, 6900, 7100, 7300, 7500]});
getCoord(7500)
// 300
getCoord(0)
//0
getCoord(6900)
//150