gridviz 3.1.0 → 3.1.1
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/README.md +18 -15
- package/dist/gridviz.js +3829 -2623
- package/dist/gridviz.min.js +1 -1
- package/package.json +5 -3
- package/src/button/Button.js +77 -68
- package/src/button/FullscreenButton.js +123 -123
- package/src/button/ZoomButtons.js +109 -104
- package/src/core/GeoCanvas.js +15 -0
- package/src/core/Legend.js +267 -245
- package/src/core/Map.js +819 -670
- package/src/core/Tooltip.js +191 -185
- package/src/index.js +82 -79
- package/src/layer/GridLayer.js +4 -3
- package/src/layer/LabelLayer.js +7 -4
- package/src/legend/ColorCategoryLegend.js +127 -125
- package/src/legend/ColorDiscreteLegend.js +116 -114
- package/src/legend/ColorLegend.js +33 -11
- package/src/legend/OrientationLegend.js +94 -92
- package/src/legend/SizeLegend.js +8 -1
- package/src/legend/TernaryLegend.js +317 -314
- package/src/legend/VennLegend.js +202 -0
- package/src/style/CircleColorSizeWebGLStyle.js +249 -0
- package/src/style/CompositionStyle.js +1 -1
- package/src/style/DotDensityStyle.js +8 -4
- package/src/style/ImageStyle.js +1 -1
- package/src/style/Interpolator.js +283 -259
- package/src/style/IsoFenceStyle.js +1 -1
- package/src/style/LegoStyle.js +6 -5
- package/src/style/MosaicStyle.js +1 -1
- package/src/style/NinjaStarStyle.js +1 -1
- package/src/style/PillarStyle.js +1 -1
- package/src/style/RandomWalkInterpolator.js +213 -0
- package/src/style/ShadingRayStyle.js +16 -2
- package/src/style/ShadingStyle.js +80 -72
- package/src/style/ShapeColorSizeStyle.js +18 -2
- package/src/style/SideCategoryStyle.js +1 -1
- package/src/style/SideStyle.js +1 -1
- package/src/style/SideTanakaStyle.js +1 -1
- package/src/style/SquareColorCategoryWebGLStyle.js +71 -20
- package/src/style/SquareColorWebGLStyle.js +7 -4
- package/src/style/StrokeStyle.js +1 -1
- package/src/style/TextStyle.js +1 -1
- package/src/style/TimeSeriesStyle.js +14 -7
- package/src/utils/WebGLSquareColoringAdvanced.js +47 -9
- package/src/utils/scale.js +20 -0
- package/src/utils/webGLUtils.js +52 -0
package/src/core/Tooltip.js
CHANGED
|
@@ -1,185 +1,191 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { select } from 'd3-selection'
|
|
5
|
-
//import { transition } from "d3-transition";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A generic class to make a tooltip.
|
|
9
|
-
* It is a div element, which can be moved under the mouse pointer and filled with some information in html.
|
|
10
|
-
* @module core
|
|
11
|
-
*/
|
|
12
|
-
export class Tooltip {
|
|
13
|
-
/**
|
|
14
|
-
* @param {object} opts
|
|
15
|
-
*/
|
|
16
|
-
constructor(opts) {
|
|
17
|
-
opts = opts || {}
|
|
18
|
-
|
|
19
|
-
/** @type {string} */
|
|
20
|
-
this.maxWidth = opts.maxWidth || '20em'
|
|
21
|
-
/** @type {string} */
|
|
22
|
-
this.fontSize = opts.fontSize || '
|
|
23
|
-
/** @type {string} */
|
|
24
|
-
this.
|
|
25
|
-
/** @type {string} */
|
|
26
|
-
this.
|
|
27
|
-
/** @type {string} */
|
|
28
|
-
this.
|
|
29
|
-
/** @type {string} */
|
|
30
|
-
this
|
|
31
|
-
/** @type {string} */
|
|
32
|
-
this
|
|
33
|
-
/** @type {string} */
|
|
34
|
-
this['
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/** @type {number} */
|
|
41
|
-
this.
|
|
42
|
-
/** @type {number} */
|
|
43
|
-
this.
|
|
44
|
-
/** @type {number} */
|
|
45
|
-
this.
|
|
46
|
-
/** @type {
|
|
47
|
-
this.
|
|
48
|
-
/** @type {
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.tooltip.style('
|
|
64
|
-
this.tooltip.style('
|
|
65
|
-
this.tooltip.style('
|
|
66
|
-
this.tooltip.style('
|
|
67
|
-
this.tooltip.style('
|
|
68
|
-
this.tooltip.style('
|
|
69
|
-
this.tooltip.style('
|
|
70
|
-
this.tooltip.style('
|
|
71
|
-
this.tooltip.style('
|
|
72
|
-
this.tooltip.style('
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.tooltip.style('
|
|
76
|
-
this.tooltip.style('
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.tooltip.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
this.tooltip.
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
this.tooltip.transition().duration(this.transitionDuration).style('opacity',
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// Ensure tooltip doesn't go beyond the
|
|
142
|
-
if (node.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
my.setPosition(event);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (arguments.length == 1) return this.tooltip.
|
|
182
|
-
this.tooltip.
|
|
183
|
-
return this
|
|
184
|
-
}
|
|
185
|
-
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { select } from 'd3-selection'
|
|
5
|
+
//import { transition } from "d3-transition";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A generic class to make a tooltip.
|
|
9
|
+
* It is a div element, which can be moved under the mouse pointer and filled with some information in html.
|
|
10
|
+
* @module core
|
|
11
|
+
*/
|
|
12
|
+
export class Tooltip {
|
|
13
|
+
/**
|
|
14
|
+
* @param {object} opts
|
|
15
|
+
*/
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
opts = opts || {}
|
|
18
|
+
|
|
19
|
+
/** @type {string} */
|
|
20
|
+
this.maxWidth = opts.maxWidth || '20em'
|
|
21
|
+
/** @type {string} */
|
|
22
|
+
this.fontSize = opts.fontSize || '1rem'
|
|
23
|
+
/** @type {string} */
|
|
24
|
+
this.color = opts.color || '#171a22'
|
|
25
|
+
/** @type {string} */
|
|
26
|
+
this.lineHeight = opts.lineHeight || '1.5'
|
|
27
|
+
/** @type {string} */
|
|
28
|
+
this.background = opts.background || 'white'
|
|
29
|
+
/** @type {string} */
|
|
30
|
+
this.padding = opts.padding || '4px'
|
|
31
|
+
/** @type {string} */
|
|
32
|
+
this.border = opts.border || '1px solid #d5d5d5'
|
|
33
|
+
/** @type {string} */
|
|
34
|
+
this['border-radius'] = opts['border-radius'] || '6px'
|
|
35
|
+
/** @type {string} */
|
|
36
|
+
this['box-shadow'] = opts['box-shadow'] || '0px 4px 6px rgba(0, 0, 0, 0.1), 0px 1px 3px rgba(0, 0, 0, 0.08)'
|
|
37
|
+
/** @type {string} */
|
|
38
|
+
this['font-family'] = opts['font-family'] || "'Helvetica Neue', Arial, Helvetica, sans-serif"
|
|
39
|
+
|
|
40
|
+
/** @type {number} */
|
|
41
|
+
this.transitionDuration = opts.transitionDuration || 100
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
this.xOffset = opts.xOffset || 30
|
|
44
|
+
/** @type {number} */
|
|
45
|
+
this.yOffset = opts.yOffset || 20
|
|
46
|
+
/** @type {number} */ // e.g. to prevent mouse cursor covering cell being highlighted
|
|
47
|
+
this.yMouseOffset = opts.yMouseOffset || 0
|
|
48
|
+
/** @type {number} */
|
|
49
|
+
this.xMouseOffset = opts.xMouseOffset || 0
|
|
50
|
+
/** @type {HTMLElement} */
|
|
51
|
+
this.parentElement = opts.parentElement || document.body
|
|
52
|
+
/** @type {HTMLElement} */
|
|
53
|
+
this.tooltipElement = opts.tooltipElement || null
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @public
|
|
57
|
+
* @type {import("d3-selection").Selection} */
|
|
58
|
+
this.tooltip = opts.tooltipElement
|
|
59
|
+
? select(opts.tooltipElement) // Wrap the provided HTML node in a D3 selection
|
|
60
|
+
: select(this.parentElement).append('div').attr('id', 'gridviz-tooltip').attr('class', 'gridviz-tooltip') // create default element
|
|
61
|
+
|
|
62
|
+
//initialise
|
|
63
|
+
this.tooltip.style('max-width', this.maxWidth)
|
|
64
|
+
this.tooltip.style('overflow', 'hidden')
|
|
65
|
+
this.tooltip.style('font-size', this.fontSize)
|
|
66
|
+
this.tooltip.style('color', this.color)
|
|
67
|
+
this.tooltip.style('line-height', this.lineHeight)
|
|
68
|
+
this.tooltip.style('background', this.background)
|
|
69
|
+
this.tooltip.style('padding', this.padding)
|
|
70
|
+
this.tooltip.style('border', this.border)
|
|
71
|
+
this.tooltip.style('border-radius', this['border-radius'])
|
|
72
|
+
this.tooltip.style('box-shadow', this['box-shadow'])
|
|
73
|
+
this.tooltip.style('font-family', this['font-family'])
|
|
74
|
+
this.tooltip.style('position', 'absolute')
|
|
75
|
+
this.tooltip.style('pointer-events', 'none')
|
|
76
|
+
this.tooltip.style('opacity', '0')
|
|
77
|
+
this.tooltip.style('text-wrap', 'nowrap')
|
|
78
|
+
this.tooltip.style('z-index', 99999999) // important for leaflet-gridviz etc
|
|
79
|
+
|
|
80
|
+
// these placeholders are needed to prevent an infinite DOM resizeObserver loop:
|
|
81
|
+
this.tooltip.style('left', '0')
|
|
82
|
+
this.tooltip.style('top', '0')
|
|
83
|
+
|
|
84
|
+
// a tooltip element given by the user gets the class too
|
|
85
|
+
this.tooltip.classed('gridviz-tooltip', true)
|
|
86
|
+
|
|
87
|
+
// aria-labels (thanks to wahlatlas)
|
|
88
|
+
this.tooltip.attr('role', 'tooltip').attr('aria-live', 'polite')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Show the tooltip */
|
|
92
|
+
show() {
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
this.tooltip.transition().duration(this.transitionDuration).style('opacity', 1)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Hide the tooltip */
|
|
98
|
+
hide() {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
this.tooltip.transition().duration(this.transitionDuration).style('opacity', 0)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Set the content of the tooltip.
|
|
105
|
+
* @param {string} html
|
|
106
|
+
*/
|
|
107
|
+
html(html) {
|
|
108
|
+
this.tooltip.html(html)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Set the position of the tooltip at the mouse event position.
|
|
113
|
+
* @param {MouseEvent} event
|
|
114
|
+
*/
|
|
115
|
+
setPosition(event) {
|
|
116
|
+
// Get the bounding rect of the parent container (map2)
|
|
117
|
+
let parentRect = this.parentElement.getBoundingClientRect()
|
|
118
|
+
|
|
119
|
+
// Get the mouse position (relative to the parent container)
|
|
120
|
+
let x = event.clientX - parentRect.left + this.xOffset // Relative to parent
|
|
121
|
+
let y = event.clientY - parentRect.top - this.yOffset // Relative to parent
|
|
122
|
+
|
|
123
|
+
// Now, apply the position to the tooltip
|
|
124
|
+
this.tooltip.style('left', x + 'px').style('top', y + 'px')
|
|
125
|
+
|
|
126
|
+
// Ensure the tooltip stays inside the parent container
|
|
127
|
+
this.ensureTooltipInsideContainer(event, parentRect, this.tooltip.node())
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @function ensureTooltipInsideContainer
|
|
131
|
+
* @description Prevents the tooltip from overflowing out of the App container (ensures that the tooltip is inside the gridviz container)
|
|
132
|
+
* @param {MouseEvent} event
|
|
133
|
+
* @param {DOMRect} parentRect
|
|
134
|
+
* @param {HTMLElement} tooltipNode
|
|
135
|
+
*/
|
|
136
|
+
ensureTooltipInsideContainer(event, parentRect, tooltipNode) {
|
|
137
|
+
let node = tooltipNode
|
|
138
|
+
let parentWidth = parentRect.width
|
|
139
|
+
let parentHeight = parentRect.height
|
|
140
|
+
|
|
141
|
+
// Ensure tooltip doesn't go beyond the right edge
|
|
142
|
+
if (node.offsetLeft + node.clientWidth > parentWidth) {
|
|
143
|
+
let left = event.clientX - node.clientWidth - this.xOffset
|
|
144
|
+
node.style.left = left + 'px'
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Ensure tooltip doesn't go beyond the bottom edge
|
|
148
|
+
if (node.offsetTop + node.clientHeight > parentHeight) {
|
|
149
|
+
node.style.top = parentHeight - node.clientHeight + 'px'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Ensure tooltip doesn't go above the top edge
|
|
153
|
+
if (node.offsetTop < 0) {
|
|
154
|
+
node.style.top = 0 + 'px'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Ensure tooltip doesn't go beyond the left edge
|
|
158
|
+
if (node.offsetLeft < 0) {
|
|
159
|
+
node.style.left = 0 + 'px'
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/*
|
|
164
|
+
my.mouseover = function (event, html) {
|
|
165
|
+
if (html) my.html(html);
|
|
166
|
+
my.setPosition(event);
|
|
167
|
+
my.show()
|
|
168
|
+
//this.ensureTooltipInsideContainer();
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
my.mousemove = function (event) {
|
|
172
|
+
my.setPosition(event);
|
|
173
|
+
//this.ensureTooltipInsideContainer();
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
my.mouseout = function () {
|
|
177
|
+
my.hide();
|
|
178
|
+
};*/
|
|
179
|
+
|
|
180
|
+
style(k, v) {
|
|
181
|
+
if (arguments.length == 1) return this.tooltip.style(k)
|
|
182
|
+
this.tooltip.style(k, v)
|
|
183
|
+
return this
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
attr(k, v) {
|
|
187
|
+
if (arguments.length == 1) return this.tooltip.attr(k)
|
|
188
|
+
this.tooltip.attr(k, v)
|
|
189
|
+
return this
|
|
190
|
+
}
|
|
191
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,79 +1,82 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
// the application
|
|
5
|
-
export { Map } from './core/Map.js'
|
|
6
|
-
export { GeoCanvas } from './core/GeoCanvas.js'
|
|
7
|
-
export { Style } from './core/Style.js'
|
|
8
|
-
export { Layer } from './core/Layer.js'
|
|
9
|
-
export { Dataset } from './core/Dataset.js'
|
|
10
|
-
export { MultiResolutionDataset } from './core/MultiResolutionDataset.js'
|
|
11
|
-
|
|
12
|
-
// export dataset types
|
|
13
|
-
export { TiledGrid } from './dataset/TiledGrid.js'
|
|
14
|
-
export { CSVGrid } from './dataset/CSVGrid.js'
|
|
15
|
-
export { JSGrid } from './dataset/JSGrid.js'
|
|
16
|
-
|
|
17
|
-
// export styles
|
|
18
|
-
export { ShapeColorSizeStyle } from './style/ShapeColorSizeStyle.js'
|
|
19
|
-
export { StrokeStyle } from './style/StrokeStyle.js'
|
|
20
|
-
export { JoyPlotStyle } from './style/JoyPlotStyle.js'
|
|
21
|
-
export { CompositionStyle } from './style/CompositionStyle.js'
|
|
22
|
-
export { SegmentStyle } from './style/SegmentStyle.js'
|
|
23
|
-
export { TextStyle } from './style/TextStyle.js'
|
|
24
|
-
export { PillarStyle } from './style/PillarStyle.js'
|
|
25
|
-
export { SideStyle } from './style/SideStyle.js'
|
|
26
|
-
export { ShadingRayStyle } from './style/ShadingRayStyle.js'
|
|
27
|
-
export { ShadingStyle } from './style/ShadingStyle.js'
|
|
28
|
-
export { SideCategoryStyle } from './style/SideCategoryStyle.js'
|
|
29
|
-
export { DotDensityStyle } from './style/DotDensityStyle.js'
|
|
30
|
-
export { SideTanakaStyle } from './style/SideTanakaStyle.js'
|
|
31
|
-
export { LegoStyle } from './style/LegoStyle.js'
|
|
32
|
-
export { SquareColorWebGLStyle } from './style/SquareColorWebGLStyle.js'
|
|
33
|
-
export { SquareColorCategoryWebGLStyle } from './style/SquareColorCategoryWebGLStyle.js'
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export
|
|
44
|
-
export {
|
|
45
|
-
export {
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export
|
|
52
|
-
export {
|
|
53
|
-
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export
|
|
65
|
-
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
// the application
|
|
5
|
+
export { Map } from './core/Map.js'
|
|
6
|
+
export { GeoCanvas } from './core/GeoCanvas.js'
|
|
7
|
+
export { Style } from './core/Style.js'
|
|
8
|
+
export { Layer } from './core/Layer.js'
|
|
9
|
+
export { Dataset } from './core/Dataset.js'
|
|
10
|
+
export { MultiResolutionDataset } from './core/MultiResolutionDataset.js'
|
|
11
|
+
|
|
12
|
+
// export dataset types
|
|
13
|
+
export { TiledGrid } from './dataset/TiledGrid.js'
|
|
14
|
+
export { CSVGrid } from './dataset/CSVGrid.js'
|
|
15
|
+
export { JSGrid } from './dataset/JSGrid.js'
|
|
16
|
+
|
|
17
|
+
// export styles
|
|
18
|
+
export { ShapeColorSizeStyle } from './style/ShapeColorSizeStyle.js'
|
|
19
|
+
export { StrokeStyle } from './style/StrokeStyle.js'
|
|
20
|
+
export { JoyPlotStyle } from './style/JoyPlotStyle.js'
|
|
21
|
+
export { CompositionStyle } from './style/CompositionStyle.js'
|
|
22
|
+
export { SegmentStyle } from './style/SegmentStyle.js'
|
|
23
|
+
export { TextStyle } from './style/TextStyle.js'
|
|
24
|
+
export { PillarStyle } from './style/PillarStyle.js'
|
|
25
|
+
export { SideStyle } from './style/SideStyle.js'
|
|
26
|
+
export { ShadingRayStyle } from './style/ShadingRayStyle.js'
|
|
27
|
+
export { ShadingStyle } from './style/ShadingStyle.js'
|
|
28
|
+
export { SideCategoryStyle } from './style/SideCategoryStyle.js'
|
|
29
|
+
export { DotDensityStyle } from './style/DotDensityStyle.js'
|
|
30
|
+
export { SideTanakaStyle } from './style/SideTanakaStyle.js'
|
|
31
|
+
export { LegoStyle } from './style/LegoStyle.js'
|
|
32
|
+
export { SquareColorWebGLStyle } from './style/SquareColorWebGLStyle.js'
|
|
33
|
+
export { SquareColorCategoryWebGLStyle } from './style/SquareColorCategoryWebGLStyle.js'
|
|
34
|
+
export { CircleColorSizeWebGLStyle } from './style/CircleColorSizeWebGLStyle.js'
|
|
35
|
+
export { MosaicStyle } from './style/MosaicStyle.js'
|
|
36
|
+
export { NinjaStarStyle } from './style/NinjaStarStyle.js'
|
|
37
|
+
export { TimeSeriesStyle } from './style/TimeSeriesStyle.js'
|
|
38
|
+
export { IsoFenceStyle } from './style/IsoFenceStyle.js'
|
|
39
|
+
export { ImageStyle } from './style/ImageStyle.js'
|
|
40
|
+
export { Interpolator } from './style/Interpolator.js'
|
|
41
|
+
export { RandomWalkInterpolator } from './style/RandomWalkInterpolator.js'
|
|
42
|
+
|
|
43
|
+
// export additional layers
|
|
44
|
+
export { GridLayer } from './layer/GridLayer.js'
|
|
45
|
+
export { BackgroundLayer } from './layer/BackgroundLayer.js'
|
|
46
|
+
export { BackgroundLayerWMS } from './layer/BackgroundLayerWMS.js'
|
|
47
|
+
export { BackgroundLayerImage } from './layer/BackgroundLayerImage.js'
|
|
48
|
+
export { LabelLayer } from './layer/LabelLayer.js'
|
|
49
|
+
export { GeoJSONLayer } from './layer/GeoJSONLayer.js'
|
|
50
|
+
|
|
51
|
+
// export legends
|
|
52
|
+
export { ColorLegend } from './legend/ColorLegend.js'
|
|
53
|
+
export { ColorDiscreteLegend } from './legend/ColorDiscreteLegend.js'
|
|
54
|
+
export { ColorCategoryLegend } from './legend/ColorCategoryLegend.js'
|
|
55
|
+
export {
|
|
56
|
+
SizeLegend,
|
|
57
|
+
sizeLegend,
|
|
58
|
+
sizeLegendViewScale,
|
|
59
|
+
sizeDiscreteLegend,
|
|
60
|
+
sizeDiscreteViewScaleLegend,
|
|
61
|
+
} from './legend/SizeLegend.js'
|
|
62
|
+
export { OrientationLegend, orientationLegend } from './legend/OrientationLegend.js'
|
|
63
|
+
export { TernaryLegend } from './legend/TernaryLegend.js'
|
|
64
|
+
export { VennLegend } from './legend/VennLegend.js'
|
|
65
|
+
|
|
66
|
+
// export { goToStraight, zoomTo } from "./utils/zoomUtils"
|
|
67
|
+
export * from './utils/stretching.js'
|
|
68
|
+
export * from './utils/scale.js'
|
|
69
|
+
export * from './utils/ternary.js'
|
|
70
|
+
export { nice, cellsToMatrix } from './utils/utils.js'
|
|
71
|
+
|
|
72
|
+
import { GeoCanvas } from './core/GeoCanvas.js'
|
|
73
|
+
export const getParameterByName = GeoCanvas.getParameterByName
|
|
74
|
+
|
|
75
|
+
// set default d3 locale
|
|
76
|
+
import { formatDefaultLocale } from 'd3-format'
|
|
77
|
+
formatDefaultLocale({
|
|
78
|
+
decimal: '.',
|
|
79
|
+
thousands: ' ',
|
|
80
|
+
grouping: [3],
|
|
81
|
+
currency: ['', '€'],
|
|
82
|
+
})
|
package/src/layer/GridLayer.js
CHANGED
|
@@ -106,7 +106,7 @@ export class GridLayer extends Layer {
|
|
|
106
106
|
for (const s of this.styles) {
|
|
107
107
|
//check if style is visible
|
|
108
108
|
if (!isVisibleAt(s, z)) continue
|
|
109
|
-
GridLayer.addLegends(legend, s.legends, s, geoCanvas)
|
|
109
|
+
GridLayer.addLegends(legend, s.legends, s, geoCanvas, this.styles)
|
|
110
110
|
|
|
111
111
|
//case for styles of styles, like kernel smoothing
|
|
112
112
|
//TODO do better
|
|
@@ -132,11 +132,12 @@ export class GridLayer extends Layer {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/** @private */
|
|
135
|
-
static addLegends(legendComp, lg, style, geoCanvas) {
|
|
136
|
-
if (Array.isArray(lg)) for (const lg_ of lg) this.addLegends(legendComp, lg_, style, geoCanvas)
|
|
135
|
+
static addLegends(legendComp, lg, style, geoCanvas, layerStyles) {
|
|
136
|
+
if (Array.isArray(lg)) for (const lg_ of lg) this.addLegends(legendComp, lg_, style, geoCanvas, layerStyles)
|
|
137
137
|
else {
|
|
138
138
|
// so that hovering a swatch can highlight the cells of the style on the map
|
|
139
139
|
lg.style_ = style
|
|
140
|
+
lg.layerStyles = layerStyles
|
|
140
141
|
lg.redraw = () => (geoCanvas.redraw ? geoCanvas.redraw() : undefined)
|
|
141
142
|
// The legends go in the order they are drawn, after the one placed before them. A hovered legend is
|
|
142
143
|
// still in the container (see Map.redrawNow) and is left where it is: moving it would lose its mouseleave,
|
package/src/layer/LabelLayer.js
CHANGED
|
@@ -110,14 +110,17 @@ export class LabelLayer extends Layer {
|
|
|
110
110
|
geoCanvas.initCanvasTransform()
|
|
111
111
|
|
|
112
112
|
//draw labels, one by one
|
|
113
|
+
//The font, the colors... are not set again when they do not change from a label to the next one: the browser parses
|
|
114
|
+
//them at each assignment, which is slow.
|
|
115
|
+
let font
|
|
113
116
|
for (const lb of this.labels) {
|
|
117
|
+
//check label within the view, to be drawn. First: there are many labels (180000 for Europe), a few are in the view.
|
|
118
|
+
if (!geoCanvas.toDraw(lb)) continue
|
|
119
|
+
|
|
114
120
|
//get label style
|
|
115
121
|
const st = this.style(lb, z)
|
|
116
122
|
if (!st) continue
|
|
117
|
-
ctx.font = st
|
|
118
|
-
|
|
119
|
-
//check label within the view, to be drawn
|
|
120
|
-
if (!geoCanvas.toDraw(lb)) continue
|
|
123
|
+
if (st !== font) ctx.font = font = st
|
|
121
124
|
|
|
122
125
|
//position
|
|
123
126
|
const xP = geoCanvas.geoToPixX(lb.x) + this.offsetPix[0]
|