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

dc.leaflet

v0.5.6

Published

Leaflet maps integrated with crossfilter and dc.js

Downloads

29

Readme

dc.leaflet.js

This library provides support for DC.js charts in a Leaflet.js map. It is a fork of Boyan Yurukov's dc.js extension, upgraded to a full library with AMD support and updated for dc.js 2.0+.

Demo

Examples of each of the charts can be found here: http://dc-js.github.io/dc.leaflet.js/

Requirements

(These will be installed by npm install)

The charts should work with older versions with minor changes.

Usage

There are two charts currently implemented - markers and choropleth. They extend the base abstract leaflet chart. Both support selection of datapoints and update in real time. Styling and map options can be set directly to the map object and though functions in the chart. Check the Leaflet reference for more information on the specific map, marker and geojson options. Location can be set as either 'lat,lng' string or as an array [lat,lng].

Leaflet base

Properties included in all dc_leaflet charts. Derives from dc.baseMixin and dc.marginMixin. This is a base class/mixin and can't be instantiated directly.

dc_leaflet.leafletBase = function(chart)
  .mapOptions({..})       - set leaflet specific options to the map object; Default: Leaflet default options
  .center([1.1,1.1])      - get or set initial location
  .zoom(7)                - get or set initial zoom level
  .map()                  - set or get map object
  .brushOn(true)          - if the map should select datapoints; Default: true
  .popupMod('alt')        - only display popup when 'alt' modifier key (or 'shift' or 'ctrlCmd') is pressed;
                            Default: null, no modifier key
  .filterMod('ctrlMod')   - only filter when control key (command key on Mac) is pressed
                            Default: null, no modifier key

Marker chart

Each group is presented as one marker on the map. Includes all properties from leafletBase, and:

dc_leaflet.markerChart(parent, chartGroup)
  .locationAccessor()     - function (d) to access the property indicating the latlng (string or array); Default: use keyAccessor
  .marker()               - set function(d, map) to build the marker object. Default: standard Leaflet marker is built
  .icon()                 - function(d, map) to build an icon object. Default: L.Icon.Default
  .popup()                - function(d, marker) to return the string or DOM content of a popup
  .renderPopup(true)      - get or set if popups should be shown; Default: true
  .cluster(false)         - get or set if markers should be clustered. Requires leaflet.markercluster.js; Default: false
  .clusterOptions({..})   - options for the markerCluster object
  .rebuildMarkers(false)  - set if all markers should be rebuild each time the map is redrawn. Degrades performance; Default: false
  .filterByArea(false)    - if the map should filter data based on the markers inside the zoomed in area instead of the user clicking on individual markers; Default: false
  .markerGroup()          - get the Leaflet group object containing all shown markers (regular group or cluster)
  .featureGroup()         - get or set featureGroup that will be used for fit on render or redraw
  .clickEvent()           - get or set the event to fire when a marker is clicked
  .fitOnRender()          - get or set a bool to determine whether to fit to bounds when markers are rendered
  .fitOnRedraw()          - get or set a bool to determine whether to fit to bounds on crossfilter redraw
  .showMarkerTitle()      - get or set a bool to determine whether title and alt should be shown for markers

Choropleth chart

Each group is mapped to an feature on the map. Includes all properties from leafletBase, and:

dc_leaflet.choroplethChart(parent, chartGroup)
  .geojson()              - get or set geojson object describing the features
  .featureOptions()       - object or a function(feature) to set the options for each feature
  .featureKeyAccessor()   - function(feature) to return a feature property that would be compared to the group key; Default: feature.properties.key
  .featureStyle()         - get or set the function(feature) to return style options for L.geoJson. Probably not helpful to override this, but it's possible. Default: use featureOptions, data, color, selection status to define the style; see source for details.
  .popup()                - function(d, feature) to return the string or DOM content of a popup
  .renderPopup(true)      - get or set if popups should be shown; Default: true

Bubble chart

Each group is mapped to a circle on the map. Includes all properties from leafletBase, and:

dc_leaflet.bubbleChart(parent, chartGroup)
  .r()                    - radius scale, used to convert value returned by valueAccessor(d) to pixels. Default: d3.scale.linear().domain([0, 100])
  .locationAccessor()     - function(d) to access the property indicating the latlng (string or array); Default: use keyAccessor
  .selectedColor()        - get or set the (constant) selected bubble color
  .unselectedColor()      - get or set the unselected bubble color, which by default passes the datum to dc.ColorMixin's getColor function to dynamically color bubbles (defaults to gray unless .colors(), .colorDomain() and .colorAccessor() are defined)
  .popup()                - function(d, marker) to return the string or DOM content of a popup
  .renderPopup()          - get or set if popups should be shown on mouseover; Default: true
  .layerGroup()           - get the layerGroup for the bubbles
  .marker()               - get or set function(d, map) to build the marker object. Probably not helpful to override this, but its's possible. Default: create L.circleMarker based on the other parameters; see source for details.