0.1.3 • Published 7 months ago

@simuratli/charts v0.1.3

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

@simuratli/charts

A simple, customizable chart library for React.js. This package provides reusable chart components, like LineChart, to quickly integrate data visualizations into your React applications.

Installation

Install the package via npm:

npm install @simuratli/charts

Usage

Line Chart

After installing, you can import and use the LineChart component in your project as shown below.

Example

import { LineChart } from '@simuratli/charts';

const App = () => {
  return (
    <div>
      <LineChart 
        data={[
          { xValue: 2, yValue: 10 },
          { xValue: 3, yValue: 15 },
          { xValue: 7, yValue: 17 },
          { xValue: 3, yValue: 25 },
        ]}
        width={560}
        height={560}
        lineColor='orange'
        xAxisLabel='X axis'
        yAxisLabel='Y axis'
      />
    </div>
  );
};

export default App;

Props

PropTypeDefaultDescription
dataArray-Required. Array of objects with xValue and yValue keys.
widthnumber560Optional. The width of the chart.
heightnumber400Optional. The height of the chart.
xAxisLabelstring-Optional. Label for the x-axis.
yAxisLabelstring-Optional. Label for the y-axis.
lineColorstringorangeOptional. Color of the line in the chart.

Data Format

The data prop should be an array of objects, each containing:

  • xValue: The x-coordinate (number)
  • yValue: The y-coordinate (number)

Example:

data={[
  { xValue: 2, yValue: 10 },
  { xValue: 3, yValue: 15 },
  { xValue: 7, yValue: 17 },
  { xValue: 3, yValue: 25 },
]}

Customization

  • Dimensions: Adjust width and height to control the chart's size.
  • Axis Labels: Use xAxisLabel and yAxisLabel to add labels to your axes.
  • Line Color: Change the line color with lineColor.

BarChart

The BarChart component allows you to create a bar chart with customizable dimensions and colors.

Example

import React from 'react';
import { BarChart } from '@simuratli/charts';

const App = () => {
  return (
      <div>
        <BarChart 
            data={[
            { name: 'A', value: 30 },
            { name: 'B', value: 80 },
            { name: 'C', value: 45 },
            { name: 'D', value: 60 },
            ]}
            width={460}
            height={500}
            color='#69b3a2'
        />
    </div>
  );
};

export default App;

Props

PropTypeDefaultDescription
dataArray-Required. Array of objects with name and value keys.
widthnumber460Optional. The width of the chart.
heightnumber500Optional. The height of the chart.
colorstring#69b3a2Optional. Color of the bars in the chart.

Data Format

The data prop should be an array of objects, each containing:

  • name: The name of the category (string)
  • value: The value for the category (number)

Example:

data={[
  { name: 'A', value: 30 },
  { name: 'B', value: 80 },
  { name: 'C', value: 45 },
  { name: 'D', value: 60 },
]}

Customization

  • Dimensions: Adjust width and height to control the chart's size.
  • Bar Color: Change the bar color with color.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open issues or pull requests for any features, bug fixes, or suggestions.

Questions?

For any questions or issues, feel free to reach out.


Happy charting with @simuratli/charts!

0.1.3

7 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago