Skip to content

Commit 309e084

Browse files
Add tooltip dimension
1 parent 2d7831a commit 309e084

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

CS/AspNetCoreCustomItem/Data/Dashboards/countryInfo.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,31 @@
1212
</DataSources>
1313
<Items>
1414
<CustomItem ComponentName="customItemDashboardItem1" Name="Online Map" DataSource="excelDataSource1" CustomItemType="OnlineMap">
15-
<CustomProperties>
1615
<Type>RoadMap</Type>
17-
</CustomProperties>
1816
<InteractivityOptions MasterFilterMode="Single" />
1917
<DataItems>
2018
<Dimension DataMember="Latitude" DefaultId="DataItem0" />
2119
<Dimension DataMember="Longitude" DefaultId="DataItem1" />
20+
<Dimension DataMember="Country" DefaultId="DataItem2" />
2221
</DataItems>
2322
<SliceTables>
2423
<SliceTable Name="SliceTable1">
2524
<Dimensions>
2625
<Dimension DefaultId="DataItem0" />
2726
<Dimension DefaultId="DataItem1" />
27+
<Dimension DefaultId="DataItem2" />
2828
</Dimensions>
2929
</SliceTable>
3030
</SliceTables>
3131
<InteractivityTargets>
3232
<Dimension DefaultId="DataItem0" />
3333
<Dimension DefaultId="DataItem1" />
34+
<Dimension DefaultId="DataItem2" />
3435
</InteractivityTargets>
3536
<CustomMetadata>
3637
<Latitude ItemType="Dimension" DefaultId="DataItem0" />
3738
<Longitude ItemType="Dimension" DefaultId="DataItem1" />
39+
<Tooltip ItemType="Dimension" DefaultId="DataItem2" />
3840
</CustomMetadata>
3941
</CustomItem>
4042
<CustomItem ComponentName="customItemDashboardItem2" Name="Web Page" DataSource="excelDataSource1" CustomItemType="WebPage">

CS/AspNetCoreCustomItem/wwwroot/js/OnlineMapItem.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@
3636
constraints: {
3737
allowedTypes: ['Integer', 'Float', 'Double', 'Decimal']
3838
}
39+
}, {
40+
propertyName: 'Tooltip',
41+
dataItemType: 'Dimension',
42+
array: false,
43+
enableInteractivity: true,
44+
displayName: 'Tooltip',
45+
emptyPlaceholder: 'Set Tooltip',
46+
selectedPlaceholder: 'Configure Tooltip',
47+
constraints: {
48+
allowedTypes: ['Text']
49+
}
3950
}],
4051
customProperties: [{
4152
ownerType: Model.CustomItem,
@@ -101,7 +112,12 @@
101112
OnlineMapItemViewer.prototype = Object.create(Dashboard.CustomItemViewer.prototype);
102113
OnlineMapItemViewer.prototype.constructor = OnlineMapItemViewer;
103114

104-
OnlineMapItemViewer.prototype._onClick = function (row) {
115+
OnlineMapItemViewer.prototype._onClick = function (index, row) {
116+
var markers = this.mapViewer.option('markers');
117+
for (var i = 0; i < markers.length; i++) {
118+
markers[i].tooltip.isShown = i == index;
119+
}
120+
105121
this.setMasterFilter(row);
106122
this._updateSelection();
107123
};
@@ -138,22 +154,32 @@
138154
showMarkers = mode === 'Markers' || mode === 'MarkersAndRoutes' || this.canMasterFilter(),
139155
showRoutes = mode === 'Routes' || mode === 'MarkersAndRoutes';
140156
if (this.getBindingValue('Latitude').length > 0 && this.getBindingValue('Longitude').length > 0) {
157+
let index = 0;
141158
this.iterateData(row => {
142159
var latitude = row.getValue('Latitude')[0];
143160
var longitude = row.getValue('Longitude')[0];
161+
var tooltip = row.getValue('Tooltip')[0];
162+
163+
let idx = index;
164+
144165
if (latitude && longitude) {
145166
if (showMarkers) {
146167
markers.push({
147168
location: { lat: latitude, lng: longitude },
148169
iconSrc: this.isSelected(row) ? "https://js.devexpress.com/Demos/RealtorApp/images/map-marker.png" : null,
149-
onClick: args => this._onClick(row),
170+
onClick: args => this._onClick(idx, row),
171+
tooltip: {
172+
text: tooltip
173+
},
150174
tag: row
151175
});
152176
}
153177
if (showRoutes) {
154178
routes.push([latitude, longitude]);
155179
}
156180
}
181+
182+
index++;
157183
});
158184
}
159185
let autoAdjust = markers.length > 0 || routes.length > 0,
@@ -177,7 +203,7 @@
177203
opacity: 0.5,
178204
mode: '',
179205
locations: routes
180-
}] : []
206+
}] : [],
181207
};
182208
if (changeExisting && this.mapViewer) {
183209
this.mapViewer.option(options);

0 commit comments

Comments
 (0)