@abi-software/flatmapvuer 1.11.0 → 1.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmapvuer",
3
- "version": "1.11.0",
3
+ "version": "1.11.2",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist/*",
@@ -44,9 +44,9 @@
44
44
  "./src/*": "./src/*"
45
45
  },
46
46
  "dependencies": {
47
- "@abi-software/map-utilities": "^1.7.0",
47
+ "@abi-software/map-utilities": "^1.7.1",
48
48
  "@abi-software/sparc-annotation": "0.3.2",
49
- "@abi-software/svg-sprite": "^1.0.1",
49
+ "@abi-software/svg-sprite": "1.0.2",
50
50
  "@element-plus/icons-vue": "^2.3.1",
51
51
  "css-element-queries": "^1.2.2",
52
52
  "element-plus": "2.8.4",
package/src/App.vue CHANGED
@@ -62,6 +62,7 @@
62
62
  <MultiFlatmapVuer
63
63
  ref="multi"
64
64
  :availableSpecies="availableSpecies"
65
+ :externalLegends="externalLegends"
65
66
  @resource-selected="FlatmapSelected"
66
67
  :minZoom="minZoom"
67
68
  @pan-zoom-callback="panZoomcallback"
@@ -313,6 +314,47 @@ export default {
313
314
  // flatmapAPI: "https://mapcore-demo.org/devel/flatmap/v1/",
314
315
  ElIconSetting: shallowRef(ElIconSetting),
315
316
  annotator: markRaw(new AnnotationService(`https://mapcore-demo.org/devel/flatmap/v4/annotator`)),
317
+ externalLegends: [
318
+ {
319
+ prompt: 'Sample Circle',
320
+ colour: '#FA00C0',
321
+ border: "green",
322
+ style: 'circle'
323
+ },
324
+ {
325
+ prompt: 'Sample square',
326
+ border: '#EA431C',
327
+ style: 'square'
328
+ },
329
+ {
330
+ prompt: 'Sample rounded square',
331
+ style: 'rounded-square'
332
+ },
333
+ {
334
+ prompt: 'Sample exoid',
335
+ colour: '#0AED59',
336
+ border: 'purple',
337
+ style: 'exoid'
338
+ },
339
+ {
340
+ prompt: 'Sample line',
341
+ colour: '#0047AB',
342
+ style: 'line'
343
+ },
344
+ {
345
+ prompt: 'Sample dashed arrow line',
346
+ colour: '#099F04',
347
+ style: 'line',
348
+ dashed: true,
349
+ arrow: true
350
+ },
351
+ {
352
+ prompt: 'Sample hexagon',
353
+ colour: '#34E5EB',
354
+ style: 'hexagon',
355
+ border: 'blue',
356
+ },
357
+ ]
316
358
  }
317
359
  },
318
360
  mounted: function () {
@@ -260,39 +260,35 @@ Please use `const` to assign meaningful names to them...
260
260
  :style="{ 'max-height': pathwaysMaxHeight + 'px' }"
261
261
  v-popover:checkBoxPopover
262
262
  >
263
- <!-- <svg-legends v-if="!isFC" class="svg-legends-container" /> -->
264
- <dynamic-legends
265
- v-if="!isFC"
266
- identifierKey="prompt"
267
- colourKey="colour"
268
- styleKey="style"
269
- :legends="flatmapLegends"
270
- :showStarInLegend="showStarInLegend"
271
- class="svg-legends-container"
272
- />
273
- <!-- <template v-if="showStarInLegend">
274
- <el-popover
275
- content="Location of the featured dataset"
276
- placement="right"
277
- :teleported="true"
278
- trigger="manual"
279
- width="max-content"
280
- :offset="-10"
281
- popper-class="flatmap-popper flatmap-teleport-popper"
282
- :visible="hoverVisibilities[9].value"
283
- ref="featuredMarkerPopover"
284
- >
285
- <template #reference>
286
- <div
287
- v-popover:featuredMarkerPopover
288
- class="yellow-star-legend"
289
- v-html="yellowstar"
290
- @mouseover="showTooltip(9)"
291
- @mouseout="hideTooltip(9)"
292
- ></div>
293
- </template>
294
- </el-popover>
295
- </template> -->
263
+ <el-popover
264
+ content="Location of the featured dataset"
265
+ placement="bottom"
266
+ :teleported="true"
267
+ trigger="manual"
268
+ width="max-content"
269
+ :offset="-10"
270
+ popper-class="flatmap-popper flatmap-teleport-popper"
271
+ :visible="hoverVisibilities[9].value && showStarInLegend"
272
+ ref="featuredMarkerPopover"
273
+ >
274
+ <template #reference>
275
+ <div
276
+ v-popover:featuredMarkerPopover
277
+ @mouseover="showTooltip(9)"
278
+ @mouseout="hideTooltip(9)"
279
+ >
280
+ <dynamic-legends
281
+ v-if="legendEntry.length"
282
+ identifierKey="prompt"
283
+ colourKey="colour"
284
+ styleKey="style"
285
+ :legends="legendEntry"
286
+ :showStarInLegend="true"
287
+ class="svg-legends-container"
288
+ />
289
+ </div>
290
+ </template>
291
+ </el-popover>
296
292
  <!-- The line below places the yellowstar svg on the left, and the text "Featured markers on the right" with css so they are both centered in the div -->
297
293
  <el-popover
298
294
  content="Find these markers for data. The number inside the markers is the number of datasets available for each marker."
@@ -647,7 +643,7 @@ import {
647
643
  import { capitalise } from './utilities.js'
648
644
  import yellowstar from '../icons/yellowstar'
649
645
  import ResizeSensor from 'css-element-queries/src/ResizeSensor'
650
- import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.2.10/+esm'
646
+ import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.2.13/+esm'
651
647
  import { AnnotationService } from '@abi-software/sparc-annotation'
652
648
  import { mapState } from 'pinia'
653
649
  import { useMainStore } from '@/store/index'
@@ -3283,6 +3279,13 @@ export default {
3283
3279
  type: Boolean,
3284
3280
  default: true,
3285
3281
  },
3282
+ /**
3283
+ * Allow to add and display extra legends to drawer
3284
+ */
3285
+ externalLegends: {
3286
+ type: Array,
3287
+ default: [],
3288
+ },
3286
3289
  },
3287
3290
  provide() {
3288
3291
  return {
@@ -3421,21 +3424,17 @@ export default {
3421
3424
  this.drawerOpen = false
3422
3425
  return false
3423
3426
  }
3424
- if (!this.isFC) {
3427
+ if ((this.systems?.length > 0) ||
3428
+ (this.containsAlert && this.alertOptions) ||
3429
+ (this.pathways?.length > 0) ||
3430
+ (this.taxonConnectivity?.length > 0) ||
3431
+ (this.legendEntry?.length > 0)
3432
+ ) {
3425
3433
  this.drawerOpen = true
3426
3434
  return true
3427
- } else {
3428
- if ((this.systems?.length > 0) ||
3429
- (this.containsAlert && this.alertOptions) ||
3430
- (this.pathways?.length > 0) ||
3431
- (this.taxonConnectivity?.length > 0)
3432
- ) {
3433
- this.drawerOpen = true
3434
- return true
3435
- }
3436
3435
  }
3437
3436
  this.drawerOpen = false
3438
- return true
3437
+ return false
3439
3438
  },
3440
3439
  modeDescription: function () {
3441
3440
  let description = this.viewingModes[this.viewingMode]
@@ -3447,6 +3446,9 @@ export default {
3447
3446
  }
3448
3447
  return description
3449
3448
  },
3449
+ legendEntry: function () {
3450
+ return [...this.flatmapLegends, ...this.externalLegends]
3451
+ }
3450
3452
  },
3451
3453
  watch: {
3452
3454
  entry: function () {
@@ -3653,18 +3655,10 @@ export default {
3653
3655
  }
3654
3656
  }
3655
3657
 
3656
- .svg-legends-container {
3657
- width: 70%;
3658
- min-width:183px;
3659
- height: auto;
3660
- position: relative;
3661
- max-height: 140px;
3662
- }
3663
-
3664
3658
  .pathway-container {
3665
3659
  float: left;
3666
- padding-left: 16px;
3667
- padding-right: 18px;
3660
+ padding-left: 8px;
3661
+ padding-right: 8px;
3668
3662
  text-align: left;
3669
3663
  overflow: auto;
3670
3664
  border: 1px solid rgb(220, 223, 230);
@@ -3675,6 +3669,7 @@ export default {
3675
3669
  overflow-x: hidden;
3676
3670
  scrollbar-width: thin;
3677
3671
  transition: all var(--el-transition-duration);
3672
+ width: 276px;
3678
3673
  &.open {
3679
3674
  opacity: 1;
3680
3675
  position: relative;
@@ -91,6 +91,7 @@
91
91
  :showLocalSettings="showLocalSettings"
92
92
  :showOpenMapButton="showOpenMapButton"
93
93
  :showPathwayFilter="showPathwayFilter"
94
+ :externalLegends="externalLegends"
94
95
  />
95
96
  </div>
96
97
  </template>
@@ -100,7 +101,7 @@
100
101
  import { markRaw } from 'vue'
101
102
  import EventBus from './EventBus'
102
103
  import FlatmapVuer from './FlatmapVuer.vue'
103
- import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.2.10/+esm'
104
+ import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.2.13/+esm'
104
105
  import {
105
106
  ElCol as Col,
106
107
  ElOption as Option,
@@ -799,6 +800,13 @@ export default {
799
800
  type: Boolean,
800
801
  default: true,
801
802
  },
803
+ /**
804
+ * Allow to add and display extra legends to drawer
805
+ */
806
+ externalLegends: {
807
+ type: Array,
808
+ default: [],
809
+ },
802
810
  },
803
811
  data: function () {
804
812
  return {
@@ -7,10 +7,25 @@
7
7
  :label="item[identifierKey]"
8
8
  >
9
9
  <div class="legend-item" v-if="legendStyle(item)">
10
- <div
10
+ <template v-if="clipPathLegends.includes(legendStyle(item))">
11
+ <div
12
+ :class="legendStyle(item)"
13
+ :style="customClipPathStyle(item, true)"
14
+ >
15
+ <div
16
+ :class="legendStyle(item)"
17
+ :style="customClipPathStyle(item, false)"
18
+ >
19
+ </div>
20
+ </div>
21
+ </template>
22
+ <template v-else>
23
+ <div
11
24
  :class="legendStyle(item)"
12
- :style="{ 'background-color': item[colourKey] }"
13
- ></div>
25
+ :style="customStyle(item)"
26
+ >
27
+ </div>
28
+ </template>
14
29
  <div class="label">{{ capitalise(item[identifierKey]) }}</div>
15
30
  </div>
16
31
  </div>
@@ -18,6 +33,7 @@
18
33
  </template>
19
34
 
20
35
  <script>
36
+ const starTemplate = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="<fillColor>" stroke="<borderColor>" stroke-width="<borderWidth>" d="M11.0748 3.25583C11.4141 2.42845 12.5859 2.42845 12.9252 3.25583L14.6493 7.45955C14.793 7.80979 15.1221 8.04889 15.4995 8.07727L20.0303 8.41798C20.922 8.48504 21.2841 9.59942 20.6021 10.1778L17.1369 13.1166C16.8482 13.3614 16.7225 13.7483 16.8122 14.1161L17.8882 18.5304C18.1 19.3992 17.152 20.0879 16.3912 19.618L12.5255 17.2305C12.2034 17.0316 11.7966 17.0316 11.4745 17.2305L7.60881 19.618C6.84796 20.0879 5.90001 19.3992 6.1118 18.5304L7.18785 14.1161C7.2775 13.7483 7.1518 13.3614 6.86309 13.1166L3.3979 10.1778C2.71588 9.59942 3.07796 8.48504 3.96971 8.41798L8.50046 8.07727C8.87794 8.04889 9.20704 7.80979 9.35068 7.45955L11.0748 3.25583Z"/></svg>'
21
37
  /* eslint-disable no-alert, no-console */
22
38
  export default {
23
39
  name: "DynamicLegends",
@@ -26,10 +42,6 @@ export default {
26
42
  type: String,
27
43
  default: "id",
28
44
  },
29
- colourKey: {
30
- type: String,
31
- default: "colour",
32
- },
33
45
  styleKey: {
34
46
  type: String,
35
47
  default: "style",
@@ -49,22 +61,57 @@ export default {
49
61
  default: false,
50
62
  },
51
63
  },
64
+ computed: {
65
+ clipPathLegends: function () {
66
+ return ['exoid', 'hexagon'];
67
+ },
68
+ },
52
69
  methods: {
53
70
  capitalise: function (label) {
54
71
  return label.charAt(0).toUpperCase() + label.slice(1).toLowerCase();
55
72
  },
73
+ customStyle: function(item) {
74
+ const specifiedColour = item["color"] ? item["color"] : item["colour"];
75
+ let colour = specifiedColour ? specifiedColour : "transparent";
76
+ let borderColour = item.border ? item.border : "black";
77
+ if (specifiedColour && !item.border) {
78
+ borderColour = colour;
79
+ }
80
+ if (item[this.styleKey] === 'star') {
81
+ let star = starTemplate.replace('<fillColor>', colour);
82
+ star = star.replace('<borderColor>', borderColour);
83
+ star = star.replace('<borderWidth>', borderColour ? '2' : '0');
84
+ star = 'data:image/svg+xml,' + encodeURIComponent(star);
85
+ return { 'color': colour, 'background-image': `url(${star})` };
86
+ } else if (item[this.styleKey] === 'line') {
87
+ return {'color': colour};
88
+ } else {
89
+ return { 'background-color': colour, 'border-color': borderColour};
90
+ }
91
+ },
92
+ customClipPathStyle: function(item, isBorder) {
93
+ const style = this.customStyle(item);
94
+ if (isBorder) {
95
+ style['background-color'] = style['border-color'];
96
+ } else {
97
+ style.scale = 0.7;
98
+ }
99
+ return style;
100
+ },
56
101
  legendStyle: function (item) {
57
102
  if (item[this.styleKey] === "star") {
58
103
  if (item[this.identifierKey] === "Featured dataset marker") {
59
104
  if (!this.showStarInLegend) {
60
105
  return;
61
106
  }
62
- return "yellow-star";
63
- } else if (item[this.identifierKey] === "Gaglionated nerve plexus") {
64
- return "hexagon-star";
65
107
  }
108
+ return 'star';
109
+ } else if (this.clipPathLegends.includes(item[this.styleKey])) {
110
+ return item[this.styleKey];
111
+ } else if (item[this.styleKey] === 'line') {
112
+ return [item[this.styleKey], item.dashed ? 'dashed' : '', item.arrow ? 'arrow' : ''];
66
113
  }
67
- return item[this.styleKey];
114
+ return [item[this.styleKey], 'shape'];
68
115
  },
69
116
  },
70
117
  };
@@ -85,19 +132,63 @@ export default {
85
132
  margin: 8px 12.5px;
86
133
  }
87
134
 
88
- .circle {
89
- height: 20px;
135
+ .line {
136
+ position: relative;
90
137
  width: 20px;
91
- background-color: #ffffff;
92
- border-radius: 50%;
138
+ border-top: 2px solid currentColor;
139
+ }
140
+
141
+ .line.dashed {
142
+ border-top: 2px dashed currentColor;
143
+ }
144
+
145
+ .line::after {
146
+ content: "";
147
+ position: absolute;
148
+ right: -2px;
149
+ top: -5px;
150
+ width: 0;
151
+ height: 0;
152
+ border-left: 7px solid currentColor;
153
+ border-top: 4px solid transparent;
154
+ border-bottom: 4px solid transparent;
155
+ display: none;
156
+ }
157
+
158
+ .line.arrow::after {
159
+ display: block;
160
+ }
161
+
162
+ .shape {
163
+ height: 16px;
164
+ width: 16px;
165
+ border-color: black;
166
+ border-style: solid;
167
+ border-width: 2px;
168
+ background-color: transparent;
93
169
  display: inline-block;
94
170
  }
95
171
 
96
- .hexagon-star {
172
+ .circle {
173
+ border-radius: 50%;
174
+ }
175
+
176
+ .rounded-square {
177
+ border-radius: 30%;
178
+ }
179
+
180
+ .hexagon {
181
+ width: 20px;
182
+ height: calc(20px * 0.866);
183
+ background-color: transparent;
184
+ clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
185
+ -webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
186
+ }
187
+
188
+ .exoid {
97
189
  width: 20px;
98
190
  height: 25px;
99
- background-color: #ffffff;
100
- opacity: 0.64;
191
+ background-color: transparent;
101
192
  clip-path: path(
102
193
  "M9.96 0.72 c-2.01 3.53 -5.81 5.74 -9.92 5.74 l-0.15 0.23 c1.94 3.42 1.94 7.6 0 11.02 l0.15 0.23 c4.07 0 7.9 2.2 9.92 5.74 c2.01 -3.53 5.81 -5.74 9.92 -5.74 c-2.01 -3.53 -2.01 -7.94 0 -11.55 C15.81 6.5 12.04 4.29 9.96 0.72z"
103
194
  );
@@ -106,11 +197,10 @@ export default {
106
197
  );
107
198
  }
108
199
 
109
- .yellow-star {
200
+ .star {
110
201
  width: 25px;
111
202
  height: 25px;
112
- background-color: #ffffff !important;
113
- background-image: url("data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20fill%3D%22yellow%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%20d%3D%22M11.0748%203.25583C11.4141%202.42845%2012.5859%202.42845%2012.9252%203.25583L14.6493%207.45955C14.793%207.80979%2015.1221%208.04889%2015.4995%208.07727L20.0303%208.41798C20.922%208.48504%2021.2841%209.59942%2020.6021%2010.1778L17.1369%2013.1166C16.8482%2013.3614%2016.7225%2013.7483%2016.8122%2014.1161L17.8882%2018.5304C18.1%2019.3992%2017.152%2020.0879%2016.3912%2019.618L12.5255%2017.2305C12.2034%2017.0316%2011.7966%2017.0316%2011.4745%2017.2305L7.60881%2019.618C6.84796%2020.0879%205.90001%2019.3992%206.1118%2018.5304L7.18785%2014.1161C7.2775%2013.7483%207.1518%2013.3614%206.86309%2013.1166L3.3979%2010.1778C2.71588%209.59942%203.07796%208.48504%203.96971%208.41798L8.50046%208.07727C8.87794%208.04889%209.20704%207.80979%209.35068%207.45955L11.0748%203.25583Z%22/%3E%3C/svg%3E");
203
+ background-color: transparent !important;
114
204
  background-repeat: no-repeat;
115
205
  background-size: contain;
116
206
  display: inline-block;