react-sparklines

Beautiful and expressive Sparklines React component

  • 所有者: borisyankov/react-sparklines
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Beautiful and expressive sparklines component for React

Build Status

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

Install

npm install react-sparklines --save

Run demo

npm install
npm start
http://localhost:8080

Use

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

import React from 'react';
import { Sparklines } from 'react-sparklines';
...
<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 React from 'react';
import { Sparklines, SparklinesLine } from 'react-sparklines';
...
<Sparklines data={[5, 10, 5, 20]}>
  <SparklinesLine color="blue" />
</Sparklines>

Bars

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

Spots

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

Reference Line

import React from 'react';
import { Sparklines, SparklinesLine, SparklinesReferenceLine } from 'react-sparklines';
...
<Sparklines data={sampleData}>
    <SparklinesLine />
    <SparklinesReferenceLine type="mean" />
</Sparklines>

Normal Band

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

概覽

名稱與所有者borisyankov/react-sparklines
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
發布數0
創建於2015-06-27 20:15:06
推送於2023-11-26 02:35:42
最后一次提交2017-07-27 15:46:34
星數2.8k
關注者數40
派生數192
提交數149
已啟用問題?
問題數89
打開的問題數51
拉請求數27
打開的拉請求數15
關閉的拉請求數9
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部