Socket
Socket
Sign inDemoInstall

react-sparklines-typescript-v2

Package Overview
Dependencies
5
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-sparklines-typescript-v2

react-sparklines rewritten in typescript and modern react patterns


Version published
Maintainers
1
Install size
23.2 kB
Created

Readme

Source

:heavy_exclamation_mark: Original Repo: https://github.com/borisyankov/react-sparklines - The original react-sparklines has not been updated for 3 years. This is a rewrite of the original library into Typescript and modern react classless components. The package is smaller and faster.

Beautiful and expressive sparklines component for React

Live demos and docs: borisyankov.github.io/react-sparklines/

Install

npm install react-sparklines-typescript-v2 --save

Use

Import the Sparklines components that you need; for example to generate a simple chart:

import { Sparklines } from 'react-sparklines-typescript-v2';
...
<Sparklines data={[5, 10, 5, 20, 8, 15]} limit={5} width={100} height={20} margin={5}>
</Sparklines>

Sparklines component is a container with the following properties:

data - the data set used to build the sparkline

limit - optional, how many data points to display at once

width, height - dimensions of the generated sparkline in the SVG viewbox. This will be automatically scaled (i.e. responsive) inside the parent container by default.

svgWidth, svgHeight - If you want absolute dimensions instead of a responsive component set these attributes.

preserveAspectRatio - default: 'none', set this to modify how the sparkline should scale

margin - optional, offset the chart

min, max - optional, bound the chart

Basic Sparkline

import { Sparklines, SparklinesLine } from 'react-sparklines-typescript-v2';
...
<Sparklines data={[5, 10, 5, 20]}>
  <SparklinesLine color="blue" />
</Sparklines>
Bars

import { Sparklines, SparklinesBars } from 'react-sparklines-typescript-v2';
...
<Sparklines data={[5, 10, 5, 20]}>
  <SparklinesBars />
</Sparklines>
Spots

import { Sparklines, SparklinesLine, SparklinesSpots } from 'react-sparklines-typescript-v2';
...
<Sparklines data={sampleData}>
    <SparklinesLine style={{ fill: "none" }} />
    <SparklinesSpots />
</Sparklines>
Reference Line

import { Sparklines, SparklinesLine, SparklinesReferenceLine, SparklinesReferenceLineTypes } from 'react-sparklines-typescript-v2';
...
<Sparklines data={sampleData}>
    <SparklinesLine />
    <SparklinesReferenceLine type={SparklinesReferenceLineTypes.mean} />
</Sparklines>
Normal Band

import { Sparklines, SparklinesLine, SparklinesNormalBand } from 'react-sparklines-typescript-v2';
...
<Sparklines data={sampleData}>
    <SparklinesLine style={{ fill: "none" }}/>
    <SparklinesNormalBand />
</Sparklines>

Keywords

FAQs

Last updated on 05 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc