gladly-plot 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/axes/Axis.js +253 -0
- package/src/{AxisQuantityKindRegistry.js → axes/AxisQuantityKindRegistry.js} +7 -0
- package/src/{AxisRegistry.js → axes/AxisRegistry.js} +48 -0
- package/src/axes/ColorAxisRegistry.js +93 -0
- package/src/{FilterAxisRegistry.js → axes/FilterAxisRegistry.js} +63 -0
- package/src/axes/ZoomController.js +141 -0
- package/src/colorscales/BivariateColorscales.js +205 -0
- package/src/colorscales/ColorscaleRegistry.js +124 -0
- package/src/compute/ComputationRegistry.js +237 -0
- package/src/compute/axisFilter.js +47 -0
- package/src/compute/conv.js +230 -0
- package/src/compute/fft.js +292 -0
- package/src/compute/filter.js +227 -0
- package/src/compute/hist.js +180 -0
- package/src/compute/kde.js +102 -0
- package/src/{Layer.js → core/Layer.js} +4 -3
- package/src/{LayerType.js → core/LayerType.js} +72 -7
- package/src/core/Plot.js +735 -0
- package/src/{Colorbar.js → floats/Colorbar.js} +19 -5
- package/src/floats/Colorbar2d.js +77 -0
- package/src/{Filterbar.js → floats/Filterbar.js} +18 -4
- package/src/{FilterbarFloat.js → floats/Float.js} +17 -30
- package/src/{EpsgUtils.js → geo/EpsgUtils.js} +1 -1
- package/src/index.js +35 -22
- package/src/{ColorbarLayer.js → layers/ColorbarLayer.js} +2 -2
- package/src/layers/ColorbarLayer2d.js +97 -0
- package/src/{FilterbarLayer.js → layers/FilterbarLayer.js} +2 -2
- package/src/layers/HistogramLayer.js +212 -0
- package/src/layers/LinesLayer.js +199 -0
- package/src/layers/PointsLayer.js +114 -0
- package/src/layers/ScatterShared.js +142 -0
- package/src/{TileLayer.js → layers/TileLayer.js} +4 -4
- package/src/Axis.js +0 -48
- package/src/ColorAxisRegistry.js +0 -49
- package/src/ColorscaleRegistry.js +0 -52
- package/src/Float.js +0 -159
- package/src/Plot.js +0 -1073
- package/src/ScatterLayer.js +0 -287
- /package/src/{AxisLink.js → axes/AxisLink.js} +0 -0
- /package/src/{MatplotlibColorscales.js → colorscales/MatplotlibColorscales.js} +0 -0
- /package/src/{Data.js → core/Data.js} +0 -0
- /package/src/{LayerTypeRegistry.js → core/LayerTypeRegistry.js} +0 -0
package/src/Float.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { Colorbar } from "./Colorbar.js"
|
|
2
|
-
import { Plot } from "./Plot.js"
|
|
3
|
-
|
|
4
|
-
const DRAG_BAR_HEIGHT = 12
|
|
5
|
-
const MIN_WIDTH = 80
|
|
6
|
-
const MIN_HEIGHT = DRAG_BAR_HEIGHT + 30
|
|
7
|
-
|
|
8
|
-
// Default sizes include the drag bar so the colorbar content area is unchanged.
|
|
9
|
-
const DEFAULT_SIZE = {
|
|
10
|
-
horizontal: { width: 220, height: 70 + DRAG_BAR_HEIGHT },
|
|
11
|
-
vertical: { width: 70, height: 220 + DRAG_BAR_HEIGHT }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class Float {
|
|
15
|
-
constructor(parentPlot, colorAxisName, {
|
|
16
|
-
orientation = "horizontal",
|
|
17
|
-
x = 10,
|
|
18
|
-
y = 10,
|
|
19
|
-
width,
|
|
20
|
-
height,
|
|
21
|
-
margin
|
|
22
|
-
} = {}) {
|
|
23
|
-
const defaults = DEFAULT_SIZE[orientation]
|
|
24
|
-
const w = width ?? defaults.width
|
|
25
|
-
const h = height ?? defaults.height
|
|
26
|
-
|
|
27
|
-
// Outer floating container
|
|
28
|
-
this._el = document.createElement('div')
|
|
29
|
-
Object.assign(this._el.style, {
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
left: x + 'px',
|
|
32
|
-
top: y + 'px',
|
|
33
|
-
width: w + 'px',
|
|
34
|
-
height: h + 'px',
|
|
35
|
-
zIndex: '10',
|
|
36
|
-
boxSizing: 'border-box',
|
|
37
|
-
background: 'rgba(255,255,255,0.88)',
|
|
38
|
-
border: '1px solid #aaa',
|
|
39
|
-
borderRadius: '4px',
|
|
40
|
-
boxShadow: '0 2px 8px rgba(0,0,0,0.25)',
|
|
41
|
-
overflow: 'hidden'
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// Ensure parent is positioned so our absolute child is contained within it
|
|
45
|
-
const parentEl = parentPlot.container
|
|
46
|
-
if (getComputedStyle(parentEl).position === 'static') {
|
|
47
|
-
parentEl.style.position = 'relative'
|
|
48
|
-
}
|
|
49
|
-
parentEl.appendChild(this._el)
|
|
50
|
-
|
|
51
|
-
// Drag bar — thin strip at the top; dragging here moves the float
|
|
52
|
-
this._dragBar = document.createElement('div')
|
|
53
|
-
Object.assign(this._dragBar.style, {
|
|
54
|
-
position: 'absolute',
|
|
55
|
-
top: '0',
|
|
56
|
-
left: '0',
|
|
57
|
-
right: '0',
|
|
58
|
-
height: DRAG_BAR_HEIGHT + 'px',
|
|
59
|
-
cursor: 'grab',
|
|
60
|
-
background: 'rgba(0,0,0,0.07)',
|
|
61
|
-
borderBottom: '1px solid rgba(0,0,0,0.12)',
|
|
62
|
-
zIndex: '1'
|
|
63
|
-
})
|
|
64
|
-
this._el.appendChild(this._dragBar)
|
|
65
|
-
|
|
66
|
-
// Resize handle — bottom-right corner
|
|
67
|
-
this._resizeHandle = document.createElement('div')
|
|
68
|
-
Object.assign(this._resizeHandle.style, {
|
|
69
|
-
position: 'absolute',
|
|
70
|
-
right: '0',
|
|
71
|
-
bottom: '0',
|
|
72
|
-
width: '12px',
|
|
73
|
-
height: '12px',
|
|
74
|
-
cursor: 'se-resize',
|
|
75
|
-
background: 'rgba(0,0,0,0.18)',
|
|
76
|
-
borderTopLeftRadius: '3px',
|
|
77
|
-
zIndex: '3'
|
|
78
|
-
})
|
|
79
|
-
this._el.appendChild(this._resizeHandle)
|
|
80
|
-
|
|
81
|
-
// Sub-container for the colorbar — sits below the drag bar
|
|
82
|
-
this._colorbarEl = document.createElement('div')
|
|
83
|
-
Object.assign(this._colorbarEl.style, {
|
|
84
|
-
position: 'absolute',
|
|
85
|
-
top: DRAG_BAR_HEIGHT + 'px',
|
|
86
|
-
left: '0',
|
|
87
|
-
right: '0',
|
|
88
|
-
bottom: '0'
|
|
89
|
-
})
|
|
90
|
-
this._el.appendChild(this._colorbarEl)
|
|
91
|
-
|
|
92
|
-
this._colorbar = new Colorbar(this._colorbarEl, parentPlot, colorAxisName, { orientation, margin })
|
|
93
|
-
|
|
94
|
-
this._setupInteraction()
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
_setupInteraction() {
|
|
98
|
-
let mode = null // 'drag' | 'resize'
|
|
99
|
-
let startX, startY, startLeft, startTop, startW, startH
|
|
100
|
-
|
|
101
|
-
const onDragBarMouseDown = (e) => {
|
|
102
|
-
mode = 'drag'
|
|
103
|
-
startX = e.clientX
|
|
104
|
-
startY = e.clientY
|
|
105
|
-
startLeft = parseInt(this._el.style.left, 10)
|
|
106
|
-
startTop = parseInt(this._el.style.top, 10)
|
|
107
|
-
this._dragBar.style.cursor = 'grabbing'
|
|
108
|
-
e.preventDefault()
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const onResizeMouseDown = (e) => {
|
|
112
|
-
mode = 'resize'
|
|
113
|
-
startX = e.clientX
|
|
114
|
-
startY = e.clientY
|
|
115
|
-
startW = this._el.offsetWidth
|
|
116
|
-
startH = this._el.offsetHeight
|
|
117
|
-
e.preventDefault()
|
|
118
|
-
e.stopPropagation()
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const onMouseMove = (e) => {
|
|
122
|
-
if (!mode) return
|
|
123
|
-
const dx = e.clientX - startX
|
|
124
|
-
const dy = e.clientY - startY
|
|
125
|
-
if (mode === 'drag') {
|
|
126
|
-
this._el.style.left = (startLeft + dx) + 'px'
|
|
127
|
-
this._el.style.top = (startTop + dy) + 'px'
|
|
128
|
-
} else {
|
|
129
|
-
this._el.style.width = Math.max(MIN_WIDTH, startW + dx) + 'px'
|
|
130
|
-
this._el.style.height = Math.max(MIN_HEIGHT, startH + dy) + 'px'
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const onMouseUp = () => {
|
|
135
|
-
if (mode === 'drag') this._dragBar.style.cursor = 'grab'
|
|
136
|
-
mode = null
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
this._dragBar.addEventListener('mousedown', onDragBarMouseDown)
|
|
140
|
-
this._resizeHandle.addEventListener('mousedown', onResizeMouseDown)
|
|
141
|
-
document.addEventListener('mousemove', onMouseMove)
|
|
142
|
-
document.addEventListener('mouseup', onMouseUp)
|
|
143
|
-
|
|
144
|
-
this._cleanupInteraction = () => {
|
|
145
|
-
this._dragBar.removeEventListener('mousedown', onDragBarMouseDown)
|
|
146
|
-
this._resizeHandle.removeEventListener('mousedown', onResizeMouseDown)
|
|
147
|
-
document.removeEventListener('mousemove', onMouseMove)
|
|
148
|
-
document.removeEventListener('mouseup', onMouseUp)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
destroy() {
|
|
153
|
-
this._cleanupInteraction()
|
|
154
|
-
this._colorbar.destroy()
|
|
155
|
-
this._el.remove()
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
Plot._FloatClass = Float
|