gridviz 3.0.1 → 3.0.3
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 +36 -33
- package/dist/gridviz.js +1300 -200
- package/dist/gridviz.min.js +1 -1
- package/package.json +4 -3
- package/src/button/Button.js +1 -0
- package/src/button/FullscreenButton.js +1 -0
- package/src/button/ZoomButtons.js +1 -0
- package/src/core/Dataset.js +1 -0
- package/src/core/Drawable.js +1 -0
- package/src/core/GeoCanvas.js +1 -0
- package/src/core/Layer.js +1 -0
- package/src/core/Legend.js +1 -0
- package/src/core/Map.js +1 -0
- package/src/core/MultiResolutionDataset.js +1 -0
- package/src/core/Style.js +11 -2
- package/src/core/Tooltip.js +1 -0
- package/src/dataset/COGeo.js +1 -0
- package/src/dataset/CSVGrid.js +1 -0
- package/src/dataset/GeoTIFF.js +1 -0
- package/src/dataset/JSGrid.js +1 -0
- package/src/dataset/TiledGrid.js +1 -0
- package/src/index.js +7 -3
- package/src/layer/BackgroundLayer.js +1 -0
- package/src/layer/BackgroundLayerWMS.js +1 -0
- package/src/layer/GeoJSONLayer.js +1 -0
- package/src/layer/GridLayer.js +1 -0
- package/src/layer/LabelLayer.js +1 -0
- package/src/legend/ColorCategoryLegend.js +1 -0
- package/src/legend/ColorDiscreteLegend.js +2 -0
- package/src/legend/ColorLegend.js +1 -0
- package/src/legend/OrientationLegend.js +1 -0
- package/src/legend/SizeLegend.js +4 -2
- package/src/legend/TrivariateLegend.js +210 -0
- package/src/style/CompositionStyle.js +1 -0
- package/src/style/ContourStyle.js +1 -0
- package/src/style/DotDensityStyle.js +1 -0
- package/src/style/ImageStyle.js +81 -0
- package/src/style/IsoFenceStyle.js +24 -72
- package/src/style/JoyPlotStyle.js +1 -1
- package/src/style/LegoStyle.js +22 -24
- package/src/style/MosaicStyle.js +1 -0
- package/src/style/NinjaStarStyle.js +1 -1
- package/src/style/PillarStyle.js +3 -2
- package/src/style/SegmentStyle.js +2 -1
- package/src/style/ShapeColorSizeStyle.js +29 -0
- package/src/style/SideCategoryStyle.js +1 -0
- package/src/style/SideStyle.js +50 -27
- package/src/style/SquareColorCategoryWebGLStyle.js +4 -3
- package/src/style/SquareColorWebGLStyle.js +1 -0
- package/src/style/StrokeStyle.js +48 -16
- package/src/style/TanakaStyle.js +11 -5
- package/src/style/TextStyle.js +1 -1
- package/src/style/TimeSeriesStyle.js +1 -0
- package/src/utils/chernoff.js +14 -0
- package/src/utils/scale.js +22 -11
- package/src/utils/stretching.js +4 -0
- package/src/utils/trivariate.js +203 -0
- package/src/utils/utils.js +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gridviz",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
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
|
|
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",
|
package/src/button/Button.js
CHANGED
package/src/core/Dataset.js
CHANGED
package/src/core/Drawable.js
CHANGED
package/src/core/GeoCanvas.js
CHANGED
package/src/core/Layer.js
CHANGED
package/src/core/Legend.js
CHANGED
package/src/core/Map.js
CHANGED
package/src/core/Style.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { Drawable } from "./Drawable.js"
|
|
5
5
|
|
|
6
|
-
/** @typedef {"square"|"circle"|"diamond"|"donut"|"none"} Shape */
|
|
6
|
+
/** @typedef {"square"|"circle"|"diamond"|"donut"|"triangle_up"|"triangle_down"|"triangle_left"|"triangle_right"|"none"} Shape */
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* viewScale type
|
|
@@ -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
|
-
/**
|
|
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
|
}
|
package/src/core/Tooltip.js
CHANGED
package/src/dataset/COGeo.js
CHANGED
package/src/dataset/CSVGrid.js
CHANGED
package/src/dataset/GeoTIFF.js
CHANGED
package/src/dataset/JSGrid.js
CHANGED
package/src/dataset/TiledGrid.js
CHANGED
package/src/index.js
CHANGED
|
@@ -25,14 +25,15 @@ 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
|
-
|
|
29
|
-
|
|
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'
|
|
33
33
|
export { NinjaStarStyle } from './style/NinjaStarStyle.js'
|
|
34
34
|
export { TimeSeriesStyle } from './style/TimeSeriesStyle.js'
|
|
35
35
|
export { IsoFenceStyle } from './style/IsoFenceStyle.js'
|
|
36
|
+
export { ImageStyle } from './style/ImageStyle.js'
|
|
36
37
|
|
|
37
38
|
// export additional layers
|
|
38
39
|
export { GridLayer } from './layer/GridLayer.js'
|
|
@@ -47,11 +48,14 @@ export { ColorDiscreteLegend } from './legend/ColorDiscreteLegend.js'
|
|
|
47
48
|
export { ColorCategoryLegend } from './legend/ColorCategoryLegend.js'
|
|
48
49
|
export { SizeLegend, sizeLegend, sizeLegendViewScale, sizeDiscreteLegend, sizeDiscreteViewScaleLegend } from './legend/SizeLegend.js'
|
|
49
50
|
export { OrientationLegend, orientationLegend } from './legend/OrientationLegend.js'
|
|
51
|
+
export { TrivariateLegend } from './legend/TrivariateLegend.js'
|
|
50
52
|
|
|
51
53
|
// export { goToStraight, zoomTo } from "./utils/zoomUtils"
|
|
52
54
|
export * from './utils/stretching.js'
|
|
53
55
|
export * from './utils/scale.js'
|
|
54
|
-
export
|
|
56
|
+
export * from './utils/trivariate.js'
|
|
57
|
+
export * from './utils/chernoff.js'
|
|
58
|
+
export { nice, loadImage } from './utils/utils.js'
|
|
55
59
|
|
|
56
60
|
import { GeoCanvas } from './core/GeoCanvas.js'
|
|
57
61
|
export const getParameterByName = GeoCanvas.getParameterByName
|
|
@@ -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 {
|
package/src/layer/GridLayer.js
CHANGED
package/src/layer/LabelLayer.js
CHANGED
|
@@ -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 {
|
|
@@ -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 {
|
package/src/legend/SizeLegend.js
CHANGED
|
@@ -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
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { select } from 'd3-selection'
|
|
5
|
+
import { Legend } from '../core/Legend.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @module legend
|
|
10
|
+
* @author Julien Gaffuri
|
|
11
|
+
*/
|
|
12
|
+
export class TrivariateLegend extends Legend {
|
|
13
|
+
/** @param {Object} opts */
|
|
14
|
+
constructor(opts) {
|
|
15
|
+
super(opts)
|
|
16
|
+
opts = opts || {}
|
|
17
|
+
|
|
18
|
+
//classifier
|
|
19
|
+
this.classifier = opts.classifier
|
|
20
|
+
|
|
21
|
+
this.width = opts.width || 150
|
|
22
|
+
this.selectionColor = this.selectionColor || "red"
|
|
23
|
+
this.tooltip = opts.tooltip
|
|
24
|
+
this.texts = opts.texts
|
|
25
|
+
|
|
26
|
+
this.leftText = opts.leftText || "Category 0"
|
|
27
|
+
this.topText = opts.topText || "Category 1"
|
|
28
|
+
this.rightText = opts.rightText || "Category 2"
|
|
29
|
+
|
|
30
|
+
this.centerCoefficient = opts.centerCoefficient || this.classifier.centerCoefficient
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {{} } opts
|
|
35
|
+
*/
|
|
36
|
+
update(opts) {
|
|
37
|
+
|
|
38
|
+
//clear
|
|
39
|
+
this.div.selectAll('*').remove()
|
|
40
|
+
|
|
41
|
+
//title
|
|
42
|
+
this.makeTitle()
|
|
43
|
+
|
|
44
|
+
const sqrt3over2 = 0.866025
|
|
45
|
+
const w = this.width, h = w * sqrt3over2
|
|
46
|
+
const classifier = this.classifier
|
|
47
|
+
const selectionColor = this.selectionColor
|
|
48
|
+
const selectionStrokeWidth = 0
|
|
49
|
+
const tt = this.tooltip
|
|
50
|
+
const texts = this.texts || {}
|
|
51
|
+
|
|
52
|
+
const padding = 2
|
|
53
|
+
const fontSize = 12
|
|
54
|
+
|
|
55
|
+
//make svg element
|
|
56
|
+
const svg = this.div
|
|
57
|
+
.append('svg')
|
|
58
|
+
.attr('width', w + selectionStrokeWidth)
|
|
59
|
+
.attr('height', h + 4 * padding + 2 * fontSize)
|
|
60
|
+
|
|
61
|
+
//top label
|
|
62
|
+
svg.append("text").attr("x", w / 2).attr("y", padding + fontSize).text(this.topText).attr("font-size", fontSize)
|
|
63
|
+
.attr("text-anchor", "middle")
|
|
64
|
+
//left label
|
|
65
|
+
svg.append("text").attr("x", 0).attr("y", 3 * padding + 2 * fontSize + h).text(this.leftText).attr("font-size", fontSize)
|
|
66
|
+
.attr("text-anchor", "start")
|
|
67
|
+
//right label
|
|
68
|
+
svg.append("text").attr("x", w).attr("y", 3 * padding + 2 * fontSize + h).text(this.rightText).attr("font-size", fontSize)
|
|
69
|
+
.attr("text-anchor", "end")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
//triangle group
|
|
74
|
+
const g = svg.append("g").attr("transform", "translate(" + (selectionStrokeWidth / 2) + " " + (selectionStrokeWidth / 2 + (2 * padding + fontSize)) + ")")
|
|
75
|
+
|
|
76
|
+
//common function for triangle patches
|
|
77
|
+
const setAttributes = (elt, color, text) => {
|
|
78
|
+
//elt.raise();
|
|
79
|
+
elt.attr('fill', color)
|
|
80
|
+
//.attr("stroke", colorOver)
|
|
81
|
+
//.attr("stroke-width", 0)
|
|
82
|
+
//.attr("stroke-linejoin", "round")
|
|
83
|
+
.on("mouseover", function (e) {
|
|
84
|
+
/*this.parentNode.appendChild(this); select(this).attr("stroke-width", selectionStrokeWidth);*/
|
|
85
|
+
select(this).attr('fill', selectionColor);
|
|
86
|
+
if (!tt || !text) return;
|
|
87
|
+
tt.html(text);
|
|
88
|
+
tt.setPosition(e);
|
|
89
|
+
tt.show()
|
|
90
|
+
})
|
|
91
|
+
.on("mouseout", function () {
|
|
92
|
+
/*select(this).attr("stroke-width", 0);*/
|
|
93
|
+
select(this).attr('fill', color);
|
|
94
|
+
if (tt) tt.hide()
|
|
95
|
+
})
|
|
96
|
+
if (tt && text) elt.on("mousemove", function (e) { tt.setPosition(e) })
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//const [c0, c1, c2] = classifier.center
|
|
100
|
+
|
|
101
|
+
//trapezium s0
|
|
102
|
+
const t0 = g.append('polygon')
|
|
103
|
+
.attr('points', "0," + h + " " + w / 3 + "," + h + " " + w / 2 + "," + h * 2 / 3 + " " + w / 6 + "," + h * 2 / 3)
|
|
104
|
+
setAttributes(t0, classifier.colors[0], texts["0"])
|
|
105
|
+
//trapezium s1
|
|
106
|
+
const t1 = g.append('polygon')
|
|
107
|
+
.attr('points', w / 2 + ",0 " + w * 2 / 3 + "," + h / 3 + " " + w / 2 + "," + h * 2 / 3 + " " + w / 3 + "," + h / 3)
|
|
108
|
+
setAttributes(t1, classifier.colors[1], texts["1"])
|
|
109
|
+
//trapezium s2
|
|
110
|
+
const t2 = g.append('polygon')
|
|
111
|
+
.attr('points', w + "," + h + " " + w * 5 / 6 + "," + 2 * h / 3 + " " + w / 2 + "," + h * 2 / 3 + " " + w * 2 / 3 + "," + h)
|
|
112
|
+
setAttributes(t2, classifier.colors[2], texts["2"])
|
|
113
|
+
//triangle s0
|
|
114
|
+
const t0_ = g.append('polygon')
|
|
115
|
+
.attr('points', w / 2 + "," + h * 2 / 3 + " " + w * 5 / 6 + "," + h * 2 / 3 + " " + w * 2 / 3 + "," + h / 3)
|
|
116
|
+
setAttributes(t0_, classifier.mixColors[0], texts["12"])
|
|
117
|
+
//triangle s1
|
|
118
|
+
const t1_ = g.append('polygon')
|
|
119
|
+
.attr('points', w / 2 + "," + h * 2 / 3 + " " + w / 3 + "," + h + " " + w * 2 / 3 + "," + h)
|
|
120
|
+
setAttributes(t1_, classifier.mixColors[1], texts["02"])
|
|
121
|
+
//triangle s2
|
|
122
|
+
const t2_ = g.append('polygon')
|
|
123
|
+
.attr('points', w / 2 + "," + h * 2 / 3 + " " + w / 6 + "," + h * 2 / 3 + " " + w / 3 + "," + h / 3)
|
|
124
|
+
setAttributes(t2_, classifier.mixColors[2], texts["01"])
|
|
125
|
+
|
|
126
|
+
//center
|
|
127
|
+
if (this.centerCoefficient) {
|
|
128
|
+
//TODO make it an hexagon !
|
|
129
|
+
const center = g.append('circle')
|
|
130
|
+
.attr('cx', w / 2).attr('cy', h * 2 / 3)
|
|
131
|
+
.attr('r', this.centerCoefficient * h / 3)
|
|
132
|
+
setAttributes(center, classifier.centerColor, texts["center"])
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
let middle, left, top, right, left_, bottom_, right_
|
|
138
|
+
if (!this.real) {
|
|
139
|
+
|
|
140
|
+
//0 left triangle
|
|
141
|
+
left = g.append('polygon')
|
|
142
|
+
.attr('points', "0," + h + " " + (w / 3) + "," + h + " " + (w / 6) + "," + (2 * h / 3))
|
|
143
|
+
//1 top triangle
|
|
144
|
+
top = g.append('polygon')
|
|
145
|
+
.attr('points', (w / 3) + "," + (h / 3) + " " + (w * 2 / 3) + "," + (h / 3) + " " + (w / 2) + ",0")
|
|
146
|
+
//2 right triangle
|
|
147
|
+
right = g.append('polygon')
|
|
148
|
+
.attr('points', (w * 2 / 3) + "," + h + " " + w + "," + h + " " + (w * 5 / 6) + "," + (2 * h / 3))
|
|
149
|
+
//middle triangle
|
|
150
|
+
middle = g.append('polygon')
|
|
151
|
+
.attr('points', (w / 2) + "," + (h / 3) + " " + (w / 4) + "," + (h * 5 / 6) + " " + (3 * w / 4) + "," + (h * 5 / 6))
|
|
152
|
+
//01 left trapezium
|
|
153
|
+
left_ = g.append('polygon')
|
|
154
|
+
.attr('points', (w / 6) + "," + (h * 2 / 3) + " " + (w / 4) + "," + (h * 5 / 6) + " " + (w / 2) + "," + (h / 3) + " " + (w / 3) + "," + (h / 3))
|
|
155
|
+
//02 bottom trapezium
|
|
156
|
+
bottom_ = g.append('polygon')
|
|
157
|
+
.attr('points', (w / 3) + "," + (h) + " " + (2 * w / 3) + "," + (h) + " " + (w * 3 / 4) + "," + (h * 5 / 6) + " " + (w / 4) + "," + (h * 5 / 6))
|
|
158
|
+
//12 right trapezium
|
|
159
|
+
right_ = g.append('polygon')
|
|
160
|
+
.attr('points', (w / 2) + "," + (h / 3) + " " + (w * 3 / 4) + "," + (h * 5 / 6) + " " + (w * 5 / 6) + "," + (h * 2 / 3) + " " + (w * 2 / 3) + "," + (h / 3))
|
|
161
|
+
|
|
162
|
+
} else {
|
|
163
|
+
|
|
164
|
+
//middle triangle
|
|
165
|
+
middle = g.append('polygon')
|
|
166
|
+
.attr('points', (w / 2) + ",0 0," + h + " " + w + "," + h)
|
|
167
|
+
|
|
168
|
+
//draw trapezium
|
|
169
|
+
//draw large trapezium first
|
|
170
|
+
for (let i_ = 2; i_ >= 0; i_--) {
|
|
171
|
+
const i = this.classifier.lowIndex[i_]
|
|
172
|
+
const r = this.classifier.lowThreshold[i]
|
|
173
|
+
if (i == 2)
|
|
174
|
+
//01 left trapezium
|
|
175
|
+
left_ = g.append('polygon')
|
|
176
|
+
.attr('points', w / 2 + ",0 0," + h + " " + w * r + "," + h + " " + w * (1 + r) / 2 + "," + r * h)
|
|
177
|
+
else if (i == 1)
|
|
178
|
+
//02 bottom trapezium
|
|
179
|
+
bottom_ = g.append('polygon')
|
|
180
|
+
.attr('points', "0," + h + " " + w + "," + h + " " + w * (1 - r / 2) + "," + h * (1 - r) + " " + r * w / 2 + "," + h * (1 - r))
|
|
181
|
+
else
|
|
182
|
+
//12 right trapezium
|
|
183
|
+
right_ = g.append('polygon')
|
|
184
|
+
.attr('points', w + "," + h + " " + w / 2 + ",0 " + w * (1 - r) / 2 + "," + h * r + " " + w * (1 - r) + "," + h)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
//draw triangles
|
|
188
|
+
//draw large triangles first
|
|
189
|
+
for (let i_ = 2; i_ >= 0; i_--) {
|
|
190
|
+
const i = this.classifier.highIndex[i_]
|
|
191
|
+
const r = this.classifier.highThreshold[i]
|
|
192
|
+
|
|
193
|
+
if (i == 2)
|
|
194
|
+
//2 right triangle
|
|
195
|
+
right = g.append('polygon')
|
|
196
|
+
.attr('points', w + "," + h + " " + w * r + "," + h + " " + w * (1 + r) / 2 + "," + h * r)
|
|
197
|
+
else if (i == 1)
|
|
198
|
+
//1 top triangle
|
|
199
|
+
top = g.append('polygon')
|
|
200
|
+
.attr('points', (w / 2) + ",0 " + w * r / 2 + "," + h * (1 - r) + " " + w * (1 - r / 2) + "," + h * (1 - r))
|
|
201
|
+
else
|
|
202
|
+
//0 left triangle
|
|
203
|
+
left = g.append('polygon')
|
|
204
|
+
.attr('points', "0," + h + " " + w * (1 - r) + "," + h + " " + w * (1 - r) / 2 + "," + h * r)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
}*/
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -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 {
|