gridviz 2.0.38 → 2.0.40

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 (58) hide show
  1. package/README.md +119 -119
  2. package/dist/gridviz.js +7945 -8887
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +77 -78
  5. package/src/App.js +698 -698
  6. package/src/BackgroundLayer.js +182 -182
  7. package/src/BackgroundLayerWMS.js +131 -131
  8. package/src/Dataset.js +76 -76
  9. package/src/DatasetComponent.js +103 -103
  10. package/src/GeoCanvas.js +419 -419
  11. package/src/LabelLayer.js +190 -190
  12. package/src/Layer.js +92 -92
  13. package/src/Legend.js +86 -86
  14. package/src/LineLayer.js +150 -150
  15. package/src/Style.js +114 -114
  16. package/src/Tooltip.js +168 -168
  17. package/src/dataset/COGeo.js +24 -24
  18. package/src/dataset/CSVGrid.js +104 -104
  19. package/src/dataset/GeoTIFF.js +127 -127
  20. package/src/dataset/GridTile.js +41 -41
  21. package/src/dataset/ParquetGrid.js +122 -122
  22. package/src/dataset/TiledGrid.js +296 -296
  23. package/src/index.js +174 -177
  24. package/src/legend/ColorCategoryLegend.js +124 -124
  25. package/src/legend/ColorDiscreteLegend.js +105 -105
  26. package/src/legend/ColorLegend.js +125 -125
  27. package/src/legend/SegmentOrientationLegend.js +87 -87
  28. package/src/legend/SegmentWidthLegend.js +97 -97
  29. package/src/legend/SizeLegend.js +141 -141
  30. package/src/style/CompositionStyle.js +300 -300
  31. package/src/style/ContourStyle.js +54 -54
  32. package/src/style/DotDensityStyle.js +156 -156
  33. package/src/style/JoyPlotStyle.js +135 -135
  34. package/src/style/LegoStyle.js +112 -112
  35. package/src/style/MosaicStyle.js +107 -107
  36. package/src/style/NinjaStarStyle.js +124 -124
  37. package/src/style/PillarStyle.js +230 -230
  38. package/src/style/SegmentStyle.js +142 -142
  39. package/src/style/ShapeColorSizeStyle.js +126 -126
  40. package/src/style/SideCatStyle.js +172 -172
  41. package/src/style/SideStyle.js +218 -218
  42. package/src/style/SquareColorCatWGLStyle.js +120 -120
  43. package/src/style/SquareColorWGLStyle.js +146 -146
  44. package/src/style/StrokeStyle.js +131 -131
  45. package/src/style/TanakaStyle.js +160 -160
  46. package/src/style/TextStyle.js +132 -132
  47. package/src/utils/Utils.js +35 -35
  48. package/src/utils/WebGLRectangleColoring.js +106 -106
  49. package/src/utils/WebGLSquareColoring.js +118 -118
  50. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  51. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  52. package/src/utils/WebGLSquareColoringKS.js +153 -153
  53. package/src/utils/stretching.js +131 -131
  54. package/src/utils/webGLUtils.js +71 -71
  55. package/src/utils/zoomUtils.js +142 -142
  56. package/src/style/KernelSmoothingOldStyle.js +0 -221
  57. package/src/style/KernelSmoothingStyle.js +0 -115
  58. package/src/style/KernelSmoothingWGLStyle.js +0 -130
