UNPKG

@domoinc/image-tooltip

Version:

ImageTooltip - Domo Widget

56 lines (44 loc) 2.44 kB
/*---------------------------------------------------------------------------------- Chart Auto Widget File © 2011 - 2015 DOMO, INC. ----------------------------------------------------------------------------------*/ // Add your chart to our the registry with your chart's unique name. AutoWidgets.register('DomoImageTooltipDomo', function(container) { // Use the bBox of the 'chartBounds' rect to find out the size of the chart we need to render. var bBox = container.select('[id^=chartBounds]') .node() .getBBox(); // Transform our chart's container to fit where the user placed the widget container.attr('transform', 'translate(' + bBox.x + ', ' + bBox.y + ')') .selectAll('*') .remove(); // Set some sample data to use with out widget. var imageUrl = 'https://s3.amazonaws.com/Domo_infographic/fauxmosapiens/fauxmosapien-male-15-90.jpg'; var bodyText = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.' var sampleData = [ ['Title', bodyText, imageUrl, 'https://www.domo.com/'] ]; // Set the data subscription name to what user specified. var dataName = container.node().parentNode.id; // Create the data subscription with sample data. // You can create as many of these as your chart needs. var sampleDataObj = {}; sampleDataObj[dataName] = { columnNames: ['Title', 'Text', 'Image Url', 'Link Url'], defaultValue: sampleData }; //Initialize widget and set parameters. var widget = AutoWidgets.baseWidget(container.chart('ImageTooltip')) .c({ 'height': bBox.height, 'width': bBox.width, }) .sampleData(sampleDataObj); // Used for sample data check. widget._sampleData = sampleData; widget._notifier.showMessage(true); // Pass the dataname to widget object so it knows which data to call on render. widget.dataName(dataName); // Return widget so to keep the methods chainable. return widget; });