Giter VIP home page Giter VIP logo

uplot's Introduction

📈 μPlot

A small (~45 KB min), fast chart for time series, lines, areas, ohlc & bars (MIT Licensed)


Introduction

μPlot is a fast, memory-efficient Canvas 2D-based chart for plotting time series, lines, areas, ohlc & bars; from a cold start it can create an interactive chart containing 150,000 data points in 90ms, scaling linearly at ~31,000 pts/ms. In addition to fast initial render, the zooming and cursor performance is by far the best of any similar charting lib; at ~50 KB, it's likely the smallest and fastest time series plotter that doesn't make use of context-limited WebGL shaders or WASM, both of which have much higher startup cost and code size.

However, if you need 60fps performance with massive streaming datasets, uPlot can only get you so far. If you decide to venture into this realm with uPlot, make sure to unclog your rendering pipeline. WebGL should still be the tool of choice for applications like realtime signal or waveform visualizations: See danchitnis/webgl-plot, huww98/TimeChart, epezent/implot, or commercial products like LightningChart®.


uPlot Chart


Features


Non-Features

In order to stay lean, fast and focused the following features will not be added:

  • No data parsing, aggregation, summation or statistical processing - just do it in advance. e.g. https://simplestatistics.org/, https://github.com/leeoniya/uDSV
  • No transitions or animations - they're always pure distractions.
  • No collision avoidance for axis tick labels, so may require manual tweaking of spacing metrics if label customization significiantly increases default label widths.
  • No stacked series: see "Stacked Area Graphs Are Not Your Friend" and a horrific demo. While smooth spline interpolation is available, its use is strongly discouraged: Your data is misrepresented!. Both visualizations are terrible at accurately communicating information.
  • No built-in drag scrolling/panning due to ambiguous native zoom/selection behavior. However, this can be added externally via the plugin/hooks API: zoom-wheel, zoom-touch.

Documentation (WIP)

The docs are a perpetual work in progress, it seems. Start with /docs/README.md for a conceptual overview. The full API is further documented via comments in /dist/uPlot.d.ts. Additionally, an ever-expanding collection of runnable /demos covers the vast majority of uPlot's API.


Third-party Integrations


Performance

Benchmarks done on this hardware:

  • Date: 2023-03-11
  • AMD Ryzen 7 PRO 5850U @ 1.9GHz, 32GB RAM
  • EndeavourOS/Arch (KDE/Plasma), Chrome 113.0.5638.0 (64-bit)
  • 4K display scaled to 1440p (1.5 devicePixelRatio)

uPlot Performance

Full size: https://leeoniya.github.io/uPlot/demos/multi-bars.html

Raw data: https://github.com/leeoniya/uPlot/blob/master/bench/results.json

| lib                    | size    | done    | js,rend,paint,sys | heap peak,final | mousemove (10s)     |
| ---------------------- | ------- | ------- | ----------------- | --------------- | ------------------- |
| uPlot v1.6.24          | 47.9 KB |   34 ms |   51   2   1   34 |  21 MB   3 MB   |  218  360  146  196 |
| Chart.js v4.2.1        |  254 KB |   38 ms |   90   2   1   40 |  29 MB  10 MB   | 1154   46  165  235 |
| Flot v3.0.0            |  494 KB |   60 ms |  105   5   1   52 |  41 MB  21 MB   | ---                 |
| ECharts v5.4.1         | 1000 KB |   55 ms |  148   3   1   35 |  17 MB   3 MB   | 1943  444  203  208 |
| dygraphs v2.2.1        |  132 KB |   90 ms |  163   2   1   33 |  88 MB  42 MB   | 1438  371  174  268 |
| LightningChart® v4.0.2 | 1300 KB |  --- ms |  250   2   1   33 |  33 MB  13 MB   | 5390  120  128  325 |
| CanvasJS v3.7.5        |  489 KB |  130 ms |  266   4   1   35 |  98 MB  69 MB   | 1030  445   90  246 |
| dvxCharts v5.1.0       |  373 KB |  160 ms |  264  23   1   62 | 100 MB  61 MB   |  687  779  206  197 |
| Highcharts v10.3.3     |  413 KB |  --- ms |  416   7   1   38 |  97 MB  55 MB   | 1286  824  205  242 |
| Plotly.js v2.18.2      | 3600 KB |  310 ms |  655  14   1   40 | 104 MB  70 MB   | 1814  163   25  208 |
| ApexCharts v3.37.1     |  503 KB |  685 ms |  694   9   1   33 | 175 MB  46 MB   | 1708  421  106  207 |
| ZingChart v2.9.10      |  871 KB |  681 ms |  717   7   1  105 | 290 MB 195 MB   | 9021  305   41   71 |
| amCharts v5.3.7        |  625 KB |  --- ms | 1601   3   3   46 | 147 MB 121 MB   | 9171   71  460  167 |
  • libs are sorted by their initial, cold-start, render performance (excluding network transfer time to download the lib)
  • size includes the lib itself plus any dependencies required to render the benchmark, e.g. Moment, jQuery, etc.
  • Flot does not make available any minified assets and all their examples use the uncompressed sources; they also use an uncompressed version of jQuery :/

Some libraries provide their own performance demos:

TODO (all of these use SVG, so performance should be similar to Highcharts):

  • Chartist.js
  • d3-based
    • C3.js
    • dc.js
    • MetricsGraphics
    • rickshaw

Unclog your rendering pipeline

Your browser's performance is highly dependent on your hardware, operating system, and GPU drivers.

If you're using a Chromium-based browser, there are some hidden settings that can unlock significant performance improvements for Canvas2D rendering. Most of these have to do with where and how the rasterization is performed.

Head over to https://leeoniya.github.io/uPlot/demos/sine-stream.html and open up Chrome's DevTools (F12), then toggle the Performance Monitor.

Chrome DevTools Peformance Monitor

For me:

  • On Windows 10 Desktop, Core i7-8700, 16GB RAM, AMD RX480 GPU, 2048 x 1080 resolution = 57% CPU usage
  • On Manjaro Laptop (Arch Linux), AMD Ryzen 7 PRO 5850U, 48GB RAM, AMD Radeon RX Vega 8 (integrated GPU), 4K resolution = 99% CPU usage

If your CPU is close to 100%, it may be rasterizing everything in the same CPU process.

Pop open chrome://gpu and see what's orange or red.

Chrome gpu

Then open chrome://flags and search for "raster" to see what can be force-enabled.

Chrome flags

  • On my Manjaro/Ryzen/Integrated GPU setup, force-enabling Canvas out-of-process rasterization resulted in a dramatic framerate improvement.
  • On my Windows/i7/Dedicated GPU setup, toggling the same flags moved the work to another process (still good), but did not have a significant framerate impact.

YMMV!


Acknowledgements

uplot's People

Contributors

benmccann avatar emiphil avatar fluxin avatar frodoluo avatar glennmatthys avatar jl- avatar joaopaulobdac avatar klaster1 avatar kurkle avatar kylebsingh avatar ldstein avatar leeoniya avatar m-ahmadi avatar martichou avatar maxdamantus avatar mezga0153 avatar mrkurt avatar samb avatar scottkevill avatar seanyusa avatar silverwind avatar simon04 avatar skalinichev avatar strepon avatar switchtrue avatar tmcnitt avatar tomforster avatar x2764tech avatar zefirka avatar zoltanbedi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uplot's Issues

📖 API Docs

  • data format & requirements
  • how scales, axes and series interact
  • DOM structure: classes of axes, labels, cursors, points, plot, grid, chart
  • mouse interaction: zoom/unzoom, focus-hover (plot & legend), cursor lock/unlock, legend series toggle
  • series.value can be a template string if time: true
  • passing then to constructor to fire init after custom dom injection

declarative opts:

  • .data
  • .hooks
    • init
    • setScale
    • setCursor
    • setSelect
    • setSeries
    • setData
    • setSize
    • drawClear
    • drawAxes
    • drawSeries
    • draw
    • ready
    • destroy
  • .plugins
  • .title
  • .id, .class
  • .width, .height
  • .gutters: {x, y}
  • .scales
    • .auto
    • .time
    • .range (fn and array)
    • .from
    • .distr
    • .min, .max
  • .axes
    • .show
    • .side
    • .stroke
    • .scale
    • .incrs
    • .split
    • .values (fn and stampsCfg array)
    • .space (fn and number)
    • .size
    • .gap
    • .font
    • .label
    • .labelSize
    • .labelFont
    • .grid
      • .show
      • .stroke
      • .width
      • .dash
    • .ticks
      • .show
      • .stroke
      • .width
      • .dash
      • .size
  • .series
    • .show
    • .paths
    • .scale
    • .label
    • .stroke
    • .fill
    • .alpha
    • .width
    • .dash
    • .value
    • .values
    • .band
    • .spanGaps
    • .class
    • .points
      • .show (fn or bool)
      • .size
      • .width
      • .stroke
      • .fill
  • .cursor
    • .show
    • .points
      • .show (fn or bool)
    • .x, .y
    • .drag: {setSelect, setScale, x, y}
    • .sync: {key, setSeries}
    • .focus: {prox}
    • .lock
  • .focus: {alpha}
  • .select
    • .show
  • .legend
    • .show

instance properties and methods:

  • .root
  • .width, .height
  • .ctx
  • .bbox
  • .redraw()
  • .scales, .axes, .series, .cursor, .hooks, .data, .ctx, .select (state inference)
  • .batch()
  • .setData(), .setScale(), .setCursor(), .setSeries(), .setSelect(), .setSize()
  • .destroy()
  • .tzDate
  • .posToIdx(left)
  • .posToVal(left/top, scaleKey)
  • .valToPos(val, scaleKey)

static properties and functions:

  • uPlot.fmtDate
  • uPlot.tzDate
  • uPlot.rangeNum
  • uPlot.assign

focus series closest to cursor

or, more accurately, de-focus all but the closest.

the cursor.focus branch is a mostly-complete implementation of this dygraphs' highlighted-series demo [1].

cursor-focus

i'm not entirely convinced that this is something valuable enough to keep (at least in this format). i'd like to see a real use-case when seeing an isolated trend is indispensable in the presence of dozens or hundreds of series. most of the interesting info in these will just be visual outlier detection, which does not actually require a canvas redraw, but simply quick identification of the hovered series/data point and its value.

i want to stay away from "cool" features that add code and impact perf but don't add much value in terms of data inference.

[1] http://dygraphs.com/gallery/#g/highlighted-series

Run benchmarks multiple times

The benchmarks seem rather variable since they're based on only a single run currently. I think the numbers would be more reliable if it created a new chart in a loop 50 or 100 times and then took the average

Financial time series axis

Adding an issue to track based off the discussion at chartjs/Chart.js#6695 (comment)

Most financial applications such as Yahoo Finance, Trading View, etc. have each data point equally spaced apart. I originally didn't notice this wasn't done on the gold high/low example because there were lots of points. But it's more noticeable when there are fewer points or the points are drawn as candlesticks, ohlc, or bars because you end up with gaps for weekends.

The actual logic is really simple. Each point is just placed on the x-axis by index / numIndices. (The Chart.js code for this is stupidly over complicated and a terrible example to follow so I wouldn't even look at it as it would only confuse)

optimize label rendering perf

first step is to re-use the dom of existing labels rather than destroying and re-creating them on each .setView() and .setData(). this might be good enough.

maybe draw axis labels on canvas rather than the DOM. they will always change together with series lines and grid, which already get drawn on canvas. this will also make it easy to export the graph as an image.

there are trade-offs to this.

there are 2 main features lost by moving away from the dom:

  • css styling flexibility, & auto-text wrapping (will have to implement this in js [1]
  • accessibility (crisp text resizing on pinch zoom)

i dont want to bloat the options with every possible styling option to compensate for loss of CSS. instead, we should provide some basics (font size, color, weight) plus access to the raw ctx so anything else can be set directly [2] by the supplied axis.values function.

[1] https://stackoverflow.com/questions/2936112/text-wrap-in-a-canvas-element
[2] https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text

Internationalization

You can use the Intl API to format times so that they render in other language-agnostic format. E.g. I work on a site that supports both English and Spanish and "October" would automatically show up as "Octubre" in my charts on that site because they're using Luxon which uses the browser's Intl api under the covers. You don't need to provide any translations as the browser has them built in. You could either use a library like Luxon or use the Intl API directly

should series line width be in logical pixels?

currently width maps directly to ctx.lineWidth. this might be somewhat unexpected when taken with the fact that chart width and height are specified in logical (css) pixels and the canvas itself may be larger (multiplied by devicePixelRatio). all internal canvas ops are also specified in canvas pixels.

this might be ok, and certainly provides a lot of fine detail, but does not result in a true 1px css width.

the question is whether the canvas ops and line widths should be adjusted to match the devicePixelRatio? i'm thinking yes for a default but should it be possible to toggle this behavior to take advantage of the full canvas resolution (as is done now).

Time zone support

I usually have timestamps (millis since epoch) from the server. But often I want to display in a different time zone. E.g. in Pacific Time or the user's local time for server monitoring. In NYC time zone for finance applications.

Luxon has a really clever way of supporting time zones via the Intl api, which is the best I've seen. I have an open PR to add this feature to the date-fns library as well, which the author sounded interested in, but wanted to wait for a future release. Potentially you could use one of these libraries or another option would be to copy some of the code needed for support

static scales

an option to pre-define fixed scales and disable auto-rescaling.

let opts = {
  scales: {
    "myScale": {
      min: -5,
      max: 100,
    },
    "yourScale": {
      min: 0,
      max: 1500,
    },
  },
};

scatter instead of line

Would it be easy (and still performant) to be able to choose for a scatterplot instead of linechart per series?

API control and query of toggled series

Series can be toggled in the UI, an API to control and queries the toggled series would be really useful.

I've tested it for streamed data and it works really nicely and fast. Thanks a lot for your library !!!

bar charts with category x-axis

Architecturally, some additional chart types can be supported as long as they conform to the following:

  • X values must be numbers, increasing and unique
  • Y values must be numbers, null or undefined for data gaps
  • X and Y arrays must be equal length
const data = [
  [1566453600, 1566457260, 1566460860, 1566464460],   // x values
  [0.54,       0.15,       3.27,       7.51      ],   // series 1
  [12.85,      null,      13.65,      14.01      ],   // series 2
  [0.52,       1.25,       0.75,       null      ],   // series 3
];

this means we can support:

  • line (numeric & time)
  • line with custom markers (box plots, candlesticks, stock (OHLC)
  • vt bar (column)
  • hz bar

while the x-values have to be numeric, x labels can be text, so for something like this:

json-parser

you could simply keep a map in app-space

let xCats = ["Censys", "Gharchive", "NYTimes"];

let data = [
  [   0,     1,     2],
  [3.09,   2.7,  2.92],
  [1.93,   1.6,  2.02],
  [1.06,  0.93,  1.22],
];

let opts = {
  scales: {
    x: {
      type: 'n'
    }
  },
  series: {
    y: [
      {label: "PyPyBaseline"},
      {label: "PyPyKeySringCaching"},
      {label: "PyPyMapNoCache"},
    ],
  },
  axes: {
    x: {
      values: (vals, space) => vals.map(v => xCats[v]),
    }
  }
}

have multiple plots sync the x-axis + crosshair

Usecase: finance time-series of N symbols of which to check their correlation. These have different y-scale, but always the same x-scale.

Plotting them in same plot due to variance in y-scale doesn't work most of the time.
Therefore, I want to have a couple of plots side by side.

It would be awesome to be able to sync between plots:

  • x-scale. Zoom in on 1 plot, zooms in on others. Note that the user has to make sure that the same data in terms of time is given for each plot to begin with.
  • crosshair. Hover over 1 plot, will show crosshair dotted x + y-lines (including highlighted numbers) on all plots.

Thoughts?

Axes control

For axes y: space works as expected, but min and max looks not working.
For axes x: the display is always time type, even I use type: "n".

axes: {
          x: [
               {
                 type: "n",
                 scale: 'x',
                  //values: (vals, space) => vals.map(v => v*100),
                  min: 0,
                  max: 10,
                  space: 50,
                }
            ],
            y: [
                {    type: "n",  //"t" is for time; "n" for number
                     scale: 'y',
                     //values: (vals, space) => vals.map(v => v*1),
                     min: -20,
                     max: 20,
                     space: 50,
                }
            ],
}

improve date label granularity determination

this logic [1] can use a bit of tweaking. specifically, something like this should be better at high granularity:

instead of:

12am    1am    2am    3am
Oct 1  Oct 1  Oct 1  Oct 1

this:

12am    1am  2am  3am
Oct 1

same for hours, months, etc.

[1]

uPlot/src/opts.js

Lines 65 to 93 in d89f982

const md = '{M}/{D}';
const hr = '{h}';
const mm = ':{mm}';
const ss = ':{ss}';
const ms = '.{fff}';
const ampm = '{aa}';
const mdhr = md + '\n' + hr;
const shortDate = fmtDate(md);
const shortDateHour = fmtDate(mdhr + ampm);
const shortDateHourMin = fmtDate(mdhr + mm + ampm);
const shortDateHourMinSec = fmtDate(mdhr + mm + ss + ampm);
const shortHourMinSecMilli = fmtDate(hr + mm + ss + ms + ampm);
export function timeAxisVals(vals, space) {
let incr = vals[1] - vals[0];
let stamp = (
incr >= d ? shortDate :
// {M}/{DD}/{YY} should only be prepended at 12a? // {YY} only at year boundaries?
incr >= h ? shortDateHour :
incr >= m ? shortDateHourMin :
incr >= 1 ? shortDateHourMinSec :
shortHourMinSecMilli
);
return vals.map(val => stamp(new Date(val * 1e3)));
}

Try uPlot.js

i'll tag people here whose issues & use-cases in other charting libs could be good opportunities to try uPlot.

Data updates with static xAxis don't redraw correctly

I'm attempting to plot a live-updating data set however instead of the new data getting drawn, uPlot will always draw the original paths. After some digging I realized that my xAxis never changes, causing the series' paths to never be reset.

A simple example of the data I'm plotting (notice the x axis data doesn't change)

setData([[1, 2, 3, 4, 5], 
         [1, 3, 5, 7, 9]])
...
setData([[1, 2, 3, 4, 5], 
         [2, 4, 6, 8, 10]])

This appears to be the relevant code:

uPlot/src/Line.js

Lines 766 to 767 in 826fa01

if (key == xScaleKey && (min != sc.min || max != sc.max))
resetSeries();

Right now I'm working around the issue with uplot.series.y.forEach(s => (s.path = null)) right before my call to setData but that seems less than ideal. Is there a more obvious way I should be doing things? Or is this an issue with the library itself? Thanks in either case.

TypeError on demo page

https://leeoniya.github.io/uPlot/bench/uPlot.html

It gets stuck on Rendering... with this error in the console:

Uncaught TypeError: Cannot read property 'show' of null
  at uPlot.iife.min.js:2
  at Array.forEach (<anonymous>)
  at uPlot.iife.min.js:2
  at rt (uPlot.iife.min.js:2)
  at ut (uPlot.iife.min.js:2)
  at A (uPlot.iife.min.js:2)
  at new n.Line (uPlot.iife.min.js:2)
  at makeChart (uPlot.html:121)
  at uPlot.html:134

Maybe related to 3633f6a

Scale Options

What are the different options we can use for scale (%, mb are provided in the example). What are the rest?

log scales

this might be somewhat involved, since grid & axes ticks are equally spaced right now, and determination of granularity is based around this fact.

Unable to handle all y values as 0

Changing the README.md example to have all y values as 0 causes an error.

const data = [
        [1566453600, 1566457260, 1566460860, 1566464460],   // Unix timestamps
        [0,       0,       0,       0 ],   // CPU
        [12.85,      13.21,      13.65,      14.01     ],   // RAM
        [0.52,       1.25,       0.75,       3.62      ],   // TCP Out
    ];

Console message

uPlot.iife.js:755 Uncaught TypeError: Cannot read property '0' of undefined
    at uPlot.iife.js:755
    at Array.forEach (<anonymous>)
    at drawAxesGrid (uPlot.iife.js:738)
    at setView (uPlot.iife.js:823)
    at setData (uPlot.iife.js:440)
    at new uPlot (uPlot.iife.js:1036)
    at (index):46

lines 754 to 756

				var ref = findIncr(max - min, axis.incrs, opts[dim], axis.space);
				var incr = ref[0];
				var space = ref[1];

My data has large sections of zeros and I believe I have reproduced the problem with the example data.

y scale min should be clamped at 0 if no values in data range < 0

all y-scales have a buffer added above and below their min/max values since we don't want a chart where the min/max are all the way to the top/bottom edges of the plot. if the value is a never-changing 100, then you get a reasonable 50-150 range since we don't know if the value can go above or below. using the same logic for never-changing 0 we end up with a range of -0.5-0.5, which places 0 off the bottom of the plot and you end up with an unavoidable bottom gap even if there's never data that ever actually goes negative.

this is probably a common-enough case where we can clamp the scale's min at 0.

non-changing 100 looks reasonable:

100

non-changing 0 shows a buffer area that extends to -0.5:

0

Show performance as a chart

Show a chart of the performance comparison in the readme. The readme has a table of values that would be easier to compare and see the differences in a chart. I hear uPlot might be good for that sort of thing. 😄

optimize scale invalidation when toggling a series

right now when a series is toggled, the scale associated with it is invalidated (along with all paths using that scale) and recomputed and paths redrawn.

by additionally keeping track of which series bumped the final scale min/max, we can avoid invalidating the scale when toggling a series that never affected the its associated scale. this would avoid recomputing the min/max of the scale and regenerating the other paths, which would provide a healthy improvement by avoiding most of the work. this is especially apparent when you have a lot of data-heavy series on the same scale.

what's involved is adding a prop or two to the scale itself for tagging which series indices pegged the min/max values by keeping track inside of setScales(), then adding a check in toggle() to avoid unnecessary invalidation.

review the pixel snapping code

https://mobtowers.com/2013/04/15/html5-canvas-crisp-lines-every-time/

it seems inevitable that there will always be a trade-off between positional accuracy and having crisp lines at data densities exceeding the available pixels.

right now all coords are shifted in the + direction by half the stroke width. this has the effect of aligning the left side of the line at the correct offset and providing crisp results at whole-numbered stroke widths. however, it causes some issues at the far edge of the canvas.

these diffs are minor (single or sub-px range), but it would br good to spell out & reason about the chosen behavior more precisely.

some kind resize(width, height) API

Use case: Our sensor dashboards are shared by a team of 7 scientists. Some of them have their screens rotated (portrait). They both want to maximize screen usage without changing the code.

Would it be possible to add a "stretch to fit" option?

image

image

arbitrary zoom range

the current design relies on two datapoints in the data to act as x-min/max values for the viewport.

an issue with this is that with sparse datasets it becomes impossible to zoom in enough on a single point to get high grid and label resolution.

an example would be some event that occurs on the 1st of each month any time between 12am and 1am.

right now it's possible to see the exact timestamp in the legend by hovering near the datapoint, but impossible to get visual sub-hour resolution in the chart because the min range between 2 datapoints will be ~30 days * 24h. at 40px min label spacing, your screen would need to be 28,800 pixels wide to see hourly labels, half that to see bi-hourly, etc.

this change will likely not be trivial.

X axis other than time

Quickly looking at the code, it looks like only time series are supported currently — X axis can only be timestamps (not sure though since there are no docs yet). Would it be possible to support non-timed use cases (with custom-formatted X axis)?

NPM package

Hi!

uPlot seems to be perfect for my needs since I don’t need most of the knobs and whistles offered by other libraries. Thanks for making this!

Would it be possible to see it published as an NPM package?

min/max bands

http://dygraphs.com/gallery/#g/temperature-sf-ny

dygraphs calls them "error bars" but a uPlot impl would be generic min/max. this will require area fill code to be added.

dunno if the bands should be their own series or be defined as part of an existing one.

the data format would probably be

const data = [
  [0,1,2,3,4],  // x vals
  [
    [7,3,5,7,9],  // main values (can be median, mean, geo mean, etc)
    [7,3,5,7,9],  // min vals
    [7,3,5,7,9],  // max vals
  ]
];

Major tick alignment

I wrote a feature for Chart.js that I've been calling "major ticks". I think it's best demonstrated with this example: https://www.chartjs.org/samples/latest/scales/time/financial.html

As you can see, it makes sure that the first hour, day, month, etc. is chosen for use as a label and formatted differently.

Is this a feature you'd be interested in adding to uPlot? If so, I'd be happy to help describe how it works in more detail. It's slightly slower than just naive label display since it needs to do some extra calculation, but not by much. In Chart.js it's an option so you can turn it on and off, and I'm sure we could do the same here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.