@@ -1,105 +1,105 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- //import { select } from "d3-selection";
5
- import { Legend } from '../Legend.js'
6
- //import { format } from "d3-format";
7
-
8
- /**
9
- * A legend element for discrete color style.
10
- * Inspiration: https://observablehq.com/@d3/color-legend
11
- *
12
- * @author Julien Gaffuri
13
- */
14
- export class ColorDiscreteLegend extends Legend {
15
- /** @param {Object} opts */
16
- constructor(opts) {
17
- super(opts)
18
- opts = opts || {}
19
-
20
- /** @private @type {Array.<Array.<string>>} */
21
- this.colors = opts.colors
22
- /** @private @type {Array.<Array.<string>>} */
23
- this.breaksText = opts.breaksText
24
-
25
- this.width = opts.width || 300
26
- this.height = opts.height || 15
27
-
28
- this.title = opts.title
29
- this.titleFontSize = opts.titleFontSize || '0.8em'
30
- this.titleFontWeight = opts.titleFontWeight || 'bold'
31
-
32
- this.tickSize = opts.tickSize || 3
33
-
34
- //label
35
- this.labelFontSize = opts.labelFontSize || '0.8em'
36
- this.invert = opts.invert
37
- }
38
-
39
- /**
40
- * @param {{ style: import("../Style").Style, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
41
- */
42
- update(opts) {
43
- //clear
44
- this.div.selectAll('*').remove()
45
-
46
- //build
47
-
48
- //title
49
- if (this.title)
50
- this.div
51
- .append('div')
52
- .style('font-size', this.titleFontSize)
53
- .style('font-weight', this.titleFontWeight)
54
- .style('margin-bottom', '7px')
55
- .text(this.title)
56
-
57
- //classes
58
- const nb = this.colors.length
59
- if (nb == 0) return
60
- const w = this.width / nb
61
-
62
- //make svg element
63
- const svg = this.div
64
- .append('svg')
65
- .attr('width', this.width)
66
- .attr('height', this.height + this.tickSize + 2 + 10)
67
-
68
- //draw graphic elements
69
- for (let i = 0; i < nb; i++) {
70
- svg.append('rect')
71
- .attr('x', i * w)
72
- .attr('y', 0)
73
- .attr('width', w)
74
- .attr('height', this.height)
75
- .style('fill', this.colors[i])
76
- }
77
-
78
- //tick line
79
- for (let i = 1; i < nb; i++) {
80
- svg.append('line')
81
- .attr('x1', w * i)
82
- .attr('y1', 0)
83
- .attr('x2', w * i)
84
- .attr('y2', this.height + this.tickSize)
85
- .style('stroke', 'black')
86
- }
87
-
88
- //labels
89
- for (let i = 1; i < nb; i++) {
90
- //prepare label
91
- svg.append('text')
92
- .attr('id', 'ticklabel_' + i)
93
- .attr('x', w * i)
94
- .attr('y', this.height + this.tickSize + 2)
95
- .style('font-size', this.labelFontSize)
96
- //.style("font-weight", "bold")
97
- //.style("font-family", "Arial")
98
- .style('text-anchor', i == 0 ? 'start' : i == this.ticks - 1 ? 'end' : 'middle')
99
- .style('alignment-baseline', 'top')
100
- .style('dominant-baseline', 'hanging')
101
- .style('pointer-events', 'none')
102
- .text(this.breaksText[i - 1])
103
- }
104
- }
105
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ //import { select } from "d3-selection";
5
+ import { Legend } from '../Legend.js'
6
+ //import { format } from "d3-format";
7
+
8
+ /**
9
+ * A legend element for discrete color style.
10
+ * Inspiration: https://observablehq.com/@d3/color-legend
11
+ *
12
+ * @author Julien Gaffuri
13
+ */
14
+ export class ColorDiscreteLegend extends Legend {
15
+ /** @param {Object} opts */
16
+ constructor(opts) {
17
+ super(opts)
18
+ opts = opts || {}
19
+
20
+ /** @private @type {Array.<Array.<string>>} */
21
+ this.colors = opts.colors
22
+ /** @private @type {Array.<Array.<string>>} */
23
+ this.breaksText = opts.breaksText
24
+
25
+ this.width = opts.width || 300
26
+ this.height = opts.height || 15
27
+
28
+ this.title = opts.title
29
+ this.titleFontSize = opts.titleFontSize || '0.8em'
30
+ this.titleFontWeight = opts.titleFontWeight || 'bold'
31
+
32
+ this.tickSize = opts.tickSize || 3
33
+
34
+ //label
35
+ this.labelFontSize = opts.labelFontSize || '0.8em'
36
+ this.invert = opts.invert
37
+ }
38
+
39
+ /**
40
+ * @param {{ style: import("../Style").Style, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
41
+ */
42
+ update(opts) {
43
+ //clear
44
+ this.div.selectAll('*').remove()
45
+
46
+ //build
47
+
48
+ //title
49
+ if (this.title)
50
+ this.div
51
+ .append('div')
52
+ .style('font-size', this.titleFontSize)
53
+ .style('font-weight', this.titleFontWeight)
54
+ .style('margin-bottom', '7px')
55
+ .text(this.title)
56
+
57
+ //classes
58
+ const nb = this.colors.length
59
+ if (nb == 0) return
60
+ const w = this.width / nb
61
+
62
+ //make svg element
63
+ const svg = this.div
64
+ .append('svg')
65
+ .attr('width', this.width)
66
+ .attr('height', this.height + this.tickSize + 2 + 10)
67
+
68
+ //draw graphic elements
69
+ for (let i = 0; i < nb; i++) {
70
+ svg.append('rect')
71
+ .attr('x', i * w)
72
+ .attr('y', 0)
73
+ .attr('width', w)
74
+ .attr('height', this.height)
75
+ .style('fill', this.colors[i])
76
+ }
77
+
78
+ //tick line
79
+ for (let i = 1; i < nb; i++) {
80
+ svg.append('line')
81
+ .attr('x1', w * i)
82
+ .attr('y1', 0)
83
+ .attr('x2', w * i)
84
+ .attr('y2', this.height + this.tickSize)
85
+ .style('stroke', 'black')
86
+ }
87
+
88
+ //labels
89
+ for (let i = 1; i < nb; i++) {
90
+ //prepare label
91
+ svg.append('text')
92
+ .attr('id', 'ticklabel_' + i)
93
+ .attr('x', w * i)
94
+ .attr('y', this.height + this.tickSize + 2)
95
+ .style('font-size', this.labelFontSize)
96
+ //.style("font-weight", "bold")
97
+ //.style("font-family", "Arial")
98
+ .style('text-anchor', i == 0 ? 'start' : i == this.ticks - 1 ? 'end' : 'middle')
99
+ .style('alignment-baseline', 'top')
100
+ .style('dominant-baseline', 'hanging')
101
+ .style('pointer-events', 'none')
102
+ .text(this.breaksText[i - 1])
103
+ }
104
+ }
105
+ }
@@ -1,125 +1,125 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- //import { select } from "d3-selection";
5
- import { Legend } from '../Legend.js'
6
- import { format } from 'd3-format'
7
-
8
- /**
9
- * A legend element for continuous color style.
10
- * Inspiration: https://observablehq.com/@d3/color-legend
11
- *
12
- * @author Joseph Davies, Julien Gaffuri
13
- */
14
- export class ColorLegend extends Legend {
15
- /** @param {Object} opts */
16
- constructor(opts) {
17
- super(opts)
18
- opts = opts || {}
19
-
20
- this.colorRamp = opts.colorRamp
21
-
22
- //function (t[0,1], r, s) -> v (for label text)
23
- this.fun = opts.fun
24
-
25
- this.title = opts.title
26
- this.tickSize = opts.tickSize || 6
27
- this.width = opts.width || 300
28
- this.height = opts.height || 15
29
- this.margin = opts.margin || 5
30
- this.ticks = opts.ticks || Math.floor(this.width / 50)
31
- this.tickFormat = opts.tickFormat || ',.0f'
32
- this.tickUnit = opts.tickUnit
33
-
34
- this.fontSize = opts.fontSize || '0.8em'
35
- this.invert = opts.invert
36
- }
37
-
38
- /**
39
- * @param {{ style: import("../Style").Style, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
40
- */
41
- update(opts) {
42
- //could happen when data is still loading
43
- if (!opts.sColor) return
44
-
45
- //clear
46
- this.div.selectAll('*').remove()
47
-
48
- const titleHeight = 12
49
-
50
- const svgW = this.width + 2 * this.margin
51
- const svgH = this.height + 3 * this.margin + titleHeight + this.tickSize + 10
52
- const svg = this.div.append('svg').attr('width', svgW).attr('height', svgH)
53
- // <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
54
-
55
- //title
56
- svg.append('text')
57
- .attr('x', this.margin)
58
- .attr('y', this.margin)
59
- .style('font-size', '0.8em')
60
- .style('font-weight', 'bold')
61
- .style('alignment-baseline', 'top')
62
- .style('dominant-baseline', 'hanging')
63
- .style('pointer-events', 'none')
64
- .text(this.title)
65
-
66
- const g = svg
67
- .append('g')
68
- .attr('transform', 'translate(' + this.margin + ' ' + (2 * this.margin + titleHeight) + ')')
69
-
70
- //draw color bar
71
- const w = this.width,
72
- h = this.height
73
- const step = 5
74
- for (let i = 0; i < w; i += step) {
75
- let t = i / (w - 1)
76
- if (this.invert) t = 1 - t
77
- g.append('rect')
78
- .attr('x', i)
79
- .attr('y', 0)
80
- .attr('width', step)
81
- .attr('height', h)
82
- .style('fill', this.colorRamp(t))
83
- }
84
-
85
- for (let i = 0; i < this.ticks; i++) {
86
- let t = i / (this.ticks - 1)
87
-
88
- //tick line
89
- g.append('line')
90
- .attr('x1', w * t)
91
- .attr('y1', 0)
92
- .attr('x2', w * t)
93
- .attr('y2', h + this.tickSize)
94
- .style('stroke', 'black')
95
-
96
- //prepare tick label
97
- g.append('text')
98
- .attr('id', 'ticklabel_' + i)
99
- .attr('x', w * t)
100
- .attr('y', h + this.tickSize + 2)
101
- .style('font-size', this.fontSize)
102
- //.style("font-weight", "bold")
103
- //.style("font-family", "Arial")
104
- .style('text-anchor', i == 0 ? 'start' : i == this.ticks - 1 ? 'end' : 'middle')
105
- .style('alignment-baseline', 'top')
106
- .style('dominant-baseline', 'hanging')
107
- .style('pointer-events', 'none')
108
- //.text("-")
109
- }
110
-
111
- //update tick labels
112
-
113
- //label text format
114
- const f = this.tickFormat && this.tickFormat != 'text' ? format(this.tickFormat) : (v) => v
115
- for (let i = 0; i < this.ticks; i++) {
116
- let t = i / (this.ticks - 1)
117
-
118
- const v = this.fun(t, opts.r, opts.sColor)
119
- const text = (v ? f(v) : '0') + (this.tickUnit ? this.tickUnit : '')
120
-
121
- //tick label
122
- this.div.select('#' + 'ticklabel_' + i).text(text)
123
- }
124
- }
125
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ //import { select } from "d3-selection";
5
+ import { Legend } from '../Legend.js'
6
+ import { format } from 'd3-format'
7
+
8
+ /**
9
+ * A legend element for continuous color style.
10
+ * Inspiration: https://observablehq.com/@d3/color-legend
11
+ *
12
+ * @author Joseph Davies, Julien Gaffuri
13
+ */
14
+ export class ColorLegend extends Legend {
15
+ /** @param {Object} opts */
16
+ constructor(opts) {
17
+ super(opts)
18
+ opts = opts || {}
19
+
20
+ this.colorRamp = opts.colorRamp
21
+
22
+ //function (t[0,1], r, s) -> v (for label text)
23
+ this.fun = opts.fun
24
+
25
+ this.title = opts.title
26
+ this.tickSize = opts.tickSize || 6
27
+ this.width = opts.width || 300
28
+ this.height = opts.height || 15
29
+ this.margin = opts.margin || 5
30
+ this.ticks = opts.ticks || Math.floor(this.width / 50)
31
+ this.tickFormat = opts.tickFormat || ',.0f'
32
+ this.tickUnit = opts.tickUnit
33
+
34
+ this.fontSize = opts.fontSize || '0.8em'
35
+ this.invert = opts.invert
36
+ }
37
+
38
+ /**
39
+ * @param {{ style: import("../Style").Style, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
40
+ */
41
+ update(opts) {
42
+ //could happen when data is still loading
43
+ if (!opts.sColor) return
44
+
45
+ //clear
46
+ this.div.selectAll('*').remove()
47
+
48
+ const titleHeight = 12
49
+
50
+ const svgW = this.width + 2 * this.margin
51
+ const svgH = this.height + 3 * this.margin + titleHeight + this.tickSize + 10
52
+ const svg = this.div.append('svg').attr('width', svgW).attr('height', svgH)
53
+ // <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
54
+
55
+ //title
56
+ svg.append('text')
57
+ .attr('x', this.margin)
58
+ .attr('y', this.margin)
59
+ .style('font-size', '0.8em')
60
+ .style('font-weight', 'bold')
61
+ .style('alignment-baseline', 'top')
62
+ .style('dominant-baseline', 'hanging')
63
+ .style('pointer-events', 'none')
64
+ .text(this.title)
65
+
66
+ const g = svg
67
+ .append('g')
68
+ .attr('transform', 'translate(' + this.margin + ' ' + (2 * this.margin + titleHeight) + ')')
69
+
70
+ //draw color bar
71
+ const w = this.width,
72
+ h = this.height
73
+ const step = 5
74
+ for (let i = 0; i < w; i += step) {
75
+ let t = i / (w - 1)
76
+ if (this.invert) t = 1 - t
77
+ g.append('rect')
78
+ .attr('x', i)
79
+ .attr('y', 0)
80
+ .attr('width', step)
81
+ .attr('height', h)
82
+ .style('fill', this.colorRamp(t))
83
+ }
84
+
85
+ for (let i = 0; i < this.ticks; i++) {
86
+ let t = i / (this.ticks - 1)
87
+
88
+ //tick line
89
+ g.append('line')
90
+ .attr('x1', w * t)
91
+ .attr('y1', 0)
92
+ .attr('x2', w * t)
93
+ .attr('y2', h + this.tickSize)
94
+ .style('stroke', 'black')
95
+
96
+ //prepare tick label
97
+ g.append('text')
98
+ .attr('id', 'ticklabel_' + i)
99
+ .attr('x', w * t)
100
+ .attr('y', h + this.tickSize + 2)
101
+ .style('font-size', this.fontSize)
102
+ //.style("font-weight", "bold")
103
+ //.style("font-family", "Arial")
104
+ .style('text-anchor', i == 0 ? 'start' : i == this.ticks - 1 ? 'end' : 'middle')
105
+ .style('alignment-baseline', 'top')
106
+ .style('dominant-baseline', 'hanging')
107
+ .style('pointer-events', 'none')
108
+ //.text("-")
109
+ }
110
+
111
+ //update tick labels
112
+
113
+ //label text format
114
+ const f = this.tickFormat && this.tickFormat != 'text' ? format(this.tickFormat) : (v) => v
115
+ for (let i = 0; i < this.ticks; i++) {
116
+ let t = i / (this.ticks - 1)
117
+
118
+ const v = this.fun(t, opts.r, opts.sColor)
119
+ const text = (v ? f(v) : '0') + (this.tickUnit ? this.tickUnit : '')
120
+
121
+ //tick label
122
+ this.div.select('#' + 'ticklabel_' + i).text(text)
123
+ }
124
+ }
125
+ }
@@ -1,87 +1,87 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Legend } from '../Legend.js'
5
-
6
- /**
7
- * A legend element for segment orientation.
8
- *
9
- * @author Joseph Davies, Julien Gaffuri
10
- */
11
- export class SegmentOrientationLegend extends Legend {
12
- /** @param {Object} opts */
13
- constructor(opts) {
14
- super(opts)
15
- opts = opts || {}
16
-
17
- //title
18
- this.title = opts.title
19
- this.titleFontSize = opts.titleFontSize || '0.8em'
20
- this.titleFontWeight = opts.titleFontWeight || 'bold'
21
-
22
- //exageration
23
- this.exaggerationFactor = opts.exaggerationFactor || 0.5
24
-
25
- //color
26
- this.color = opts.color || 'gray'
27
- //orientation
28
- this.orientation = opts.orientation || 0
29
- //width
30
- this.widthPix = opts.widthPix || 3
31
-
32
- //label
33
- this.labelFontSize = opts.labelFontSize || '0.8em'
34
- this.labelUnitText = opts.labelUnitText || ''
35
- }
36
-
37
- /**
38
- * @param {{ style: import("../style/SegmentStyle").SegmentStyle, r: number, zf: number, sColor: import("../Style").Stat, sLength: import("../Style").Stat, sWidth: import("../Style").Stat }} opts
39
- */
40
- update(opts) {
41
- //could happen when data is still loading
42
- if (!opts.sWidth) return
43
-
44
- //clear
45
- this.div.selectAll('*').remove()
46
-
47
- const d = this.div.append('div')
48
-
49
- //title
50
- if (this.title) {
51
- d.append('div')
52
- .attr('class', 'title')
53
- .style('font-size', this.titleFontSize)
54
- .style('font-weight', this.titleFontWeight)
55
- .text(this.title)
56
- }
57
-
58
- //compute segment width and length, in pix
59
- const sWidth = this.widthPix
60
- const sLength = (1 * opts.r) / opts.zf
61
-
62
- //draw SVG segment
63
- const svgS = Math.max(sLength, sWidth)
64
- const svg = d.append('svg').attr('width', svgS).attr('height', svgS).style('', 'inline-block')
65
-
66
- const cos = Math.cos((-this.orientation * Math.PI) / 180)
67
- const sin = Math.sin((-this.orientation * Math.PI) / 180)
68
- const dc = svgS * 0.5,
69
- l2 = sLength * 0.5
70
- svg.append('line')
71
- .attr('x1', dc - cos * l2)
72
- .attr('y1', dc - sin * l2)
73
- .attr('x2', dc + cos * l2)
74
- .attr('y2', dc + sin * l2)
75
- .style('stroke', this.color)
76
- .style('stroke-width', sWidth)
77
-
78
- //text label
79
- d.append('div')
80
- //show on right of svg
81
- .style('display', 'inline')
82
- .style('padding-left', '5px')
83
- .style('font-size', this.labelFontSize)
84
- //.style("font-weight", "bold")
85
- .text(this.labelUnitText)
86
- }
87
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Legend } from '../Legend.js'
5
+
6
+ /**
7
+ * A legend element for segment orientation.
8
+ *
9
+ * @author Joseph Davies, Julien Gaffuri
10
+ */
11
+ export class SegmentOrientationLegend extends Legend {
12
+ /** @param {Object} opts */
13
+ constructor(opts) {
14
+ super(opts)
15
+ opts = opts || {}
16
+
17
+ //title
18
+ this.title = opts.title
19
+ this.titleFontSize = opts.titleFontSize || '0.8em'
20
+ this.titleFontWeight = opts.titleFontWeight || 'bold'
21
+
22
+ //exageration
23
+ this.exaggerationFactor = opts.exaggerationFactor || 0.5
24
+
25
+ //color
26
+ this.color = opts.color || 'gray'
27
+ //orientation
28
+ this.orientation = opts.orientation || 0
29
+ //width
30
+ this.widthPix = opts.widthPix || 3
31
+
32
+ //label
33
+ this.labelFontSize = opts.labelFontSize || '0.8em'
34
+ this.labelUnitText = opts.labelUnitText || ''
35
+ }
36
+
37
+ /**
38
+ * @param {{ style: import("../style/SegmentStyle").SegmentStyle, r: number, zf: number, sColor: import("../Style").Stat, sLength: import("../Style").Stat, sWidth: import("../Style").Stat }} opts
39
+ */
40
+ update(opts) {
41
+ //could happen when data is still loading
42
+ if (!opts.sWidth) return
43
+
44
+ //clear
45
+ this.div.selectAll('*').remove()
46
+
47
+ const d = this.div.append('div')
48
+
49
+ //title
50
+ if (this.title) {
51
+ d.append('div')
52
+ .attr('class', 'title')
53
+ .style('font-size', this.titleFontSize)
54
+ .style('font-weight', this.titleFontWeight)
55
+ .text(this.title)
56
+ }
57
+
58
+ //compute segment width and length, in pix
59
+ const sWidth = this.widthPix
60
+ const sLength = (1 * opts.r) / opts.zf
61
+
62
+ //draw SVG segment
63
+ const svgS = Math.max(sLength, sWidth)
64
+ const svg = d.append('svg').attr('width', svgS).attr('height', svgS).style('', 'inline-block')
65
+
66
+ const cos = Math.cos((-this.orientation * Math.PI) / 180)
67
+ const sin = Math.sin((-this.orientation * Math.PI) / 180)
68
+ const dc = svgS * 0.5,
69
+ l2 = sLength * 0.5
70
+ svg.append('line')
71
+ .attr('x1', dc - cos * l2)
72
+ .attr('y1', dc - sin * l2)
73
+ .attr('x2', dc + cos * l2)
74
+ .attr('y2', dc + sin * l2)
75
+ .style('stroke', this.color)
76
+ .style('stroke-width', sWidth)
77
+
78
+ //text label
79
+ d.append('div')
80
+ //show on right of svg
81
+ .style('display', 'inline')
82
+ .style('padding-left', '5px')
83
+ .style('font-size', this.labelFontSize)
84
+ //.style("font-weight", "bold")
85
+ .text(this.labelUnitText)
86
+ }
87
+ }