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

perspective-map

v1.2.0

Published

Perspective map

Downloads

49

Readme

Table of Contents

Installation

You can also load directly from UNPKG as a standalone library.

<script src="https://unpkg.com/@finos/[email protected]/dist/umd/perspective.js"></script>
<script src="https://unpkg.com/@finos/[email protected]/dist/umd/perspective-viewer.js"></script>
<script src="https://unpkg.com/@finos/[email protected]/dist/umd/perspective-viewer-datagrid.js"></script>
<script src="https://unpkg.com/@finos/[email protected]/dist/umd/perspective-viewer-d3fc.js"></script>
<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

As a module with NPM or YARN

# npm
npm i perspective-leaflet --save-dev

# yarn
yarn add perspective-leaflet

And then import it:

import perspective from "@finos/perspective";
import "@finos/perspective-viewer";
import "@finos/perspective-viewer-datagrid";
import "@finos/perspective-viewer-d3fc";
import "@finos/perspective-viewer/themes/all-themes.css";
import "perspective-map";

Requirements

The plugin has been tested with the latest versions of Perspective (>= 0.8.0) which was released on 28.04.2021.

You will also need to include the Leaflet CSS

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />

Or

import "leaflet/dist/leaflet.css";

How to use

The plugin expects to receive the data as CSV, and it should have a column called geometry, which will have the geospatial data in GeoJSON or TopoJSON format (string-like).

An example:

population,city,geometry
785123,"Zaragoza","{""type"":""Point"",""coordinates"":[-0.8850860595703125,41.64828831259533]}"
125123,"Teruel","{""type"":""Point"",""coordinates"":[-1.1061859130859375,40.345497469392406]}"
785123,"Huesca","{""type"":""Point"",""coordinates"":[-0.41473388671875,42.14202329789122]}"

config-map

You can choose the metric and zoom value of the map with the `map-config. This attribute is optional.

Create an object

const configMap = {
  metric: "population",
  zoom: true
}

metric: string This is the column of data used to color the map and display it in the legend. If not defined, the map uses the first value of the data. zoom: boolean, enable/disable the zoom of the map.

Stringify the object to add it as an attribute to the perspective-viewer.

const element = document.getElementsByTagName("perspective-viewer")[0];
element.setAttribute("config-map", JSON.stringify(configMap))

CSS

You can override the color scale using custom properties. To create color scales for maps, we recommend using ColorBrewer

In your CSS, you should override the custom properties that we have created.

:root {
  --perspective-map-range-1: #fef0d9;
  --perspective-map-range-2: #fdcc8a;
  --perspective-map-range-3: #fc8d59;
  --perspective-map-range-4: #e34a33;
  --perspective-map-range-5: #b30000;
  --perspective-map-category-1: #feebe2;
  --perspective-map-category-2: #fbb4b9;
  --perspective-map-category-3: #f768a1;
  --perspective-map-category-4: #c51b8a;
  --perspective-map-category-5: #7a0177;
}

Examples

Development

  • Clone the repo
  • Install dependencies
  • Start coding!
  • Send a PR