i am trying to add tooltip and data over hover of a sprite inside using the data visualization api. I have achieved adding the sprite viewable, but it is not mentioned as to how we add a tooltip on hover. Docs just mention there is a DATAVID_OBJECT_HOVERING event that is triggered to the viewer object, and we can add a callback on it. Also the code is not clear. Attaching hyperion demo's code below which only adds a callback to the onhover event on sprite and no mention of tooltip and data passed to it. Where in the code that is present as in this website i am seeing the tooltip with some data. this is the link https://hyperion.autodesk.io/ and code is this https://github.dev/Autodesk-Forge/forge-dataviz-iot-reference-app
async function onModelLoaded(viewer) {
const dataVizExt = viewer.getExtension("Autodesk.DataVisualization");
const DATAVIZEXTN = Autodesk.DataVisualization.Core;
var styleMap = {};
// Create model-to-style map from style definitions.
Object.entries(SensorStyleDefinitions).forEach(([type, styleDef]) => {
styleMap[type] = new DATAVIZEXTN.ViewableStyle(
DATAVIZEXTN.ViewableType.SPRITE,
new THREE.Color(styleDef.color),
styleDef.url
);
});
const viewableData = new DATAVIZEXTN.ViewableData();
viewableData.spriteSize = 16;
let startId = 1;
devices.forEach((device) => {
let style = styleMap[device.type] || styleMap["default"];
const viewable = new DATAVIZEXTN.SpriteViewable(device.position, style, startId);
viewableData.addViewable(viewable);
startId++;
});
await viewableData.finish();
dataVizExt.addViewables(viewableData);
/**
* Called when a user clicks on a Sprite Viewable
* @param {Event} event
*/
function onItemClick(/* event */) {}
/**
* Called when a user hovers over a Sprite Viewable
* @param {Event} event
*/
function onItemHovering(event) {
console.log("Show tooltip here", event.dbId);
}
const DataVizCore = Autodesk.DataVisualization.Core;
viewer.addEventListener(DataVizCore.MOUSE_CLICK, onItemClick);
viewer.addEventListener(DataVizCore.MOUSE_HOVERING, onItemHovering);
}