DAta VIews (davi) is a self-contained JavaScript module-library which implements various raster (pixel-based) rendering techniques for data, with an emphasis on simple and direct statistical summaries.
This is an attempted remake of the original `davi`, with the aim to
DAta VIews is a JS module from which you can import functions and values to make data-graphics on web-pages more convenient: below are some of these, starting with all the `pure-data` exports.
Hexadecimal RGB strings of nice colors for common color names.
A color-palette for categorical data, using hexadecimal RGB strings.
A color-palette for categorical data, using hexadecimal RGB strings.
Avoid null/undefined values, if possible.
Find both the minimum and maximum values from the non-NaN numbers given by a transformed array. The `transform` func is optional, and can be used like the funcs given to Array.map, accepting 1, 2, or even 3 args.
The result is an object of 2 numbers, labelled `min` and `max`.
Render numbers into nice strings, with commas between all 3-digit groups, and using the number of decimal digits given. An optional argument, which is the empty string by default, is a fallback string for NaN values.
Return the same value given: this is a common default for optional transformation funcs used all over `davi`.
Loop over all integers from 1 up to (the floor of) the number given, transforming each value using the (optional) func given, resulting in an array of such transformed values.
When not given a transformation func, the result will be the values 1 to n, unchanged. When given a value less than 1, the result is an empty array, no matter the transformation func given; this is also the case when given a NaN or either infinity.
Find several numeric statistics from the non-NaN numbers given by a transformed array. The `transform` func is optional, and can be used like the funcs given to Array.map, accepting 1, 2, or even 3 args.
The result is an object of several numbers, each named according to its calculated statistic. All stats are `single-pass`, and some are calculated using Welford's method for improved accuracy.
HTML-escape strings, avoiding tag-injections in web-pages.
Proportionally/linearly map a value from its domain, given as the next 2 arguments, into the span/domain implied by the last 2 args.
The last 2 arguments are optional, and when they're not given, they default to the span/output range [0, 1], both ends included.
Proportionally/linearly map a value from its domain, given as the next 2 arguments, into the span/output range [0, 1], both ends included.
Following the `pure-data` exports are the graphics-related ones, starting right below.
Make the `outer` HTML-source of an element showing as a colored bar. This visual is meant to represent a proportional quantity between the min/max values given, and is typically used to compare to other such `bars`, perhaps as part of a data-table.
Get a base64-encoded data-URI for the current canvas contents implied by the graphics-context given.
Clear the canvas contents implied by the graphics-context given.
Fill the canvas implied by the graphics-context given. When not given a background style, the default is to clear the canvas contents.
Stroke/trace a trendline using the graphics-context given, using the (transformed) data given.
After the (general) data array given is a transformation func, which default to the identity func when given a null/undefined value: the func otherwise is expected to return a number, when given explicitly.
The last 2 numbers are always required, and define the expected source domain of the (transformed) values.