StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
var size = require('element-size')
|
|
|
|
module.exports = fit
|
|
|
|
var scratch = new Float32Array(2)
|
|
|
|
function fit(canvas, parent, scale) {
|
|
var isSVG = canvas.nodeName.toUpperCase() === 'SVG'
|
|
|
|
canvas.style.position = canvas.style.position || 'absolute'
|
|
canvas.style.top = 0
|
|
canvas.style.left = 0
|
|
|
|
resize.scale = parseFloat(scale || 1)
|
|
resize.parent = parent
|
|
|
|
return resize()
|
|
|
|
function resize() {
|
|
var p = resize.parent || canvas.parentNode
|
|
if (typeof p === 'function') {
|
|
var dims = p(scratch) || scratch
|
|
var width = dims[0]
|
|
var height = dims[1]
|
|
} else
|
|
if (p && p !== document.body) {
|
|
var psize = size(p)
|
|
var width = psize[0]|0
|
|
var height = psize[1]|0
|
|
} else {
|
|
var width = window.innerWidth
|
|
var height = window.innerHeight
|
|
}
|
|
|
|
if (isSVG) {
|
|
canvas.setAttribute('width', width * resize.scale + 'px')
|
|
canvas.setAttribute('height', height * resize.scale + 'px')
|
|
} else {
|
|
canvas.width = width * resize.scale
|
|
canvas.height = height * resize.scale
|
|
}
|
|
|
|
canvas.style.width = width + 'px'
|
|
canvas.style.height = height + 'px'
|
|
|
|
return resize
|
|
}
|
|
}
|
|
|