Skip to content
Commits on Source (2)
This diff is collapsed.
{
"name": "i4-js-commons",
"version": "3.9.8",
"version": "3.9.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "i4-js-commons",
"version": "3.9.8",
"version": "3.9.9",
"description": "Just a load of common stuff for i4 front-ends and some probably usable in back-end as well",
"dependencies": {
"@material-ui/core": "^4.8.0",
......@@ -65,9 +65,11 @@
},
"scripts": {
"docgen": "jsdoc2md src/* > docs/lib.md",
"lint": "eslint --cache src",
"prettier": "prettier --ignore-path .gitignore --write --list-different \"**/*.{js,mjs}\"",
"prettier:check": "prettier --ignore-path .gitignore --check \"**/*.{js,mjs}\"",
"eslint": "eslint --ext=ts,js,jsx,tsx .",
"lint": "npm run eslint && npm run lint-check && npm run pretty-check",
"lint-check": "eslint --print-config .eslintrc.json | eslint-config-prettier-check",
"pretty": "node resources/pretty.js",
"pretty-check": "node resources/pretty.js --check",
"build": "npx babel src -d dist",
"test": "node --experimental-modules ./test"
},
......
......@@ -123,17 +123,16 @@ const pointIntoChart = R.curry((chart, { length, ttl }, point) => {
let remove = 0;
if (ttl) {
remove = R.findIndex(R.lt(subSeconds(ttl)(x)))(chart.data.labels);
console.log('ttl present:', ttl, length, chart.data.labels);
console.log('Remove count:', remove);
// console.log('ttl present:', ttl, length, chart.data.labels);
// console.log('Remove count:', remove);
chart.data.labels.splice(0, remove);
} else if (length) {
remove = 1;
if (chronologicStart && chart.data.labels.length < length) remove = 0;
}
// if (length && chronologicStart && chart.data.labels.length < length) remove = false;
// Add the new data point (to labels & datasets) and remove if necessary
if (remove) chart.data.labels.shift();
chart.data.labels.push(x);
// if (length && chronologicStart && chart.data.labels.length < length) remove = false;
// if (remove) chart.data.labels.shift();
chart.data.datasets.forEach((ds, ix) => {
const val = ys[ix];
// if (!R.is(Object, val) && !R.is(Number, val) && !R.isNil(val)) val = { data: val };
......@@ -187,24 +186,16 @@ export const Chart = ({
}, []);
useEffect(() => {
console.log('Chart update on points:', length, points);
if (nilOrEmpty(points)) return;
R.map(pointIntoChart(chart.current, { length, ttl }))(points);
// console.log('Chart datasets:', chart.current.data.datasets);
// console.log('Chart labels:', chart.current.data.labels);
chart.current.update();
}, [points]);
useEffect(() => {
// console.log('Chart update:', length, point);
if (nilOrEmpty(point)) return;
// if (Array.isArray(point)) {
// R.map(payloadIntoChart(chart.current, length))(payload);
pointIntoChart(chart.current, { length: length || 10, ttl }, point);
// console.log('Chart datasets:', chart.current.data.datasets);
// console.log('Chart labels:', chart.current.data.labels);
chart.current.update();
}, [point]);
}, [point, length, ttl]);
useEffect(() => {
if (nilOrEmpty(values)) return;
......
......@@ -15,18 +15,17 @@ import { hasnt } from './transforms';
* @param {array} settings.lengths A "guess" of each channel's space in resulting pl
* @returns {Component} A new component
*/
export const withSubs = settings => {
export const withSubs = ({
propName = 'point',
historyPropName = 'points',
channels,
transform,
init,
ttl = 84600,
...rest
}) => {
// settings: { myKey: { init: x, rid:'<aRid>'} }
// const dataKey = R.o(R.head, R.keys)(settings);
const {
propName = 'point',
historyPropName = 'points',
channels,
transform,
init,
ttl = 84600,
...rest
} = settings;
const doTransform = transform && typeof transform === 'function';
return Component => {
......