1.0.6 • Published 9 months ago

react-chart-dev v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

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

PropTypeDefaultDescription
dataArray[]Data to display in the bar chart.
widthNumber300Width of the chart in pixels.
heightNumber200Height of the chart in pixels.
colorString#3498dbColor of the bars.
paddingObject{ top: 10, right: 10, bottom: 10, left: 10 }Padding around the chart.
showAxesBooleantrueWhether to display axes on the chart.

LineChart

PropTypeDefaultDescription
dataArray[]Data to display in the line chart.
widthNumber350Width of the chart in pixels.
heightNumber200Height of the chart in pixels.
strokeWidthNumber2Thickness of the line.
colorString#2ecc71Color of the line.

PieChart

PropTypeDefaultDescription
dataArray[]Data to display in the pie chart.
widthNumber300Width of the chart in pixels.
heightNumber300Height of the chart in pixels.
colorsArray[]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.

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago