The ViewerHeatmapAPI provides functionality to visualize a heatmap based on a given set of points.
Quick Start
Example: Adding heatmap data and configuring the heatmap:
// get an instance of the ContextAPI and the matching ViewerAPIconstcontext = webvis.getContext();constviewer = context.getViewer();// add the modelconstmodel = context.add({ dataURI:MODEL, initialProperties: { enabled:true } });// add matching heatmap dataconstheatmapPositions = [0, 1, 0, // first point0, 1, 1, // second point0, 0, 2, // third point];constheatmapDataId = viewer.createHeatmap({ position:heatmapPositions });// configure the heatmapviewer.configureHeatmap({// set a color schemecolorScheme:"Blackbody",// calculated density is normalized, upper end of color scheme is mapped to maxValuemaxValue:100,}
Events
The following events are associated with the ViewerHeatmapAPI:
viewer.changeGlobalHeatmapConfig({// set a color schemecolorScheme:webvis.HeatmapColorScheme.BLACKBODY,// calculated density is normalized, upper end of color scheme is mapped to maxValuemaxValue:100,// configure heatmap to be had 5 separated bands of colors (smooth gradient by default)colorBands:true,colorResolution:5,// kernel defines the falloff from a point's center to its edge// this defaults to a gaussian curve, but other options are availablekernel:webvis.HeatmapKernal.LINEAR,// scale all points' size uniformly for more/less overlapsizeFactor:2,// scale all point's strength uniformly// this has the same effect as adjusting maxValue by the inverse factorstrengthFactor:1.5,});
Example: Adding points to an existing heatmap dataset:
// [continued createHeatmapData example]// add pointsheatmapPositions.push(1, 3, 0, // fourth point3, 0, 1, // fifth point)// update data by passing id and data to overrideviewer.changeHeatmap(heatmapDataId, { position:heatmapPositions });
// positions are stored in a flat arrayconstheatmapPositions = [0, 1, 0, // first point0, 1, 1, // second point0, 0, 2, // third point];constheatmapDataId = viewer.createHeatmap({ position:heatmapPositions });
Example: Adding heatmap data with varying size/strength:
By specifying per-point size and/or strength, you can tweak ther influence on the heatmap. This example defines two points:
Small radius and high strength. Represents a precisely located but highly important issue.
High radius and low strength. Represents a low-priority issue affecting a larger area.
Note: The number of points defined by position, size and strength must match. Since position contains the coordinates, its length must be three times that of size and strength.
constposition = [0, 0, 0, // first point1, 0, 0, // second point];constsize = [0.2, // first point has small radius3, // second point has large radius];conststrength = [2, // first point has a high impact0.5, // second point has a low impact];constheatmapDataId = viewer.createHeatmap({ position, size, strength });
ViewerHeatmapAPI
Overview
The ViewerHeatmapAPI provides functionality to visualize a heatmap based on a given set of points.
Quick Start
Example: Adding heatmap data and configuring the heatmap:
Events
The following events are associated with the ViewerHeatmapAPI: