gridviz 3.0.1 → 3.0.2

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.
Files changed (54) hide show
  1. package/README.md +36 -33
  2. package/dist/gridviz.js +434 -183
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +4 -3
  5. package/src/button/Button.js +1 -0
  6. package/src/button/FullscreenButton.js +1 -0
  7. package/src/button/ZoomButtons.js +1 -0
  8. package/src/core/Dataset.js +1 -0
  9. package/src/core/Drawable.js +1 -0
  10. package/src/core/GeoCanvas.js +1 -0
  11. package/src/core/Layer.js +1 -0
  12. package/src/core/Legend.js +1 -0
  13. package/src/core/Map.js +1 -0
  14. package/src/core/MultiResolutionDataset.js +1 -0
  15. package/src/core/Style.js +10 -1
  16. package/src/core/Tooltip.js +1 -0
  17. package/src/dataset/COGeo.js +1 -0
  18. package/src/dataset/CSVGrid.js +1 -0
  19. package/src/dataset/GeoTIFF.js +1 -0
  20. package/src/dataset/JSGrid.js +1 -0
  21. package/src/dataset/TiledGrid.js +1 -0
  22. package/src/index.js +2 -2
  23. package/src/layer/BackgroundLayer.js +1 -0
  24. package/src/layer/BackgroundLayerWMS.js +1 -0
  25. package/src/layer/GeoJSONLayer.js +1 -0
  26. package/src/layer/GridLayer.js +1 -0
  27. package/src/layer/LabelLayer.js +1 -0
  28. package/src/legend/ColorCategoryLegend.js +1 -0
  29. package/src/legend/ColorDiscreteLegend.js +2 -0
  30. package/src/legend/ColorLegend.js +1 -0
  31. package/src/legend/OrientationLegend.js +1 -0
  32. package/src/legend/SizeLegend.js +4 -2
  33. package/src/style/CompositionStyle.js +1 -0
  34. package/src/style/ContourStyle.js +1 -0
  35. package/src/style/DotDensityStyle.js +1 -0
  36. package/src/style/IsoFenceStyle.js +24 -72
  37. package/src/style/JoyPlotStyle.js +1 -1
  38. package/src/style/LegoStyle.js +22 -24
  39. package/src/style/MosaicStyle.js +1 -0
  40. package/src/style/NinjaStarStyle.js +1 -1
  41. package/src/style/PillarStyle.js +1 -0
  42. package/src/style/SegmentStyle.js +1 -0
  43. package/src/style/ShapeColorSizeStyle.js +1 -0
  44. package/src/style/SideCategoryStyle.js +1 -0
  45. package/src/style/SideStyle.js +51 -28
  46. package/src/style/SquareColorCategoryWebGLStyle.js +4 -3
  47. package/src/style/SquareColorWebGLStyle.js +1 -0
  48. package/src/style/StrokeStyle.js +1 -1
  49. package/src/style/TanakaStyle.js +11 -5
  50. package/src/style/TextStyle.js +1 -1
  51. package/src/style/TimeSeriesStyle.js +1 -0
  52. package/src/utils/scale.js +22 -11
  53. package/src/utils/stretching.js +4 -0
  54. package/src/utils/utils.js +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridviz",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
@@ -40,7 +40,7 @@
40
40
  "start": "export NODE_OPTIONS=--openssl-legacy-provider && webpack --config webpack.config.dev.cjs",
41
41
  "start-dev": "webpack --config webpack.config.dev.cjs",
42
42
  "server": "webpack serve -c webpack.config.dev.cjs",
43
- "doc": "./node_modules/.bin/jsdoc src/ src/dataset src/legend src/style -d docs/jsdoc",
43
+ "doc": "./node_modules/.bin/jsdoc -c docs/jsdoc/jsdoc.conf.json",
44
44
  "bp": "webpack --config webpack.config.prod.cjs",
45
45
  "test": "jest"
46
46
  },
@@ -55,7 +55,8 @@
55
55
  "d3-random": "^3.0.1",
56
56
  "d3-scale": "^4.0.2",
57
57
  "d3-selection": "^3.0.0",
58
- "d3-zoom": "^3.0.0"
58
+ "d3-zoom": "^3.0.0",
59
+ "jsdoc": "^4.0.2"
59
60
  },
60
61
  "devDependencies": {
61
62
  "@babel/core": "^7.9.0",
@@ -3,6 +3,7 @@ import { select } from 'd3-selection'
3
3
  /**
4
4
  * Parent class for button elements used to interact with the gridviz viewer.
5
5
  *
6
+ * @module button
6
7
  * @author Joseph Davies, Julien Gaffuri
7
8
  */
8
9
  export class Button {
@@ -3,6 +3,7 @@ import { Button } from './Button.js'
3
3
  /**
4
4
  * Button for toggling fullscreen mode
5
5
  *
6
+ * @module button
6
7
  * @author Joseph Davies, Julien Gaffuri
7
8
  */
8
9
  export class FullscreenButton extends Button {
@@ -3,6 +3,7 @@ import { Button } from './Button.js'
3
3
  /**
4
4
  * Button for toggling fullscreen mode
5
5
  *
6
+ * @module button
6
7
  * @author Joseph Davies, Julien Gaffuri
7
8
  */
8
9
  export class ZoomButtons extends Button {
@@ -9,6 +9,7 @@
9
9
  * A dataset component, of grid cells.
10
10
  * @abstract
11
11
  *
12
+ * @module core
12
13
  * @author Joseph Davies, Julien Gaffuri
13
14
  */
14
15
  export class Dataset {
@@ -5,6 +5,7 @@
5
5
  * This is an abstract class used to group elements shared between Layer and Style classes.
6
6
  *
7
7
  * @abstract
8
+ * @module core
8
9
  * @author Joseph Davies, Julien Gaffuri
9
10
  */
10
11
  export class Drawable {
@@ -13,6 +13,7 @@ import { zoom as d3zoom, zoomIdentity } from 'd3-zoom'
13
13
  /**
14
14
  * A HTML canvas for geo data display, enhanced with zoom and pan capabilities.
15
15
  *
16
+ * @module core
16
17
  * @author Joseph Davies, Julien Gaffuri
17
18
  */
18
19
  export class GeoCanvas {
package/src/core/Layer.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { Drawable } from "./Drawable.js"
5
5
 
6
6
  /**
7
+ * @module core
7
8
  * @abstract
8
9
  * @author Joseph Davies, Julien Gaffuri
9
10
  */
@@ -6,6 +6,7 @@ import { select } from 'd3-selection'
6
6
  /**
7
7
  * A legend container.
8
8
  *
9
+ * @module core
9
10
  * @author Joseph Davies, Julien Gaffuri
10
11
  */
11
12
  export class Legend {
package/src/core/Map.js CHANGED
@@ -13,6 +13,7 @@ import { select } from 'd3-selection'
13
13
  /**
14
14
  * A gridviz application.
15
15
  *
16
+ * @module core
16
17
  * @author Joseph Davies, Julien Gaffuri
17
18
  */
18
19
  export class Map {
@@ -7,6 +7,7 @@
7
7
  *
8
8
  * @abstract
9
9
  *
10
+ * @module core
10
11
  * @author Joseph Davies, Julien Gaffuri
11
12
  */
12
13
  export class MultiResolutionDataset {
package/src/core/Style.js CHANGED
@@ -13,6 +13,7 @@ import { Drawable } from "./Drawable.js"
13
13
  /**
14
14
  * A style, to show a grid dataset.
15
15
  *
16
+ * @module core
16
17
  * @author Joseph Davies, Julien Gaffuri
17
18
  */
18
19
  export class Style extends Drawable {
@@ -73,7 +74,7 @@ export class Style extends Drawable {
73
74
  return this
74
75
  }
75
76
 
76
- /** Hide all legend elements of the style, if any
77
+ /** Update legends of the style, if any
77
78
  * @param {object} opts
78
79
  * @returns {this} */
79
80
  updateLegends(opts) {
@@ -81,4 +82,12 @@ export class Style extends Drawable {
81
82
  return this
82
83
  }
83
84
 
85
+ /**
86
+ * @param {Array.<import("./Legend").Legend>} legends
87
+ * @returns {this} */
88
+ addLegends(legends) {
89
+ for (let legend of legends)
90
+ this.legends.push(legend)
91
+ return this
92
+ }
84
93
  }
@@ -7,6 +7,7 @@ import { select } from 'd3-selection'
7
7
  /**
8
8
  * A generic class to make a tooltip.
9
9
  * It is a div element, which can be moved under the mouse pointer and filled with some information in html.
10
+ * @module core
10
11
  */
11
12
  export class Tooltip {
12
13
  /**
@@ -8,6 +8,7 @@ import { Dataset } from '../core/Dataset.js'
8
8
  * A dataset composed of a COGeo file.
9
9
  * @see https://www.cogeo.org/
10
10
  *
11
+ * @module dataset
11
12
  * @author Joseph Davies, Julien Gaffuri
12
13
  */
13
14
  export class COGeo extends Dataset {
@@ -9,6 +9,7 @@ import { Dataset } from '../core/Dataset.js'
9
9
  /**
10
10
  * A dataset composed of a single CSV file (not tiled).
11
11
  *
12
+ * @module dataset
12
13
  * @author Joseph Davies, Julien Gaffuri
13
14
  */
14
15
  export class CSVGrid extends Dataset {
@@ -8,6 +8,7 @@ import { Dataset } from '../core/Dataset.js'
8
8
  * @todo
9
9
  * A dataset composed of a single GeoTiff file.
10
10
  *
11
+ * @module dataset
11
12
  * @author Joseph Davies, Julien Gaffuri
12
13
  */
13
14
  export class GeoTIFF extends Dataset {
@@ -6,6 +6,7 @@ import { Dataset } from '../core/Dataset.js'
6
6
  /**
7
7
  * A dataset composed of cells defined in javascript, or loaded outside of gridviz map.
8
8
  *
9
+ * @module dataset
9
10
  * @author Joseph Davies, Julien Gaffuri
10
11
  */
11
12
  export class JSGrid extends Dataset {
@@ -13,6 +13,7 @@ import { json, csv } from 'd3-fetch'
13
13
  /**
14
14
  * A tiled dataset, composed of CSV tiles.
15
15
  *
16
+ * @module dataset
16
17
  * @author Joseph Davies, Julien Gaffuri
17
18
  */
18
19
  export class TiledGrid extends Dataset {
package/src/index.js CHANGED
@@ -25,8 +25,8 @@ export { SideStyle } from './style/SideStyle.js'
25
25
  //export { ContourStyle } from './style/ContourStyle.js'
26
26
  export { SideCategoryStyle } from './style/SideCategoryStyle.js'
27
27
  export { DotDensityStyle } from './style/DotDensityStyle.js'
28
- //export { TanakaStyle } from './style/TanakaStyle.js'
29
- //export { LegoStyle } from './style/LegoStyle.js'
28
+ export { TanakaStyle } from './style/TanakaStyle.js'
29
+ export { LegoStyle } from './style/LegoStyle.js'
30
30
  export { SquareColorWebGLStyle } from './style/SquareColorWebGLStyle.js'
31
31
  export { SquareColorCategoryWebGLStyle } from './style/SquareColorCategoryWebGLStyle.js'
32
32
  export { MosaicStyle } from './style/MosaicStyle.js'
@@ -9,6 +9,7 @@ import { Layer } from '../core/Layer.js'
9
9
  * See https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
10
10
  * https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/#6/27.88/44.48
11
11
  *
12
+ * @module layer
12
13
  * @author Julien Gaffuri
13
14
  */
14
15
  export class BackgroundLayer extends Layer {
@@ -7,6 +7,7 @@ import { Layer } from '../core/Layer.js'
7
7
  *
8
8
  * A map WMS background layer.
9
9
  *
10
+ * @module layer
10
11
  * @author Julien Gaffuri
11
12
  */
12
13
  export class BackgroundLayerWMS extends Layer {
@@ -5,6 +5,7 @@ import { Layer } from '../core/Layer.js'
5
5
  import { json } from 'd3-fetch'
6
6
 
7
7
  /**
8
+ * @module layer
8
9
  * @author Joseph Davies, Julien Gaffuri
9
10
  */
10
11
  export class GeoJSONLayer extends Layer {
@@ -6,6 +6,7 @@ import { Layer } from '../core/Layer.js'
6
6
  /**
7
7
  * A layer, which specifies a dataset to be shown with specified styles.
8
8
  *
9
+ * @module layer
9
10
  * @author Joseph Davies, Julien Gaffuri
10
11
  */
11
12
  export class GridLayer extends Layer {
@@ -13,6 +13,7 @@ import { csv } from 'd3-fetch'
13
13
  * If the label data is not in the expected format or in the same CRS as the grid, it can be corrected with the "preprocess" function.
14
14
  * The selection of the label, their style (font, weight, etc.) and color can be specified depending on their importance and the zoom level.
15
15
  *
16
+ * @module layer
16
17
  * @author Joseph Davies, Julien Gaffuri
17
18
  */
18
19
  export class LabelLayer extends Layer {
@@ -6,6 +6,7 @@ import { Legend } from '../core/Legend.js'
6
6
  /**
7
7
  * A legend element for color categrories.
8
8
  *
9
+ * @module legend
9
10
  * @author Joseph Davies, Julien Gaffuri
10
11
  */
11
12
  export class ColorCategoryLegend extends Legend {
@@ -7,6 +7,7 @@ import { Legend } from '../core/Legend.js'
7
7
  * A legend element for discrete color style.
8
8
  * Inspiration: https://observablehq.com/@d3/color-legend
9
9
  *
10
+ * @module legend
10
11
  * @author Julien Gaffuri
11
12
  */
12
13
  export class ColorDiscreteLegend extends Legend {
@@ -43,6 +44,7 @@ export class ColorDiscreteLegend extends Legend {
43
44
  //get colors and breaks
44
45
  const colors = this.colors(opts.viewScale)
45
46
  const breaks = this.breaks(opts.viewScale)
47
+ if (!breaks) return
46
48
 
47
49
  //classes
48
50
  const nb = colors.length
@@ -7,6 +7,7 @@ import { Legend } from '../core/Legend.js'
7
7
  * A legend element for continuous color style.
8
8
  * Inspiration: https://observablehq.com/@d3/color-legend
9
9
  *
10
+ * @module legend
10
11
  * @author Joseph Davies, Julien Gaffuri
11
12
  */
12
13
  export class ColorLegend extends Legend {
@@ -6,6 +6,7 @@ import { Legend } from '../core/Legend.js'
6
6
  /**
7
7
  * A legend element for segment orientation.
8
8
  *
9
+ * @module legend
9
10
  * @author Joseph Davies, Julien Gaffuri
10
11
  */
11
12
  export class OrientationLegend extends Legend {
@@ -8,6 +8,7 @@ import { max } from 'd3-array'
8
8
  /**
9
9
  * A legend element for proportional symbols.
10
10
  *
11
+ * @module legend
11
12
  * @author Joseph Davies, Julien Gaffuri
12
13
  */
13
14
  export class SizeLegend extends Legend {
@@ -198,10 +199,11 @@ export function sizeDiscreteViewScaleLegend(classNumber, opts = {}) {
198
199
  const f = opts.labelFormat || (x => x)
199
200
  const labelText = opts.labelText || defaultLabelText(f)
200
201
  const legends = []
202
+ const viewScaleFun = opts.viewScaleFun || (t => t) //TODO do it differently? At sizelegend level !
201
203
  for (let i = classNumber - 1; i >= 0; i--) {
202
204
  opts.title = i == classNumber - 1 ? opts.title : undefined
203
- opts.size = (viewScale) => viewScale.values[i]
204
- opts.label = (viewScale) => labelText(viewScale.breaks[i - 1], viewScale.breaks[i])
205
+ opts.size = (viewScale) => viewScaleFun(viewScale).values[i]
206
+ opts.label = (viewScale) => labelText(viewScaleFun(viewScale).breaks[i - 1], viewScaleFun(viewScale).breaks[i])
205
207
  legends.push(new SizeLegend(opts))
206
208
  }
207
209
  return legends
@@ -11,6 +11,7 @@ import { Style } from '../core/Style.js'
11
11
  * For a list of supported symbols, @see CompositionType
12
12
  * The symbol can be scaled depending on the cell importance.
13
13
  *
14
+ * @module style
14
15
  * @author Julien Gaffuri
15
16
  */
16
17
  export class CompositionStyle extends Style {
@@ -7,6 +7,7 @@ import { SideStyle } from './SideStyle.js'
7
7
 
8
8
  /**
9
9
  *
10
+ * @module style
10
11
  * @author Julien Gaffuri
11
12
  */
12
13
  export class ContourStyle extends SideStyle {
@@ -9,6 +9,7 @@ import { color } from 'd3-color'
9
9
 
10
10
  /**
11
11
  *
12
+ * @module style
12
13
  * @author Julien Gaffuri
13
14
  */
14
15
  export class DotDensityStyle extends Style {
@@ -7,6 +7,7 @@ import { SideStyle } from './SideStyle.js'
7
7
  /** @typedef {{x:number,y:number,or:"v"|"h",c1:import('../core/Dataset.js').Cell|undefined,c2:import('../core/Dataset.js').Cell|undefined}} Side */
8
8
 
9
9
  /**
10
+ * @module style
10
11
  * @author Julien Gaffuri
11
12
  */
12
13
  export class IsoFenceStyle extends Style {
@@ -77,57 +78,7 @@ export class IsoFenceStyle extends Style {
77
78
 
78
79
  //make sides
79
80
  /** @type {Array.<Side>} */
80
- const sides = SideStyle.buildSides(cells, resolution, this.angle % 180 != 90 && this.sVert, this.angle % 180 != 0 && this.sHor, true)
81
-
82
-
83
-
84
- /*const sides = []
85
-
86
- //make horizontal sides - except when angle%180=0
87
- //sort cells by x and y
88
- if (this.angle % 180 != 90 && this.sVert) {
89
- cells.sort((c1, c2) => (c2.x == c1.x ? c1.y - c2.y : c1.x - c2.x))
90
- let c1 = cells[0]
91
- for (let i = 1; i < cells.length; i++) {
92
- let c2 = cells[i]
93
-
94
- if ((c1.y + resolution == c2.y) && (c1.x == c2.x))
95
- //cells in same column and touch along horizontal side
96
- //make shared side
97
- sides.push({ x: c1.x + r2, y: c2.y, or: 'h', c1: c1, c2: c2 })
98
- else {
99
- //cells do not touch along horizontal side
100
- //make two sides: top one for c1, bottom for c2
101
- sides.push({ x: c1.x + r2, y: c1.y + resolution, or: 'h', c1: c1, c2: undefined })
102
- sides.push({ x: c2.x + r2, y: c2.y, or: 'h', c1: undefined, c2: c2 })
103
- }
104
-
105
- c1 = c2
106
- }
107
- }
108
-
109
- //make vertical sides - except when angle%180=90
110
- //sort cells by y and x
111
- if (this.angle % 180 != 0 && this.sHor) {
112
- cells.sort((c1, c2) => (c2.y == c1.y ? c1.x - c2.x : c1.y - c2.y))
113
- let c1 = cells[0]
114
- for (let i = 1; i < cells.length; i++) {
115
- let c2 = cells[i]
116
-
117
- if ((c1.x + resolution == c2.x) && (c1.y == c2.y))
118
- //cells in same row and touch along vertical side
119
- //make shared side
120
- sides.push({ x: c2.x, y: c1.y + r2, or: 'v', c1: c1, c2: c2 })
121
- else {
122
- //cells do not touch along vertical side
123
- //make two sides: right one for c1, left for c2
124
- sides.push({ x: c1.x + resolution, y: c1.y + r2, or: 'v', c1: c1, c2: undefined })
125
- sides.push({ x: c2.x, y: c2.y + r2, or: 'v', c1: undefined, c2: c2 })
126
- }
127
-
128
- c1 = c2
129
- }
130
- }*/
81
+ const sides = SideStyle.buildSides(cells, resolution, this.angle % 180 != 90 && this.sVert, this.angle % 180 != 0 && this.sHor)
131
82
 
132
83
  //
133
84
  if (sides.length == 0) return
@@ -163,15 +114,16 @@ export class IsoFenceStyle extends Style {
163
114
 
164
115
  //draw sides
165
116
  geoCanvas.ctx.lineCap = "round";
166
- for (let s of sides) {
117
+ for (let side of sides) {
118
+ const c1 = side.c1, c2 = side.c2, x = side.x, y = side.y
167
119
 
168
120
  //heights - in geo
169
- const hG1 = s.c1 ? this.height(s.c1, resolution, z, viewScale) : 0,
170
- hG2 = s.c2 ? this.height(s.c2, resolution, z, viewScale) : 0
121
+ const hG1 = c1 ? this.height(c1, resolution, z, viewScale) : 0,
122
+ hG2 = c2 ? this.height(c2, resolution, z, viewScale) : 0
171
123
 
172
124
  //compute totals for both cells
173
- const total1 = computeTotal(s.c1, cats),
174
- total2 = computeTotal(s.c2, cats)
125
+ const total1 = computeTotal(c1, cats),
126
+ total2 = computeTotal(c2, cats)
175
127
  if (total1 == 0 && total2 == 0) continue
176
128
 
177
129
  let cumul1 = 0, cumul2 = 0
@@ -179,8 +131,8 @@ export class IsoFenceStyle extends Style {
179
131
  //draw stripe of side s and category column
180
132
 
181
133
  //get values for both cells
182
- let v1 = s.c1 ? +s.c1[column] : 0
183
- let v2 = s.c2 ? +s.c2[column] : 0
134
+ let v1 = c1 ? +c1[column] : 0
135
+ let v2 = c2 ? +c2[column] : 0
184
136
  if (v1 == 0 && v2 == 0) continue
185
137
 
186
138
  //compute heights
@@ -191,26 +143,26 @@ export class IsoFenceStyle extends Style {
191
143
 
192
144
  //make path
193
145
  geoCanvas.ctx.beginPath()
194
- if (s.or == "h") {
146
+ if (side.or == "h") {
195
147
  //horizontal side - vertical section
196
148
  //bottom left
197
- geoCanvas.ctx.moveTo(s.x + h1 * cos + dx, s.y - r2 + h1 * sin + dy)
149
+ geoCanvas.ctx.moveTo(x + h1 * cos + dx, y - r2 + h1 * sin + dy)
198
150
  //top left
199
- geoCanvas.ctx.lineTo(s.x + h2 * cos + dx, s.y + r2 + h2 * sin + dy)
151
+ geoCanvas.ctx.lineTo(x + h2 * cos + dx, y + r2 + h2 * sin + dy)
200
152
  //top right
201
- geoCanvas.ctx.lineTo(s.x + h2n * cos + dx, s.y + r2 + h2n * sin + dy)
153
+ geoCanvas.ctx.lineTo(x + h2n * cos + dx, y + r2 + h2n * sin + dy)
202
154
  //bottom right
203
- geoCanvas.ctx.lineTo(s.x + h1n * cos + dx, s.y - r2 + h1n * sin + dy)
155
+ geoCanvas.ctx.lineTo(x + h1n * cos + dx, y - r2 + h1n * sin + dy)
204
156
  } else {
205
157
  //vertical side - horizontal section
206
158
  //bottom left
207
- geoCanvas.ctx.moveTo(s.x - r2 + h1 * cos + dx, s.y + h1 * sin + dy)
159
+ geoCanvas.ctx.moveTo(x - r2 + h1 * cos + dx, y + h1 * sin + dy)
208
160
  //bottom right
209
- geoCanvas.ctx.lineTo(s.x + r2 + h2 * cos + dx, s.y + h2 * sin + dy)
161
+ geoCanvas.ctx.lineTo(x + r2 + h2 * cos + dx, y + h2 * sin + dy)
210
162
  //top right
211
- geoCanvas.ctx.lineTo(s.x + r2 + h2n * cos + dx, s.y + h2n * sin + dy)
163
+ geoCanvas.ctx.lineTo(x + r2 + h2n * cos + dx, y + h2n * sin + dy)
212
164
  //top left
213
- geoCanvas.ctx.lineTo(s.x - r2 + h1n * cos + dx, s.y + h1n * sin + dy)
165
+ geoCanvas.ctx.lineTo(x - r2 + h1n * cos + dx, y + h1n * sin + dy)
214
166
  }
215
167
  //cg.ctx.closePath()
216
168
 
@@ -223,11 +175,11 @@ export class IsoFenceStyle extends Style {
223
175
 
224
176
  //TODO draw only one line
225
177
  //draw corner line
226
- //if (s.or == "h") {
227
- drawCornerLine(s.c1)
228
- drawCornerLine(s.c2)
229
- //if (this.angle > 0 && s.or == "h") drawCornerLine(s.c2)
230
- //else drawCornerLine(s.c2)
178
+ //if (side.or == "h") {
179
+ drawCornerLine(c1)
180
+ drawCornerLine(c2)
181
+ //if (this.angle > 0 && side.or == "h") drawCornerLine(c2)
182
+ //else drawCornerLine(c2)
231
183
  //}
232
184
  }
233
185
  }
@@ -4,7 +4,7 @@
4
4
  import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
- *
7
+ * @module style
8
8
  * @author Julien Gaffuri
9
9
  */
10
10
  export class JoyPlotStyle extends Style {
@@ -7,21 +7,18 @@ import { SquareColorCategoryWebGLStyle } from './SquareColorCategoryWebGLStyle.j
7
7
  import { Style } from '../core/Style.js'
8
8
 
9
9
  /**
10
+ * @module style
10
11
  * @author Julien Gaffuri
11
12
  */
12
13
  export class LegoStyle {
13
- /**
14
- * @param {string} col
15
- * @param {object} opts
16
- * @returns {Array.<Style>}
17
- */
18
- static get(col, opts) {
14
+
15
+ static get(value, breaks, colors, opts = {}) {
19
16
  opts = opts || {}
20
17
 
21
18
  //the colors
22
19
  //http://www.jennyscrayoncollection.com/2021/06/all-current-lego-colors.html
23
20
  //https://leonawicz.github.io/legocolors/reference/figures/README-plot-1.png
24
- opts.colors = opts.colors || [
21
+ /*opts.colors = opts.colors || [
25
22
  '#00852b', //darker green
26
23
  '#afd246', //light green
27
24
  '#fac80a', //dark yellow
@@ -32,18 +29,18 @@ export class LegoStyle {
32
29
  '#720012', //dark red
33
30
  //"purple",
34
31
  //"#eee" //whithe
35
- ]
32
+ ]*/
36
33
 
37
34
  opts.colDark = opts.colDark || '#333'
38
35
  opts.colBright = opts.colBright || '#aaa'
39
36
  opts.widthFactor = opts.widthFactor || 0.12
40
37
 
41
38
  //reuse tanaka as basis
42
- const ts = TanakaStyle.get(col, opts)
39
+ const ts = TanakaStyle.get(value, breaks, colors, opts)
43
40
  //style to show limits between pieces
44
41
  const sst = new StrokeStyle({
45
42
  strokeColor: () => '#666',
46
- strokeWidth: (v, r, s, z) => 0.2 * z,
43
+ strokeWidth: (c, r, z) => 0.2 * z,
47
44
  filter: opts.filter,
48
45
  })
49
46
 
@@ -56,20 +53,21 @@ export class LegoStyle {
56
53
  }
57
54
 
58
55
  /**
59
- * @param {function(string):string} col
56
+ * @param {function(import('../core/Dataset.js').Cell):string} code
57
+ * @param {object} color
60
58
  * @param {object} opts
61
59
  * @returns {Array.<Style>}
62
60
  */
63
- static getCat(col, opts) {
61
+ static getCategory(code, color, opts) {
64
62
  opts = opts || {}
65
63
 
66
64
  opts.colDark = opts.colDark || '#333'
67
65
  opts.colBright = opts.colBright || '#aaa'
68
66
 
69
67
  //
70
- const s = new SquareColorCategoryWebGLStyle({ colorCol: col, color: opts.color })
68
+ const s = new SquareColorCategoryWebGLStyle({ code: code, color: color })
71
69
  //style to show limits between pieces
72
- const sst = new StrokeStyle({ strokeColor: () => '#666', strokeWidth: (v, r, s, z) => 0.2 * z })
70
+ const sst = new StrokeStyle({ strokeColor: () => '#666', strokeWidth: (c, r, z) => 0.2 * z })
73
71
 
74
72
  return [s, sst, new LegoTopStyle({ colDark: opts.colDark, colBright: opts.colBright })]
75
73
  }
@@ -87,26 +85,26 @@ class LegoTopStyle extends Style {
87
85
  this.colBright = opts.colBright || '#aaa'
88
86
  }
89
87
 
90
- draw(cells, r, cg) {
88
+ draw(cells, geoCanvas, r) {
91
89
  //filter
92
90
  if (this.filter) cells = cells.filter(this.filter)
93
91
 
94
- cg.ctx.lineWidth = 0.6 * cg.view.z
92
+ geoCanvas.ctx.lineWidth = 0.6 * geoCanvas.view.z
95
93
 
96
94
  //dark part
97
- cg.ctx.strokeStyle = this.colDark
95
+ geoCanvas.ctx.strokeStyle = this.colDark
98
96
  for (let c of cells) {
99
- cg.ctx.beginPath()
100
- cg.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), true)
101
- cg.ctx.stroke()
97
+ geoCanvas.ctx.beginPath()
98
+ geoCanvas.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), true)
99
+ geoCanvas.ctx.stroke()
102
100
  }
103
101
 
104
102
  //bright part
105
- cg.ctx.strokeStyle = this.colBright
103
+ geoCanvas.ctx.strokeStyle = this.colBright
106
104
  for (let c of cells) {
107
- cg.ctx.beginPath()
108
- cg.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), false)
109
- cg.ctx.stroke()
105
+ geoCanvas.ctx.beginPath()
106
+ geoCanvas.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), false)
107
+ geoCanvas.ctx.stroke()
110
108
  }
111
109
  }
112
110
  }
@@ -4,6 +4,7 @@
4
4
  import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
+ * @module style
7
8
  * @author Julien Gaffuri
8
9
  */
9
10
  export class MosaicStyle extends Style {
@@ -4,7 +4,7 @@
4
4
  import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
- *
7
+ * @module style
8
8
  * @author Joseph Davies, Julien Gaffuri
9
9
  */
10
10
  export class NinjaStarStyle extends Style {
@@ -4,6 +4,7 @@
4
4
  import { Style } from '../core/Style.js'
5
5
 
6
6
  /**
7
+ * @module style
7
8
  * @author Julien Gaffuri
8
9
  */
9
10
  export class PillarStyle extends Style {