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

gridy-chart-d3

v2.1.2

Published

GridyGrid chart component D3 driver

Downloads

4

Readme

GridyGrid chart component D3 driver

Installation

npm i gridy-grid d3 gridy-chart-d3 gridy-grid-default sk-theme-default

and plug it to your page

<script src="/node_modules/d3/dist/d3.js"></script>

or from CDN

<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>

then add element to your container or setup it programmatically

    <gridy-grid id="gridyGrid" base-path="/node_modules/gridy-grid/src" sort-field="$.title">
	    <gridy-data-source fields='[{ "title": "Name", "path": "$.name" },{ "title": "Value", "path": "$.value"},{ "title": "Color", "path": "$.color"}]'
                       datasource-type="DataSourceLocal" datapath="$.data"></cbr-data-source>
    
	<gridy-chart type="pie" dri="d3" field-name="Name" field-color="Color" field-value="Value" width="400" height="400"></cbr-chart>
    
    </gridy-grid>
    <script>
        let data = [];
	    data.push({ name: 'FooBar1', value: 10, color: '#98abc5' });
	    data.push({ name: 'FooBar2', value: 23, color: '#8a89a6' });
	    data.push({ name: 'FooBar3', value: 34, color: '#7b6888' });
	    data.push({ name: 'FooBar4', value: 17, color: '#a05d56' });
        let grid = document.querySelector('#gridyGrid');
        grid.addEventListener('bootstrap', () => {
            grid.charts[0].addEventListener('skrender', (event) => {
                grid.dataSource.loadData(data);
            });
        });
    </script>
    

to map datasource data for chart field-${dataKey} attributes are used with field title from datasource mapping as value

Chart types

Pie

	<gridy-chart type="pie" dri="d3" field-color="Color" field-value="Value" width="400" height="400"></cbr-chart>

config attrs: stroke, stroke-width, radius, inner-radius

Bar

	<gridy-chart type="bar" dri="d3" field-color="Color" field-name="Name" field-value="Value" width="400" height="400"></cbr-chart>

config attrs: color (fill)

Histogram

	<gridy-chart type="hist" dri="d3" field-color="Color" field-name="Name" field-value="Value" width="400" height="400"></cbr-chart>

config attrs: color (fill)

Line

	<gridy-chart stroke-width="5" color="#f0f0f0" fill="#f0f0f0" type="line" dri="d3" field-x="x" field-y="y" width="400" height="400"></cbr-chart>

config attrs: color (stroke), stroke-width, fill

Groupline

groupline chart allows multiple lines for data grouped by value of specified field

	<gridy-chart stroke-width="5" color="#f0f0f0" fill="#f0f0f0" type="groupline" dri="d3" field-x="x" field-y="y" field-group="Name" width="400" height="400"></cbr-chart>

config attrs: color (stroke), stroke-width

Configuration

attributes

share-chart-dri - share chart driver instance from cache than instancinate, ok when all types of chart on page have the same type

share-chart-impl - prefer get chart impl from cache than instancinate, ok when all types of chart on page have the same type