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

d3-graphic

v1.0.2

Published

D3 graphic to React Native

Downloads

3

Readme

d3-graphic

d3-graphic is a React Native package that utilizes D3, react-native-svg, react, and lodash to display horizontal bars, vertical bars, and pie charts. This package is designed to make dashboard development in React Native much easier.

Installation

To install this package, you can use npm or yarn:

npm

npm install d3-graphic

yarn

yarn add d3-graphic

Components

The d3-graphic package includes the following components:

  • MultipleHorizontalBars
  • MultipleVerticalBars
  • PieChart

Common Props

The three mentioned components share the same props:

  • data: An array of JSON objects containing at least three properties: one for the label, one for the value, and one for the id.
  • keyLabel: The JSON property that the component uses for the label.
  • keyValue: The JSON property that the component uses for the value.
  • primaryKey: The JSON property that acts as the ID.

Optional props:

  • loading: Boolean that controls whether a spinner is shown while true.
  • error: Boolean that shows an error message.
  • withoutDataMessage: String to customize the message displayed when there is no data.
  • color: An array of strings with the colors of the bars or sections of the chart.

Usage Example

Below is an example of how to use the MultipleHorizontalBars component:

import React from "react";
import { MultipleHorizontalBars } from "d3-graphic";

const data = [
  { nameProduct: "Apples", value: 100, id: 1 },
  { nameProduct: "Banana", value: 150, id: 2 },
  { nameProduct: "Cactus", value: 45, id: 3 },
  { nameProduct: "Dades", value: 169.48, id: 4 },
  { nameProduct: "Guitar", value: 188.4, id: 5 },
  { nameProduct: "Fruit", value: 90, id: 6 },
  { nameProduct: "Games", value: 25, id: 7 },
];

<MultipleHorizontalBars
  data={data}
  keyLabel={"nameProduct"}
  keyValue={"value"}
  primaryKey={"id"}
  error={false}
  loading={false}
/>;

Example Project

You can find a project using d3-graphic on the following GitHub link. This project provides practical examples of how to use the components included in the package.

Example Project on GitHub

Animations

  • Horizontal Bars

Horizontal Bars

  • Vertical Bars

Vertical Bars

  • Pie Chart

Pie chart

Screenshots

  • Horizontal Bars

    Horizontal Bars

    • Vertical Bars

    Vertical Bars

    • Pie Chart

    Pie chart