New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@uwdata/mosaic-plot

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uwdata/mosaic-plot - npm Package Compare versions

Comparing version

to
0.14.0

8

package.json
{
"name": "@uwdata/mosaic-plot",
"version": "0.13.0",
"version": "0.14.0",
"description": "A Mosaic-powered plotting framework based on Observable Plot.",

@@ -29,8 +29,8 @@ "keywords": [

"@observablehq/plot": "^0.6.17",
"@uwdata/mosaic-core": "^0.13.0",
"@uwdata/mosaic-sql": "^0.13.0",
"@uwdata/mosaic-core": "^0.14.0",
"@uwdata/mosaic-sql": "^0.14.0",
"d3": "^7.9.0",
"isoformat": "^0.2.1"
},
"gitHead": "b5a0e03e200c0f04c46562a288f084ffc9f6ad55"
"gitHead": "a882aab60867e4e9d9738bc950aa9de32729a806"
}

@@ -1,6 +0,4 @@

import { ExprNode, add, dateBin, div, float64, floor, interval, mul, sub } from '@uwdata/mosaic-sql';
import { ExprNode, binDate, binHistogram } from '@uwdata/mosaic-sql';
import { Transform } from '../symbols.js';
import { channelScale } from '../marks/util/channel-scale.js';
import { bins } from './bin-step.js';
import { timeInterval } from './time-interval.js';

@@ -57,27 +55,10 @@ const EXTENT = new Set([

const { type, min, max } = mark.channelField(channel);
const { interval: i, steps, offset = 0 } = options;
const ival = i ?? (
type === 'date' || hasTimeScale(mark, channel) ? 'date' : 'number'
);
let result;
if (ival === 'number') {
// perform number binning
const { apply, sqlApply, sqlInvert } = channelScale(mark, channel);
const b = bins(apply(min), apply(max), options);
const col = sqlApply(column);
const alpha = float64((b.max - b.min) / b.steps);
const bin = floor(div(b.min === 0 ? col : sub(col, b.min), alpha));
const expr = add(b.min, mul(alpha, offset ? add(offset, bin) : bin));
result = sqlInvert(expr);
} else {
// perform date/time binning
const { interval: unit, step = 1 } = ival === 'date'
? timeInterval(min, max, steps || 40)
: options;
const bin = dateBin(column, unit, step);
result = offset ? add(bin, interval(unit, offset * step)) : bin;
}
const isDate = options.interval
|| type === 'date'
|| hasTimeScale(mark, channel);
const result = isDate
? binDate(column, [min, max], options)
: binHistogram(column, [min, max], options, channelScale(mark, channel));
return `${result}`;
}
}