MCPcopy Create free account
hub / github.com/chartjs/Chart.js / numbers

Function numbers

docs/scripts/utils.js:20–42  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

18}
19
20export function numbers(config) {
21 var cfg = config || {};
22 var min = valueOrDefault(cfg.min, 0);
23 var max = valueOrDefault(cfg.max, 100);
24 var from = valueOrDefault(cfg.from, []);
25 var count = valueOrDefault(cfg.count, 8);
26 var decimals = valueOrDefault(cfg.decimals, 8);
27 var continuity = valueOrDefault(cfg.continuity, 1);
28 var dfactor = Math.pow(10, decimals) || 0;
29 var data = [];
30 var i, value;
31
32 for (i = 0; i < count; ++i) {
33 value = (from[i] || 0) + this.rand(min, max);
34 if (this.rand() <= continuity) {
35 data.push(Math.round(dfactor * value) / dfactor);
36 } else {
37 data.push(null);
38 }
39 }
40
41 return data;
42}
43
44export function points(config) {
45 const xs = this.numbers(config);

Callers

nothing calls this directly

Calls 1

valueOrDefaultFunction · 0.85

Tested by

no test coverage detected