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

react-chart-dev

v1.0.6

Published

A powerful and flexible charting library for React Native applications using D3.js.

Downloads

350

Readme

Here’s the updated README.md file for your chart library, react-chart-dev:


React Chart Dev

A powerful and flexible charting library built with D3.js and react-native-svg, designed specifically for React Native applications. Easily create stunning, interactive charts with minimal configuration.

Table of Contents

Features

  • Multiple Chart Types: Includes Bar, Line, and Pie charts, with the flexibility to add more.
  • Fully Customizable: Control the appearance and behavior of your charts.
  • Responsive Design: Automatically adjusts to fit the screen size.
  • Easy Integration: Simple to include in any React Native project.

Installation

To install this library, run the following command in your React Native project:

pnpm add react-chart-dev react-native-svg d3

Make sure react-native-svg is linked properly. For React Native versions 0.60 and above, it will link automatically.

Usage

Here’s how to use the charts in your application:

Bar Chart Example

import React from "react";
import { View } from "react-native";
import { BarChart } from "react-chart-dev";

const data = [
  { label: "Jan", value: 30 },
  { label: "Feb", value: 50 },
  { label: "Mar", value: 20 },
  { label: "Apr", value: 80 },
];

const MyBarChart = () => (
  <View style={{ flex: 1 }}>
    <BarChart data={data} width={300} height={200} />
  </View>
);

export default MyBarChart;

Line Chart Example

import React from "react";
import { View } from "react-native";
import { LineChart } from "react-chart-dev";

const data = [
  { label: "Week 1", value: 20 },
  { label: "Week 2", value: 50 },
  { label: "Week 3", value: 75 },
  { label: "Week 4", value: 100 },
];

const MyLineChart = () => (
  <View style={{ flex: 1 }}>
    <LineChart data={data} width={350} height={200} />
  </View>
);

export default MyLineChart;

Pie Chart Example

import React from "react";
import { View } from "react-native";
import { PieChart } from "react-chart-dev";

const data = [
  { label: "Apples", value: 40 },
  { label: "Bananas", value: 25 },
  { label: "Cherries", value: 35 },
];

const MyPieChart = () => (
  <View style={{ flex: 1 }}>
    <PieChart data={data} width={300} height={300} />
  </View>
);

export default MyPieChart;

API Reference

BarChart

| Prop | Type | Default | Description | | ---------- | --------- | ---------------------------------------------- | ------------------------------------- | | data | Array | [] | Data to display in the bar chart. | | width | Number | 300 | Width of the chart in pixels. | | height | Number | 200 | Height of the chart in pixels. | | color | String | #3498db | Color of the bars. | | padding | Object | { top: 10, right: 10, bottom: 10, left: 10 } | Padding around the chart. | | showAxes | Boolean | true | Whether to display axes on the chart. |

LineChart

| Prop | Type | Default | Description | | ------------- | -------- | --------- | ---------------------------------- | | data | Array | [] | Data to display in the line chart. | | width | Number | 350 | Width of the chart in pixels. | | height | Number | 200 | Height of the chart in pixels. | | strokeWidth | Number | 2 | Thickness of the line. | | color | String | #2ecc71 | Color of the line. |

PieChart

| Prop | Type | Default | Description | | -------- | -------- | ------- | ----------------------------------- | | data | Array | [] | Data to display in the pie chart. | | width | Number | 300 | Width of the chart in pixels. | | height | Number | 300 | Height of the chart in pixels. | | colors | Array | [] | Array of colors for each pie slice. |

Customization

Hooks

  • useD3(): A hook providing access to D3 functionalities for the chart.
  • useChartData(): Manages and formats the input data for the chart.
  • useChartSettings(): Manages chart settings such as dimensions and colors.

Utility Functions

  • dataProcessing.js: Utilities for transforming and preparing data for charts.
  • scales.js: Functions to create scales for your charts.
  • axes.js: Functions to create and customize chart axes.

Examples

Explore example projects and demos in the examples/ directory to see how to integrate multiple charts into a dashboard or use them individually.

Running Examples

  1. Clone the repository and navigate to the examples/ directory.

  2. Install dependencies using:

    pnpm install
  3. Run the example app:

    react-native run-android
    # or
    react-native run-ios

Roadmap

  • Add support for additional chart types (e.g., Scatter Plot, Area Chart).
  • Implement animations and transitions for dynamic chart behavior.
  • Introduce user interactions like tooltips and zooming.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature.
  3. Make your changes and commit them: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/your-feature.
  5. Create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Feel free to adjust any sections to better fit your library's specific features and usage patterns. This README.md is structured to be informative and user-friendly, ensuring that users can easily understand how to utilize and contribute to react-chart-dev.