1.0.2 • Published 2 years ago

uplot-react-js v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
  1. Introduction
  2. Getting Started
  3. General
  4. Configuration
  5. Axes

Introduction

This is Wrapper component for uplot library (A small (~40 KB min), fast chart for time series, lines, areas, ohlc & bars).

Getting_Started

Install:

    npm i uplot-react-js
    or
    yarn add uplot-react-js

First you need remove Strict Mode in index(.tsx | .ts) or index(.jsx | .js) files

Before: 
    ReactDOM.createRoot(document.getElementById('root'));
    root.render(
    <StrictMode>
        <App />
    </StrictMode>
    );

After:
    ReactDOM.createRoot(document.getElementById('root'));
    root.render(
    <>
        <App />
    </>
    );

General

    <div>
        <UPlot 
            data={data} 
            options={{
                ...options,
                width: '720px', 
                height: '320px'
            }}
        />
    </div>
    const randomWidth = Math.random()*1000;
    const randomHeight = Math.random()*1000;

    <div style={{ width: randomWidth, height: randomHeight}}>
        <UPlot 
            data={data} 
            options={{
                ...options,
                autoResize: true
            }}
        />
    </div>

Configuration

STTpropstypedefaultrequired
1idstringnoneno
2optionsoptions in UPlotPropsnoneyes
3datadata in UPlotPropsnoneyes
4configsconfigs in UPlotPropsnoneno

options:

NameTypeItemValueDefaultDescription
modenumber1 or 211: aligned & ordered, single-x / y-per-series, 2: unordered & faceted, per-series/per-point x,y,size,label,color,shape,etc.
titlestringnonechart title
idstringnoneid of chart uplot canvas
classstringnoneclassName to add to chart uplot canvas
widthnumbernonewidth of chart
heightnumbernoneheight of chart
dataobjectAlignedDatanone
tzDatefunctiontzDatenoneConverts a unix timestamp to Date that's time-adjusted for the desired timezone
fmtDatefunctionfmtDatenoneCreates an efficient formatter for Date objects from a template string, e.g. {YYYY}-{MM}-{DD} */
msnumber1e-3 or 11e-3timestamp multiplier that yields 1 millisecond
drawOrderarray'axes' or 'series'"axes", "series"drawing order for axes/grid & series
pxAlignboolean or numbertruewhether vt & hz lines of series/grid/ticks should be crisp/sharp or sub-px antialiased
seriesarraySeriescoming soon...coming soon...
bandsarrayBandcoming soon...
scalesarrayScalescoming soon...coming soon...
axesuplot.Axis[]coming soon...coming soon...coming soon...
paddinguplot.Paddingtop: PaddingSide, right: PaddingSide, bottom: PaddingSide, left: PaddingSidecoming soon...
selectuplot.SelectSelectcoming soon...coming soon...
legenduplot.Legendcoming soon...coming soon...coming soon...
cursoruplot.Cursorcoming soon...coming soon...coming soon...
focusuplot.Focuscoming soon...coming soon...coming soon...
hooksuplot.Hooks[]coming soon...coming soon...coming soon...
pluginsuplot.Plugin[]coming soon...coming soon...coming soon...

data:

config:

AlignedData

In options.mode = 1, per xValue correspond with per yValue

{
    xValues: number[] | string[],
    yValues: any[]
}

NOTE: if xValues is time, it default is seconds, if you don't like it, you can config with ms in options config.

tzDate

(ts: number) => Date

fmtDate

(tpl: string) => (date: Date) => string

uplot.select

div into which .u-select will be placed: .u-over or .u-under

{
    show?: boolean;
    left: number;
    top: number;
    width: number;
    height: number;
    over?: boolean; // default true
}

Series

NameTypeItemValueDefaultDescription
showboolean or functionif boolean or func returns boolean (this func is have 4 params: uplotSelf,seriesIdx,idx0,idx1), round points are drawn with defined options, else fn should draw own custom points via self
pathsfunction(self: uPlot, seriesIdx: number, idx0: number, idx1: number, filtIdxs?: number[] or null) => Paths or null
filterPoints.Filtermay return an array of points indices to draw Points.Filter = number[] or null or ((self: uPlot, seriesIdx: number, show: boolean, gaps?: null or number) => number[] or null)
sizenumberdiameter of point in CSS pixels
spacenumbersize * 2minimum avg space between point centers before they're shown
widthnumberline width of circle outline in CSS pixels
strokeStrokecoming soon...coming soon...line color of circle outline (defaults to series.stroke)
dasharraynumberline dash segment array
dashSeries.Capcoming soon...coming soon...line cap
fillFillcoming soon...#ffffill color of circle

Band

NameTypeItemValueDefaultDescription
showbooleantrue or falsefalseband on/off
seriesarrayfromSeriesIdx: number, toSeriesIdx: numberseries indices of upper and lower band edges
fillcoming soon...area fill style
dirnumber1 or -1whether to fill towards yMin (-1) or yMax (+1) between "from" & "to" series

Scales

this is object:

interface Scales {
		[key: string]: Scale;
	}

Scale have properties:

NameTypeItemValueDefaultDescription
timebooleanis this scale temporal, with series' data in UNIX timestamps?
autoboolean or functiondetermines whether all series' data on this scale will be scanned to find the full min/max range. ((self: uPlot, resetScales: boolean) => boolean)
rangemin: number or null, max: number or null or (self: uPlot, initMin: number, initMax: number, scaleKey: string) => MinMax or {min: Range.Limit;max: Range.Limit;}area fill style

More info...

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago