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

simple_react_bar_chart

v1.1.3

Published

Simple Bar Chart.

Downloads

14

Readme

simple_react_bar_chart #The module is still in test process react-simple-bar-chart is a simple React component for visualizing and selecting ranges on a calendar.(max 3 for each row) It's designed to be flexible and easy to integrate into your React applications.

🚀 Features

Dynamic rows: Allows users to see multiple data in one row but not more than 3. Customizable: Easily customize the appearance of the chart.

⚠️ Under Testing

This library is currently under testing and development. You can use it but maybe still there is some issues. While we are working hard to make it stable and reliable, please be aware that some features may be experimental or subject to change. We appreciate your feedback and contributions to my github.

OBS! The app works on matching keys on data and xAxis.(if xAxis and data has same key then data values show up in chart)

📦 Installation

To install simple_react_bar_chart, use npm or yarn:

bash Copy code npm install simple_react_bar_chart or

bash Copy code yarn add react-simple-bar-chart

Simple example

Example of use

import ChartComponent from "simple_react_bar_chart";
import { useState } from "react";
interface Data {
  key: number;
  beginNumber: number;
  endNumber: number;
  color: string;
  type: string;
}
const data: { [key: number]: Data[] } = {
  1: [
    {
      type: "Apple",
      beginNumber: 1,
      endNumber: 9,
      color: "orange",
      key: 2,
    },
    {
      type: "Samsung",
      beginNumber: 3,
      endNumber: 6,
      color: "green",
      key: 2,
    },
    {
      type: "Other",
      beginNumber: 2,
      endNumber: 8,
      color: "red",
      key: 2,
    },
  ],
  2: [
    {
      type: "Apple",
      beginNumber: 4,
      endNumber: 8,
      color: "orange",
      key: 1,
    },
    {
      type: "Samsung",
      beginNumber: 3,
      endNumber: 6,
      color: "green",
      key: 2,
    },
  ],
};
const xAxis = [
  {
    type: "Jan",

    color: "#fff",
    key: 1,
  },
  {
    type: "Feb",

    color: "#fff",
    key: 2,
  },
  {
    type: "March",

    color: "#fff",
    key: 3,
  },
  {
    type: "Apr",

    color: "#fff",
    key: 4,
  },
  {
    type: "May",

    color: "#fff",
    key: 5,
  },
  {
    type: "Jun",

    color: "#fff",
    key: 6,
  },
  {
    type: "Jul",

    color: "#fff",
    key: 7,
  },
  {
    type: "Aug",

    color: "#fff",
    key: 8,
  },
  {
    type: "Sep",

    color: "#fff",
    key: 9,
  },
  {
    type: "Oct",

    color: "#fff",
    key: 10,
  },
  {
    type: "Nov",

    color: "#fff",
    key: 11,
  },
  {
    type: "Dec",

    color: "#fff",
    key: 12,
  },
];

export interface DayData {
  key: number;
  beginNumber: number; // Hour in the day (e.g., 9 for 9:00 AM)
  endNumber: number; // Hour in the day (e.g., 17 for 5:00 PM)
  color: string; // Color to represent the event
}
interface RowsData {
  key: number;
  color: "";
  type: "";
}
const yAxisLength = 14;
const App = () => {
  const [page, setPage] = useState(1);
  return (
    <div
      style={{
        height: "500px",
        maxWidth: "700px",
        margin: "auto",
        marginTop: "10%",
      }}>
      <ChartComponent
        onNavigateNext={() => setPage((cur) => cur + 1)}
        onNavigatePrevious={() => setPage((cur) => (page > 1 ? cur - 1 : 1))}
        currentPage={page}
        xAxis={xAxis as RowsData[]}
        yAxisExtension=". 000"
        yAxisLength={yAxisLength}
        containerStyle={{ color: "white" }}
        data={(data as any)[page] as DayData[]}
        GuidComponent={<GuidComponent page={page} />}
      />
    </div>
  );
};

// // To filter duplicates by `type` (or any key)
const uniqueData = Object.values(data)
  .flatMap((r) => r)
  .filter(
    (obj, index, self) => index === self.findIndex((t) => t.type === obj.type)
  );

// Render the filtered data

const GuidComponent = ({ page }: { page: number }) => {
  return (
    <div
      className="guid-colors-parent"
      style={{ color: "white" }}>
      <>
        {uniqueData.map((r, index) => (
          <span key={index}>
            <span
              className="guid-colors-shape"
              style={{ backgroundColor: r.color }}></span>
            <span>{r.type}</span>
          </span>
        ))}
      </>
    </div>
  );
};
export default App;