UNPKG

@domoinc/domo-select

Version:

DomoSelect - Domo Widget

70 lines (57 loc) 1.69 kB
AutoWidgets.register("DomoDomoSelectDomo", function(container) { var bBox = container.select('[id^=chartBounds]') .node() .getBoundingClientRect(); container.selectAll('*').remove(); var sampleData = [ ['All', null], ['North', 'North'], ['East', 'East'], ['South', 'South'], ['West', 'West'] ]; // Set the data subscription name to what user specified. var dataName = container.node().parentNode.id; // This will allow the wiring experience to show the user // which widget item they are powering. container.attr("data-domo-link", dataName); var sampleDataObj = {}; sampleDataObj[dataName] = { defaultValue: sampleData, columnNames: ["Display Name", "Value"] }; var baseDiv = d3.select('body') .append('div') .style({ position: 'absolute', top: bBox.top + 'px', left: bBox.left + 'px' }); var widget = AutoWidgets.baseWidget(baseDiv.chart("DomoSelect")) .c({ width: bBox.width, }) .sampleData(sampleDataObj) .on('dispatch:selection', function(d){ AutoWidgets.filterChange(dataName, d.data[1]); }); widget.dataName(dataName); widget.prepareForArtboard = function() { container.selectAll('[id^=chartBounds]') .remove(); container.insert('rect', ':first-child') .attr('id', 'chartBounds') .attr({ 'height': widget.base.select('.da-btn').style('height'), 'width': widget.c('width') + 'px' }) .style('fill', 'none'); }; widget.rasterizeNodes = [{ node: widget._layerGroup.node(), insert: function(image) { container.node().appendChild(image); } }]; return widget; });